- Timestamp:
- 3 Dec 2021, 08:10:26 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.unidel/trunk/src/kofacustom/unidel/applicants/browser.py
r16721 r16734 19 19 """ 20 20 import grok 21 from zope.formlib.textwidgets import BytesDisplayWidget 21 22 from waeup.kofa.applicants.browser import ( 22 23 ApplicantRegistrationPage, ApplicantsContainerPage) … … 31 32 INigeriaPGApplicantEdit, INigeriaUGApplicantEdit, 32 33 INigeriaApplicantOnlinePayment, 33 UG_OMIT_DISPLAY_FIELDS,34 UG_OMIT_PDF_FIELDS,35 UG_OMIT_MANAGE_FIELDS,36 UG_OMIT_EDIT_FIELDS,34 #UG_OMIT_DISPLAY_FIELDS, 35 #UG_OMIT_PDF_FIELDS, 36 #UG_OMIT_MANAGE_FIELDS, 37 #UG_OMIT_EDIT_FIELDS, 37 38 PG_OMIT_DISPLAY_FIELDS, 38 39 PG_OMIT_PDF_FIELDS, … … 48 49 from kofacustom.unidel.interfaces import MessageFactory as _ 49 50 51 OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 52 'result_uploaded', 'suspended', 'special_application', 53 'bank_account_number', 54 'bank_account_name', 55 'bank_name') 56 57 # UG students are all undergraduate students. 58 UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( 59 'jamb_subjects_list', 60 'programme_type',) 61 UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',) 62 UG_OMIT_MANAGE_FIELDS = ( 63 'special_application', 64 'jamb_subjects_list', 65 'programme_type',) 66 UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( 67 'student_id', 68 'notice', 69 'screening_score', 70 'screening_venue', 71 'screening_date', 72 'jamb_age', 73 #'jamb_subjects', 74 #'jamb_score', 75 #'jamb_reg_number', 76 'aggregate',) 77 78 79 class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): 80 """A display view for applicant data. 81 """ 82 83 @property 84 def form_fields(self): 85 if self.target is not None and self.target.startswith('pg'): 86 form_fields = grok.AutoFields(ICustomPGApplicant) 87 for field in PG_OMIT_DISPLAY_FIELDS: 88 form_fields = form_fields.omit(field) 89 else: 90 form_fields = grok.AutoFields(ICustomUGApplicant) 91 for field in UG_OMIT_DISPLAY_FIELDS: 92 form_fields = form_fields.omit(field) 93 #form_fields['perm_address'].custom_widget = BytesDisplayWidget 94 form_fields['notice'].custom_widget = BytesDisplayWidget 95 if not getattr(self.context, 'student_id'): 96 form_fields = form_fields.omit('student_id') 97 if not getattr(self.context, 'screening_score'): 98 form_fields = form_fields.omit('screening_score') 99 if not getattr(self.context, 'screening_venue') or self._not_paid(): 100 form_fields = form_fields.omit('screening_venue') 101 if not getattr(self.context, 'screening_date') or self._not_paid(): 102 form_fields = form_fields.omit('screening_date') 103 return form_fields 104 105 class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): 106 107 @property 108 def form_fields(self): 109 if self.target is not None and self.target.startswith('pg'): 110 form_fields = grok.AutoFields(ICustomPGApplicant) 111 for field in PG_OMIT_PDF_FIELDS: 112 form_fields = form_fields.omit(field) 113 else: 114 form_fields = grok.AutoFields(ICustomUGApplicant) 115 for field in UG_OMIT_PDF_FIELDS: 116 form_fields = form_fields.omit(field) 117 if not getattr(self.context, 'student_id'): 118 form_fields = form_fields.omit('student_id') 119 if not getattr(self.context, 'screening_score'): 120 form_fields = form_fields.omit('screening_score') 121 if not getattr(self.context, 'screening_venue'): 122 form_fields = form_fields.omit('screening_venue') 123 if not getattr(self.context, 'screening_date'): 124 form_fields = form_fields.omit('screening_date') 125 return form_fields 126 127 class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): 128 """A full edit view for applicant data. 129 """ 130 131 @property 132 def form_fields(self): 133 if self.target is not None and self.target.startswith('pg'): 134 form_fields = grok.AutoFields(ICustomPGApplicant) 135 for field in PG_OMIT_MANAGE_FIELDS: 136 form_fields = form_fields.omit(field) 137 else: 138 form_fields = grok.AutoFields(ICustomUGApplicant) 139 for field in UG_OMIT_MANAGE_FIELDS: 140 form_fields = form_fields.omit(field) 141 form_fields['student_id'].for_display = True 142 form_fields['applicant_id'].for_display = True 143 return form_fields 144 50 145 class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): 51 146 """An applicant-centered edit view for applicant data. … … 55 150 return True 56 151 152 @property 153 def form_fields(self): 154 if self.target is not None and self.target.startswith('pg'): 155 form_fields = grok.AutoFields(ICustomPGApplicantEdit) 156 for field in PG_OMIT_EDIT_FIELDS: 157 form_fields = form_fields.omit(field) 158 else: 159 form_fields = grok.AutoFields(ICustomUGApplicantEdit) 160 for field in UG_OMIT_EDIT_FIELDS: 161 form_fields = form_fields.omit(field) 162 form_fields['applicant_id'].for_display = True 163 form_fields['reg_number'].for_display = True 164 return form_fields
Note: See TracChangeset for help on using the changeset viewer.