| 1 | ## $Id: browser.py 18363 2026-11-16 11:20:39Z 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 |
|---|
| 21 | from zope.formlib.textwidgets import BytesDisplayWidget |
|---|
| 22 | from waeup.kofa.applicants.browser import ( |
|---|
| 23 | ApplicantRegistrationPage, ApplicantsContainerPage, |
|---|
| 24 | AdditionalFile) |
|---|
| 25 | from kofacustom.nigeria.applicants.browser import ( |
|---|
| 26 | NigeriaApplicantDisplayFormPage, |
|---|
| 27 | NigeriaApplicantManageFormPage, |
|---|
| 28 | NigeriaApplicantEditFormPage, |
|---|
| 29 | NigeriaPDFApplicationSlip) |
|---|
| 30 | |
|---|
| 31 | from kofacustom.nigeria.applicants.interfaces import ( |
|---|
| 32 | INigeriaPGApplicant, INigeriaUGApplicant, |
|---|
| 33 | INigeriaPGApplicantEdit, INigeriaUGApplicantEdit, |
|---|
| 34 | INigeriaApplicantOnlinePayment, |
|---|
| 35 | #UG_OMIT_DISPLAY_FIELDS, |
|---|
| 36 | #UG_OMIT_PDF_FIELDS, |
|---|
| 37 | #UG_OMIT_MANAGE_FIELDS, |
|---|
| 38 | #UG_OMIT_EDIT_FIELDS, |
|---|
| 39 | PG_OMIT_DISPLAY_FIELDS, |
|---|
| 40 | PG_OMIT_PDF_FIELDS, |
|---|
| 41 | PG_OMIT_MANAGE_FIELDS, |
|---|
| 42 | PG_OMIT_EDIT_FIELDS, |
|---|
| 43 | ) |
|---|
| 44 | from kofacustom.unidel.applicants.interfaces import ( |
|---|
| 45 | ICustomPGApplicant, ICustomUGApplicant, ICustomApplicant, |
|---|
| 46 | ICustomPGApplicantEdit, ICustomUGApplicantEdit, |
|---|
| 47 | ICustomApplicantOnlinePayment, |
|---|
| 48 | ) |
|---|
| 49 | |
|---|
| 50 | from kofacustom.unidel.interfaces import MessageFactory as _ |
|---|
| 51 | |
|---|
| 52 | OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', |
|---|
| 53 | 'result_uploaded', 'suspended', 'special_application', |
|---|
| 54 | 'bank_account_number', |
|---|
| 55 | 'bank_account_name', |
|---|
| 56 | 'bank_name', |
|---|
| 57 | 'jamb_subjects_list') |
|---|
| 58 | |
|---|
| 59 | # UG students are all undergraduate students. |
|---|
| 60 | UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
|---|
| 61 | 'jamb_subjects_list', |
|---|
| 62 | 'programme_type',) |
|---|
| 63 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',) |
|---|
| 64 | UG_OMIT_MANAGE_FIELDS = ( |
|---|
| 65 | 'special_application', |
|---|
| 66 | 'jamb_subjects_list', |
|---|
| 67 | 'programme_type',) |
|---|
| 68 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
|---|
| 69 | 'student_id', |
|---|
| 70 | 'notice', |
|---|
| 71 | 'screening_score', |
|---|
| 72 | 'screening_venue', |
|---|
| 73 | 'screening_date', |
|---|
| 74 | 'jamb_age', |
|---|
| 75 | 'jamb_subjects', |
|---|
| 76 | 'jamb_score', |
|---|
| 77 | 'jamb_reg_number', |
|---|
| 78 | 'aggregate', |
|---|
| 79 | 'lga',) |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
|---|
| 83 | """A display view for applicant data. |
|---|
| 84 | """ |
|---|
| 85 | |
|---|
| 86 | @property |
|---|
| 87 | def form_fields(self): |
|---|
| 88 | if self.target is not None and self.target.startswith('pg'): |
|---|
| 89 | form_fields = grok.AutoFields(ICustomPGApplicant) |
|---|
| 90 | for field in PG_OMIT_DISPLAY_FIELDS: |
|---|
| 91 | form_fields = form_fields.omit(field) |
|---|
| 92 | else: |
|---|
| 93 | form_fields = grok.AutoFields(ICustomUGApplicant) |
|---|
| 94 | for field in UG_OMIT_DISPLAY_FIELDS: |
|---|
| 95 | form_fields = form_fields.omit(field) |
|---|
| 96 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
|---|
| 97 | form_fields['notice'].custom_widget = BytesDisplayWidget |
|---|
| 98 | if not getattr(self.context, 'student_id'): |
|---|
| 99 | form_fields = form_fields.omit('student_id') |
|---|
| 100 | if not getattr(self.context, 'screening_score'): |
|---|
| 101 | form_fields = form_fields.omit('screening_score') |
|---|
| 102 | if not getattr(self.context, 'screening_venue') or self._not_paid(): |
|---|
| 103 | form_fields = form_fields.omit('screening_venue') |
|---|
| 104 | if not getattr(self.context, 'screening_date') or self._not_paid(): |
|---|
| 105 | form_fields = form_fields.omit('screening_date') |
|---|
| 106 | return form_fields |
|---|
| 107 | |
|---|
| 108 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
|---|
| 109 | |
|---|
| 110 | @property |
|---|
| 111 | def form_fields(self): |
|---|
| 112 | if self.target is not None and self.target.startswith('pg'): |
|---|
| 113 | form_fields = grok.AutoFields(ICustomPGApplicant) |
|---|
| 114 | for field in PG_OMIT_PDF_FIELDS: |
|---|
| 115 | form_fields = form_fields.omit(field) |
|---|
| 116 | else: |
|---|
| 117 | form_fields = grok.AutoFields(ICustomUGApplicant) |
|---|
| 118 | for field in UG_OMIT_PDF_FIELDS: |
|---|
| 119 | form_fields = form_fields.omit(field) |
|---|
| 120 | if not getattr(self.context, 'student_id'): |
|---|
| 121 | form_fields = form_fields.omit('student_id') |
|---|
| 122 | if not getattr(self.context, 'screening_score'): |
|---|
| 123 | form_fields = form_fields.omit('screening_score') |
|---|
| 124 | if not getattr(self.context, 'screening_venue'): |
|---|
| 125 | form_fields = form_fields.omit('screening_venue') |
|---|
| 126 | if not getattr(self.context, 'screening_date'): |
|---|
| 127 | form_fields = form_fields.omit('screening_date') |
|---|
| 128 | return form_fields |
|---|
| 129 | |
|---|
| 130 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
|---|
| 131 | """A full edit view for applicant data. |
|---|
| 132 | """ |
|---|
| 133 | |
|---|
| 134 | @property |
|---|
| 135 | def form_fields(self): |
|---|
| 136 | if self.target is not None and self.target.startswith('pg'): |
|---|
| 137 | form_fields = grok.AutoFields(ICustomPGApplicant) |
|---|
| 138 | for field in PG_OMIT_MANAGE_FIELDS: |
|---|
| 139 | form_fields = form_fields.omit(field) |
|---|
| 140 | else: |
|---|
| 141 | form_fields = grok.AutoFields(ICustomUGApplicant) |
|---|
| 142 | for field in UG_OMIT_MANAGE_FIELDS: |
|---|
| 143 | form_fields = form_fields.omit(field) |
|---|
| 144 | form_fields['student_id'].for_display = True |
|---|
| 145 | form_fields['applicant_id'].for_display = True |
|---|
| 146 | return form_fields |
|---|
| 147 | |
|---|
| 148 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
|---|
| 149 | """An applicant-centered edit view for applicant data. |
|---|
| 150 | """ |
|---|
| 151 | |
|---|
| 152 | def unremovable(self, ticket): |
|---|
| 153 | return True |
|---|
| 154 | |
|---|
| 155 | @property |
|---|
| 156 | def form_fields(self): |
|---|
| 157 | if self.target is not None and self.target.startswith('pg'): |
|---|
| 158 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
|---|
| 159 | for field in PG_OMIT_EDIT_FIELDS: |
|---|
| 160 | form_fields = form_fields.omit(field) |
|---|
| 161 | elif getattr(self.context.__parent__, 'code', None) == 'ase2023': |
|---|
| 162 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
|---|
| 163 | temp_UG_OMIT_EDIT_FIELDS = list(UG_OMIT_EDIT_FIELDS) |
|---|
| 164 | for x in ('jamb_subjects', |
|---|
| 165 | 'jamb_score', |
|---|
| 166 | 'jamb_reg_number', |
|---|
| 167 | 'lga',): |
|---|
| 168 | temp_UG_OMIT_EDIT_FIELDS.remove(x) |
|---|
| 169 | for field in temp_UG_OMIT_EDIT_FIELDS: |
|---|
| 170 | form_fields = form_fields.omit(field) |
|---|
| 171 | else: |
|---|
| 172 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
|---|
| 173 | for field in UG_OMIT_EDIT_FIELDS: |
|---|
| 174 | form_fields = form_fields.omit(field) |
|---|
| 175 | form_fields['applicant_id'].for_display = True |
|---|
| 176 | form_fields['reg_number'].for_display = True |
|---|
| 177 | form_fields['firstname'].for_display = True |
|---|
| 178 | form_fields['middlename'].for_display = True |
|---|
| 179 | form_fields['lastname'].for_display = True |
|---|
| 180 | return form_fields |
|---|
| 181 | |
|---|
| 182 | class FstSitResDoc(AdditionalFile): |
|---|
| 183 | grok.name('fst_sit_doc') |
|---|
| 184 | |
|---|
| 185 | class ScdSitResDoc(AdditionalFile): |
|---|
| 186 | grok.name('scd_sit_doc') |
|---|
| 187 | |
|---|
| 188 | class FstDegResult(AdditionalFile): |
|---|
| 189 | grok.name('fst_deg_result') |
|---|
| 190 | |
|---|
| 191 | class Transcript(AdditionalFile): |
|---|
| 192 | grok.name('transcript') |
|---|
| 193 | |
|---|
| 194 | class NYSC(AdditionalFile): |
|---|
| 195 | grok.name('nysc') |
|---|
| 196 | |
|---|
| 197 | class MasterDegResult(AdditionalFile): |
|---|
| 198 | grok.name('master_deg_rst') |
|---|
| 199 | |
|---|
| 200 | class PGDPResult(AdditionalFile): |
|---|
| 201 | grok.name('pg_grad_dp_rst') |
|---|
| 202 | |
|---|
| 203 | class HNDResult(AdditionalFile): |
|---|
| 204 | grok.name('hnd_rst') |
|---|
| 205 | |
|---|
| 206 | class Other1(AdditionalFile): |
|---|
| 207 | grok.name('other1') |
|---|
| 208 | |
|---|
| 209 | class Other2(AdditionalFile): |
|---|
| 210 | grok.name('other2') |
|---|