[10765] | 1 | ## $Id: browser.py 15807 2019-11-14 14:45:16Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
| 18 | """UI components for basic applicants and related components. |
---|
| 19 | """ |
---|
| 20 | import grok |
---|
[15807] | 21 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[10765] | 22 | from waeup.kofa.applicants.browser import ( |
---|
| 23 | ApplicantRegistrationPage, ApplicantsContainerPage) |
---|
[15807] | 24 | from waeup.kofa.applicants.interfaces import ISpecialApplicant |
---|
[10765] | 25 | from kofacustom.nigeria.applicants.browser import ( |
---|
| 26 | NigeriaApplicantDisplayFormPage, |
---|
[15807] | 27 | NigeriaApplicantManageFormPage, |
---|
| 28 | NigeriaApplicantEditFormPage, |
---|
[10765] | 29 | NigeriaPDFApplicationSlip) |
---|
[15807] | 30 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
| 31 | UG_OMIT_DISPLAY_FIELDS, |
---|
| 32 | UG_OMIT_PDF_FIELDS, |
---|
| 33 | UG_OMIT_MANAGE_FIELDS, |
---|
| 34 | UG_OMIT_EDIT_FIELDS, |
---|
| 35 | PG_OMIT_DISPLAY_FIELDS, |
---|
| 36 | PG_OMIT_PDF_FIELDS, |
---|
| 37 | PG_OMIT_MANAGE_FIELDS, |
---|
| 38 | PG_OMIT_EDIT_FIELDS, |
---|
| 39 | ) |
---|
| 40 | from kofacustom.iuokada.applicants.interfaces import ( |
---|
| 41 | ICustomPGApplicant, ICustomUGApplicant, |
---|
| 42 | ICustomPGApplicantEdit, ICustomUGApplicantEdit, |
---|
| 43 | ICustomApplicantOnlinePayment |
---|
| 44 | ) |
---|
[15563] | 45 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
[10765] | 46 | |
---|
[15793] | 47 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
| 48 | """A display view for applicant data. |
---|
| 49 | """ |
---|
[15807] | 50 | |
---|
[15793] | 51 | @property |
---|
| 52 | def form_fields(self): |
---|
[15807] | 53 | if self.target is not None and self.target.startswith('pg'): |
---|
| 54 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 55 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
| 56 | form_fields = form_fields.omit(field) |
---|
[15793] | 57 | else: |
---|
[15807] | 58 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 59 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
| 60 | form_fields = form_fields.omit(field) |
---|
| 61 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 62 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
| 63 | if not getattr(self.context, 'student_id'): |
---|
| 64 | form_fields = form_fields.omit('student_id') |
---|
| 65 | if not getattr(self.context, 'screening_score'): |
---|
| 66 | form_fields = form_fields.omit('screening_score') |
---|
| 67 | if not getattr(self.context, 'screening_venue') or self._not_paid(): |
---|
| 68 | form_fields = form_fields.omit('screening_venue') |
---|
| 69 | if not getattr(self.context, 'screening_date') or self._not_paid(): |
---|
| 70 | form_fields = form_fields.omit('screening_date') |
---|
[15793] | 71 | return form_fields |
---|
| 72 | |
---|
[15807] | 73 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
| 74 | """A full edit view for applicant data. |
---|
| 75 | """ |
---|
| 76 | |
---|
| 77 | @property |
---|
| 78 | def form_fields(self): |
---|
| 79 | if self.target is not None and self.target.startswith('pg'): |
---|
| 80 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 81 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
| 82 | form_fields = form_fields.omit(field) |
---|
| 83 | else: |
---|
| 84 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 85 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
| 86 | form_fields = form_fields.omit(field) |
---|
| 87 | form_fields['student_id'].for_display = True |
---|
| 88 | form_fields['applicant_id'].for_display = True |
---|
| 89 | return form_fields |
---|
| 90 | |
---|
| 91 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
| 92 | """An applicant-centered edit view for applicant data. |
---|
| 93 | """ |
---|
| 94 | |
---|
| 95 | @property |
---|
| 96 | def form_fields(self): |
---|
| 97 | if self.target is not None and self.target.startswith('pg'): |
---|
| 98 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
| 99 | for field in PG_OMIT_EDIT_FIELDS: |
---|
| 100 | form_fields = form_fields.omit(field) |
---|
| 101 | else: |
---|
| 102 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 103 | for field in UG_OMIT_EDIT_FIELDS: |
---|
| 104 | form_fields = form_fields.omit(field) |
---|
| 105 | form_fields['applicant_id'].for_display = True |
---|
| 106 | form_fields['reg_number'].for_display = True |
---|
| 107 | return form_fields |
---|
| 108 | |
---|
| 109 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
| 110 | |
---|
| 111 | @property |
---|
| 112 | def form_fields(self): |
---|
| 113 | if self.target is not None and self.target.startswith('pg'): |
---|
| 114 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 115 | for field in PG_OMIT_PDF_FIELDS: |
---|
| 116 | form_fields = form_fields.omit(field) |
---|
| 117 | else: |
---|
| 118 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 119 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 120 | form_fields = form_fields.omit(field) |
---|
| 121 | if not getattr(self.context, 'student_id'): |
---|
| 122 | form_fields = form_fields.omit('student_id') |
---|
| 123 | if not getattr(self.context, 'screening_score'): |
---|
| 124 | form_fields = form_fields.omit('screening_score') |
---|
| 125 | if not getattr(self.context, 'screening_venue'): |
---|
| 126 | form_fields = form_fields.omit('screening_venue') |
---|
| 127 | if not getattr(self.context, 'screening_date'): |
---|
| 128 | form_fields = form_fields.omit('screening_date') |
---|
| 129 | return form_fields |
---|
| 130 | |
---|