[8012] | 1 | ## $Id: browser.py 17538 2023-08-15 09:47:00Z 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 | """ |
---|
[10287] | 20 | import grok |
---|
[11784] | 21 | from time import time |
---|
[11782] | 22 | from zope.component import getUtility, createObject |
---|
[14105] | 23 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
[11736] | 24 | from zope.security import checkPermission |
---|
[13552] | 25 | from zope.i18n import translate |
---|
[11784] | 26 | from hurry.workflow.interfaces import IWorkflowState |
---|
| 27 | from waeup.kofa.browser.layout import action, UtilityView |
---|
[13552] | 28 | from waeup.kofa.interfaces import IExtFileStore, IKofaUtils |
---|
[10587] | 29 | from waeup.kofa.applicants.browser import ( |
---|
[11728] | 30 | ApplicantRegistrationPage, ApplicantsContainerPage, |
---|
[11782] | 31 | ApplicationFeePaymentAddPage, |
---|
[11784] | 32 | OnlinePaymentApprovePage, |
---|
[14147] | 33 | ExportPDFPageApplicationSlip, |
---|
[16117] | 34 | ApplicantBaseDisplayFormPage, |
---|
[16164] | 35 | CheckTranscriptStatus, |
---|
[16504] | 36 | AdditionalFile,) |
---|
[14147] | 37 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
[11782] | 38 | from waeup.kofa.applicants.interfaces import ( |
---|
| 39 | ISpecialApplicant, IApplicantsUtils) |
---|
[13558] | 40 | from waeup.kofa.browser.interfaces import IPDFCreator |
---|
[10378] | 41 | from kofacustom.nigeria.applicants.browser import ( |
---|
| 42 | NigeriaApplicantDisplayFormPage, |
---|
[11736] | 43 | NigeriaApplicantManageFormPage, |
---|
[13796] | 44 | NigeriaApplicantEditFormPage, |
---|
[16504] | 45 | NigeriaPDFApplicationSlip, |
---|
| 46 | NigeriaExportPDFPaymentSlipPage) |
---|
[11782] | 47 | from waeup.uniben.applicants.interfaces import ( |
---|
[14105] | 48 | ICustomApplicant, |
---|
| 49 | IUnibenRegistration, |
---|
| 50 | ICustomUGApplicant, |
---|
| 51 | ICustomPGApplicant, |
---|
| 52 | ICustomPGApplicantEdit, |
---|
| 53 | ICustomUGApplicantEdit, |
---|
[16078] | 54 | IPUTMEApplicantEdit, |
---|
[16804] | 55 | ITranscriptApplicant, |
---|
| 56 | IFrenchApplicant) |
---|
[13825] | 57 | from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED |
---|
[14105] | 58 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
[17537] | 59 | OMIT_DISPLAY_FIELDS, |
---|
[17538] | 60 | UG_OMIT_DISPLAY_FIELDS, |
---|
| 61 | UG_OMIT_PDF_FIELDS, |
---|
| 62 | UG_OMIT_MANAGE_FIELDS, |
---|
| 63 | UG_OMIT_EDIT_FIELDS, |
---|
[14105] | 64 | CBT_OMIT_DISPLAY_FIELDS, |
---|
| 65 | CBT_OMIT_PDF_FIELDS, |
---|
| 66 | CBT_OMIT_MANAGE_FIELDS, |
---|
| 67 | CBT_OMIT_EDIT_FIELDS, |
---|
| 68 | AFFIL_OMIT_DISPLAY_FIELDS, |
---|
| 69 | AFFIL_OMIT_PDF_FIELDS, |
---|
| 70 | AFFIL_OMIT_MANAGE_FIELDS, |
---|
| 71 | AFFIL_OMIT_EDIT_FIELDS, |
---|
| 72 | PG_OMIT_DISPLAY_FIELDS, |
---|
| 73 | PG_OMIT_PDF_FIELDS, |
---|
| 74 | PG_OMIT_MANAGE_FIELDS, |
---|
| 75 | PG_OMIT_EDIT_FIELDS, |
---|
| 76 | PUTME_OMIT_DISPLAY_FIELDS, |
---|
[17538] | 77 | PUTME_OMIT_PDF_FIELDS, |
---|
| 78 | PUTME_OMIT_MANAGE_FIELDS, |
---|
| 79 | PUTME_OMIT_EDIT_FIELDS, |
---|
| 80 | PUTME_OMIT_RESULT_SLIP_FIELDS, |
---|
[14105] | 81 | PUDE_OMIT_DISPLAY_FIELDS, |
---|
| 82 | PUDE_OMIT_PDF_FIELDS, |
---|
| 83 | PUDE_OMIT_MANAGE_FIELDS, |
---|
| 84 | PUDE_OMIT_EDIT_FIELDS, |
---|
| 85 | PUDE_OMIT_RESULT_SLIP_FIELDS, |
---|
| 86 | PRE_OMIT_DISPLAY_FIELDS, |
---|
| 87 | PRE_OMIT_PDF_FIELDS, |
---|
| 88 | PRE_OMIT_MANAGE_FIELDS, |
---|
| 89 | PRE_OMIT_EDIT_FIELDS, |
---|
| 90 | ) |
---|
[8012] | 91 | |
---|
[10378] | 92 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
| 93 | |
---|
[14839] | 94 | PASTQ_ALL = ['ADT','CIT','DEF','DEM','EPCS','ESM','HEK','HSE','VTE'] |
---|
[8012] | 95 | |
---|
[14839] | 96 | PASTQ_AL = ['ENL','FAA','FOL','HIS','LAL', 'PHL','THR','BUL','JIL', |
---|
| 97 | 'LAW','PPL','PUL'] + PASTQ_ALL |
---|
[10338] | 98 | |
---|
| 99 | PASTQ_BS = ['ANT','ANY','CHH','COH','HAE','MED','MEH','PHS','SUR', |
---|
| 100 | 'PCG','PCH','PCO', 'PCT','PHA','PHM','PMB','ANA','MBC', |
---|
| 101 | 'MLS','NSC','PSY','DPV','ODR','OSP','PER', 'RES','AEB', |
---|
| 102 | 'BCH','BOT','CED','EVL','MCB','OPT','PBB','SLT','ZOO', |
---|
| 103 | 'AEE','ANS', 'CRS','FIS','FOW','SOS'] + PASTQ_ALL |
---|
| 104 | |
---|
[14839] | 105 | PASTQ_EPS = ['ARC','CHE','CVE','DMIC','EEE','GEM','MCH','PEE','PRE','CHM', |
---|
[14850] | 106 | 'CSC','GLY','MTH','QSV','PHY','CPE','STR'] + PASTQ_ALL |
---|
[10338] | 107 | |
---|
[14848] | 108 | PASTQ_MSS = ['ACC','BNK','BUS','ECO','ESM','GEO','POL','SAA','SWK', |
---|
| 109 | 'ACT','ENT','HRM','INS','MKT'] + PASTQ_ALL |
---|
[10338] | 110 | |
---|
[17538] | 111 | PT_OMIT_FIELDS = ( |
---|
[17537] | 112 | 'student_id', |
---|
| 113 | 'notice', |
---|
| 114 | 'screening_score', |
---|
| 115 | 'screening_venue', |
---|
| 116 | 'screening_date', |
---|
| 117 | 'jamb_age', |
---|
| 118 | 'jamb_subjects', |
---|
| 119 | 'jamb_score', |
---|
[17538] | 120 | #'jamb_reg_number', |
---|
| 121 | 'aggregate', |
---|
[17537] | 122 | 'hq_type', 'hq_matric_no', |
---|
| 123 | 'hq_degree', 'hq_school', |
---|
| 124 | 'hq_session', 'hq_disc', |
---|
| 125 | 'jamb_subjects_list', 'programme_type') |
---|
| 126 | |
---|
[17538] | 127 | PT_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PT_OMIT_FIELDS |
---|
[17537] | 128 | |
---|
[17538] | 129 | PT_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PT_OMIT_FIELDS |
---|
[17537] | 130 | |
---|
[17538] | 131 | PT_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + PT_OMIT_FIELDS |
---|
[17537] | 132 | |
---|
[17538] | 133 | PT_OMIT_PDF_FIELDS = PT_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
| 134 | PT_OMIT_RESULT_SLIP_FIELDS = PT_OMIT_DISPLAY_FIELDS + ( |
---|
[17537] | 135 | 'phone', |
---|
| 136 | 'date_of_birth', 'sex', |
---|
| 137 | 'nationality', 'lga', #'perm_address', |
---|
| 138 | 'course2', 'screening_venue', |
---|
| 139 | 'screening_date') |
---|
| 140 | |
---|
| 141 | |
---|
[13814] | 142 | REGISTRATION_OMIT_DISPLAY_FIELDS = ( |
---|
| 143 | 'locked', |
---|
| 144 | 'suspended', |
---|
[16945] | 145 | 'course_admitted', |
---|
[13796] | 146 | ) |
---|
| 147 | |
---|
[13814] | 148 | REGISTRATION_OMIT_EDIT_FIELDS = ( |
---|
| 149 | 'locked', |
---|
| 150 | 'suspended', |
---|
| 151 | 'applicant_id', |
---|
[16945] | 152 | 'course_admitted', |
---|
[13814] | 153 | ) |
---|
| 154 | |
---|
| 155 | REGISTRATION_OMIT_MANAGE_FIELDS = ( |
---|
| 156 | 'applicant_id', |
---|
| 157 | ) |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | REGISTRATION_OMIT_PDF_FIELDS = ( |
---|
| 161 | 'locked', |
---|
| 162 | 'suspended', |
---|
[16945] | 163 | 'course_admitted', |
---|
[13814] | 164 | ) |
---|
[14848] | 165 | |
---|
| 166 | PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_PDF_FIELDS + ( |
---|
| 167 | 'fst_sit_results', 'scd_sit_results') |
---|
| 168 | |
---|
[16227] | 169 | TRANS_OMIT_FIELDS = ('suspended',) |
---|
[16131] | 170 | |
---|
[16331] | 171 | #TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS + ( |
---|
| 172 | # 'date_of_birth', |
---|
| 173 | # 'sex', |
---|
| 174 | # #'nationality', |
---|
| 175 | # 'entry_mode', |
---|
| 176 | # 'entry_session', |
---|
| 177 | # 'end_session', |
---|
| 178 | # 'course_studied', |
---|
| 179 | # 'course_changed', |
---|
| 180 | # #'change_level', |
---|
| 181 | # ) |
---|
[16131] | 182 | |
---|
[16331] | 183 | TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS |
---|
| 184 | |
---|
[16227] | 185 | TRANS_OMIT_EDIT_FIELDS = TRANS_OMIT_FIELDS + ('applicant_id', ) |
---|
| 186 | |
---|
| 187 | TRANS_SHORT_OMIT_EDIT_FIELDS = TRANS_SHORT_OMIT_FIELDS + ('applicant_id', ) |
---|
| 188 | |
---|
| 189 | TRANS_OMIT_PDF_FIELDS = TRANS_OMIT_FIELDS + ('locked', ) |
---|
| 190 | |
---|
| 191 | TRANS_SHORT_OMIT_PDF_FIELDS = TRANS_SHORT_OMIT_FIELDS + ('locked', ) |
---|
| 192 | |
---|
[10587] | 193 | class CustomApplicantsContainerPage(ApplicantsContainerPage): |
---|
| 194 | """The standard view for regular applicant containers. |
---|
| 195 | """ |
---|
| 196 | |
---|
| 197 | @property |
---|
| 198 | def form_fields(self): |
---|
| 199 | form_fields = super(CustomApplicantsContainerPage, self).form_fields |
---|
[10589] | 200 | usertype = getattr(self.request.principal, 'user_type', None) |
---|
| 201 | if self.request.principal.id == 'zope.anybody' or \ |
---|
| 202 | usertype in ('applicant', 'student'): |
---|
[10587] | 203 | return form_fields.omit('application_fee') |
---|
| 204 | return form_fields |
---|
| 205 | |
---|
[8630] | 206 | class CustomApplicantRegistrationPage(ApplicantRegistrationPage): |
---|
| 207 | """Captcha'd registration page for applicants. |
---|
| 208 | """ |
---|
| 209 | |
---|
[10337] | 210 | def _redirect(self, email, password, applicant_id): |
---|
| 211 | # Forward email and credentials to landing page. |
---|
| 212 | self.redirect(self.url(self.context, 'registration_complete', |
---|
| 213 | data = dict(email=email, password=password, |
---|
| 214 | applicant_id=applicant_id))) |
---|
| 215 | return |
---|
[10287] | 216 | |
---|
[16175] | 217 | @property |
---|
| 218 | def label(self): |
---|
| 219 | if self.context.prefix.startswith('tsc'): |
---|
| 220 | return _('Request for ${a}', |
---|
| 221 | mapping = {'a':self.context.title}) |
---|
| 222 | return _('Apply for ${a}', |
---|
| 223 | mapping = {'a':self.context.title}) |
---|
| 224 | |
---|
[10375] | 225 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
| 226 | """A display view for applicant data. |
---|
[10287] | 227 | """ |
---|
[10375] | 228 | grok.template('applicantdisplaypage') |
---|
[10338] | 229 | |
---|
[13887] | 230 | @property |
---|
| 231 | def display_payments(self): |
---|
| 232 | if self.context.special or self.target == 'ictwk': |
---|
| 233 | return True |
---|
| 234 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
| 235 | |
---|
[10622] | 236 | def _show_pastq_putme(self): |
---|
[15487] | 237 | return self.target.startswith('pre') \ |
---|
[14821] | 238 | and self.context.state in ('paid', 'submitted') \ |
---|
| 239 | and getattr(self.context, 'course1') is not None |
---|
| 240 | # return False |
---|
[10338] | 241 | |
---|
| 242 | @property |
---|
[14090] | 243 | def depcode(self): |
---|
| 244 | try: |
---|
| 245 | code = self.context.course1.__parent__.__parent__.code |
---|
| 246 | return code |
---|
| 247 | except: |
---|
| 248 | return |
---|
| 249 | |
---|
| 250 | @property |
---|
[10338] | 251 | def show_pastq_al(self): |
---|
[15486] | 252 | return self._show_pastq_putme() # and self.depcode in PASTQ_AL |
---|
[10338] | 253 | |
---|
| 254 | @property |
---|
| 255 | def show_pastq_bs(self): |
---|
[15486] | 256 | return self._show_pastq_putme() # and self.depcode in PASTQ_BS |
---|
[10338] | 257 | |
---|
| 258 | @property |
---|
| 259 | def show_pastq_eps(self): |
---|
[15486] | 260 | return self._show_pastq_putme() # and self.depcode in PASTQ_EPS |
---|
[10338] | 261 | |
---|
| 262 | @property |
---|
| 263 | def show_pastq_mss(self): |
---|
[15486] | 264 | return self._show_pastq_putme() # and self.depcode in PASTQ_MSS |
---|
[10338] | 265 | |
---|
[10622] | 266 | @property |
---|
| 267 | def show_pastq_pude(self): |
---|
| 268 | return self.target.startswith('pude') \ |
---|
| 269 | and self.context.state in ('paid', 'submitted') |
---|
| 270 | |
---|
[13814] | 271 | @property |
---|
| 272 | def label(self): |
---|
| 273 | if self.target == 'ictwk': |
---|
| 274 | container_title = self.context.__parent__.title |
---|
| 275 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
| 276 | 'a':container_title, 'b':self.context.application_number}) |
---|
| 277 | return super(CustomApplicantDisplayFormPage, self).label |
---|
[11784] | 278 | |
---|
[11782] | 279 | @property |
---|
| 280 | def form_fields(self): |
---|
[16164] | 281 | if self.target is not None and self.target == 'tscf': |
---|
[16131] | 282 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 283 | for field in TRANS_OMIT_FIELDS: |
---|
| 284 | form_fields = form_fields.omit(field) |
---|
[16078] | 285 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
[16151] | 286 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
[16078] | 287 | return form_fields |
---|
[16164] | 288 | if self.target is not None and self.target == 'tscs': |
---|
[16131] | 289 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 290 | for field in TRANS_SHORT_OMIT_FIELDS: |
---|
| 291 | form_fields = form_fields.omit(field) |
---|
| 292 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
[16151] | 293 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
[16131] | 294 | return form_fields |
---|
[16807] | 295 | if self.target is not None and self.target == 'flc': |
---|
[16804] | 296 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
| 297 | for field in REGISTRATION_OMIT_DISPLAY_FIELDS: |
---|
| 298 | form_fields = form_fields.omit(field) |
---|
| 299 | return form_fields |
---|
[13796] | 300 | if self.target == 'ictwk': |
---|
[13814] | 301 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 302 | for field in REGISTRATION_OMIT_DISPLAY_FIELDS: |
---|
[13796] | 303 | form_fields = form_fields.omit(field) |
---|
| 304 | return form_fields |
---|
[14105] | 305 | elif self.target is not None and self.target.startswith('pg'): |
---|
| 306 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 307 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
| 308 | form_fields = form_fields.omit(field) |
---|
| 309 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 310 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 311 | for field in PRE_OMIT_DISPLAY_FIELDS: |
---|
| 312 | form_fields = form_fields.omit(field) |
---|
| 313 | elif self.target is not None and self.target.startswith('cbt'): |
---|
| 314 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 315 | for field in CBT_OMIT_DISPLAY_FIELDS: |
---|
| 316 | form_fields = form_fields.omit(field) |
---|
| 317 | elif self.target is not None and self.target.startswith('akj'): |
---|
| 318 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 319 | for field in PRE_OMIT_DISPLAY_FIELDS: |
---|
| 320 | form_fields = form_fields.omit(field) |
---|
| 321 | elif self.target is not None and self.target.startswith('ak'): |
---|
| 322 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 323 | for field in AFFIL_OMIT_DISPLAY_FIELDS: |
---|
| 324 | form_fields = form_fields.omit(field) |
---|
| 325 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 326 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 327 | for field in PUTME_OMIT_DISPLAY_FIELDS: |
---|
| 328 | form_fields = form_fields.omit(field) |
---|
[17538] | 329 | elif self.target is not None and self.target.startswith('pt'): |
---|
| 330 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 331 | for field in PT_OMIT_DISPLAY_FIELDS: |
---|
| 332 | form_fields = form_fields.omit(field) |
---|
[14105] | 333 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 334 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 335 | for field in PUDE_OMIT_DISPLAY_FIELDS: |
---|
| 336 | form_fields = form_fields.omit(field) |
---|
| 337 | else: |
---|
| 338 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 339 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
| 340 | form_fields = form_fields.omit(field) |
---|
| 341 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
[17538] | 342 | try: |
---|
| 343 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
| 344 | except: |
---|
| 345 | pass |
---|
[14105] | 346 | if not getattr(self.context, 'student_id'): |
---|
| 347 | form_fields = form_fields.omit('student_id') |
---|
| 348 | if not getattr(self.context, 'screening_score'): |
---|
| 349 | form_fields = form_fields.omit('screening_score') |
---|
| 350 | if not getattr(self.context, 'screening_venue') or self._not_paid(): |
---|
| 351 | form_fields = form_fields.omit('screening_venue') |
---|
| 352 | if not getattr(self.context, 'screening_date') or self._not_paid(): |
---|
| 353 | form_fields = form_fields.omit('screening_date') |
---|
[11784] | 354 | if not self.context.admchecking_fee_paid(): |
---|
| 355 | form_fields = form_fields.omit( |
---|
| 356 | 'screening_score', 'aggregate', 'student_id') |
---|
[11782] | 357 | return form_fields |
---|
| 358 | |
---|
[11784] | 359 | @property |
---|
| 360 | def display_actions(self): |
---|
| 361 | state = IWorkflowState(self.context).getState() |
---|
| 362 | actions = [] |
---|
| 363 | if state == ADMITTED and not self.context.admchecking_fee_paid(): |
---|
| 364 | actions = [_('Add admission checking payment ticket')] |
---|
| 365 | return actions |
---|
| 366 | |
---|
| 367 | |
---|
| 368 | def getCourseAdmitted(self): |
---|
| 369 | """Return link, title and code in html format to the certificate |
---|
| 370 | admitted. |
---|
| 371 | """ |
---|
[15125] | 372 | if self.admission_checking_info: |
---|
| 373 | return '<span class="hint">%s</span>' % self.admission_checking_info |
---|
| 374 | return super(CustomApplicantDisplayFormPage, self).getCourseAdmitted() |
---|
[11784] | 375 | |
---|
[11786] | 376 | @property |
---|
| 377 | def admission_checking_info(self): |
---|
| 378 | if self.context.state == ADMITTED and \ |
---|
| 379 | not self.context.admchecking_fee_paid(): |
---|
| 380 | return _('You must pay the admission checking fee ' |
---|
[15125] | 381 | 'to view your screening results and your course admitted.') |
---|
[11786] | 382 | return |
---|
| 383 | |
---|
[11784] | 384 | @action(_('Add admission checking payment ticket'), style='primary') |
---|
| 385 | def addPaymentTicket(self, **data): |
---|
| 386 | self.redirect(self.url(self.context, '@@addacp')) |
---|
| 387 | return |
---|
| 388 | |
---|
[11728] | 389 | class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage): |
---|
| 390 | """ Page to add an online payment ticket |
---|
| 391 | """ |
---|
[10378] | 392 | |
---|
[11728] | 393 | @property |
---|
| 394 | def custom_requirements(self): |
---|
[15506] | 395 | if self.context.__parent__.with_picture: |
---|
| 396 | store = getUtility(IExtFileStore) |
---|
[16211] | 397 | if self.context.__parent__.picture_editable \ |
---|
| 398 | and not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
[15506] | 399 | return _('Upload your 1"x1" Red background passport photo before making payment.') |
---|
[11728] | 400 | return '' |
---|
| 401 | |
---|
[11784] | 402 | class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View): |
---|
| 403 | """ Page to add an admission checking online payment ticket. |
---|
| 404 | """ |
---|
| 405 | grok.context(ICustomApplicant) |
---|
| 406 | grok.name('addacp') |
---|
| 407 | grok.require('waeup.payApplicant') |
---|
| 408 | factory = u'waeup.ApplicantOnlinePayment' |
---|
| 409 | |
---|
| 410 | def _setPaymentDetails(self, payment): |
---|
| 411 | container = self.context.__parent__ |
---|
| 412 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
| 413 | session = str(container.year) |
---|
| 414 | try: |
---|
| 415 | session_config = grok.getSite()['configuration'][session] |
---|
| 416 | except KeyError: |
---|
| 417 | return _(u'Session configuration object is not available.'), None |
---|
| 418 | payment.p_id = "p%s" % timestamp |
---|
| 419 | payment.p_item = container.title |
---|
| 420 | payment.p_session = container.year |
---|
| 421 | payment.amount_auth = 0.0 |
---|
| 422 | payment.p_category = 'admission_checking' |
---|
| 423 | payment.amount_auth = session_config.admchecking_fee |
---|
| 424 | if payment.amount_auth in (0.0, None): |
---|
| 425 | return _('Amount could not be determined.'), None |
---|
| 426 | return |
---|
| 427 | |
---|
[11782] | 428 | def update(self): |
---|
[11784] | 429 | if self.context.admchecking_fee_paid(): |
---|
| 430 | self.flash( |
---|
| 431 | _('Admission checking payment has already been made.'), |
---|
| 432 | type='warning') |
---|
| 433 | self.redirect(self.url(self.context)) |
---|
| 434 | return |
---|
[11782] | 435 | payment = createObject(self.factory) |
---|
[11784] | 436 | failure = self._setPaymentDetails(payment) |
---|
[11782] | 437 | if failure is not None: |
---|
| 438 | self.flash(failure[0], type='danger') |
---|
| 439 | self.redirect(self.url(self.context)) |
---|
| 440 | return |
---|
| 441 | self.context[payment.p_id] = payment |
---|
| 442 | self.flash(_('Payment ticket created.')) |
---|
| 443 | self.redirect(self.url(payment)) |
---|
| 444 | return |
---|
[11736] | 445 | |
---|
[11784] | 446 | def render(self): |
---|
| 447 | return |
---|
[11736] | 448 | |
---|
[11784] | 449 | |
---|
[11782] | 450 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
| 451 | |
---|
[11736] | 452 | @property |
---|
[13887] | 453 | def display_payments(self): |
---|
| 454 | if self.context.special or self.target == 'ictwk': |
---|
| 455 | return True |
---|
| 456 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
| 457 | |
---|
| 458 | @property |
---|
[11736] | 459 | def custom_upload_requirements(self): |
---|
| 460 | if not checkPermission('waeup.uploadPassportPictures', self.context): |
---|
| 461 | return _('You are not entitled to upload passport pictures.') |
---|
[11782] | 462 | |
---|
[16683] | 463 | def display_fileupload(self, filename): |
---|
| 464 | if filename[1] == 'res_stat' \ |
---|
| 465 | and self.target is not None \ |
---|
| 466 | and not self.target.startswith('tsc'): |
---|
| 467 | return False |
---|
| 468 | if filename[1] == 'eligibility' \ |
---|
| 469 | and self.target is not None \ |
---|
| 470 | and not self.target.startswith('tsc'): |
---|
| 471 | return False |
---|
| 472 | return True |
---|
| 473 | |
---|
[13796] | 474 | @property |
---|
[13814] | 475 | def label(self): |
---|
| 476 | if self.target == 'ictwk': |
---|
| 477 | container_title = self.context.__parent__.title |
---|
| 478 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
| 479 | 'a':container_title, 'b':self.context.application_number}) |
---|
| 480 | return super(CustomApplicantManageFormPage, self).label |
---|
| 481 | |
---|
| 482 | @property |
---|
[13796] | 483 | def form_fields(self): |
---|
[16164] | 484 | if self.target is not None and self.target == 'tscf': |
---|
[16078] | 485 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16227] | 486 | for field in TRANS_OMIT_EDIT_FIELDS: |
---|
[16131] | 487 | form_fields = form_fields.omit(field) |
---|
[16078] | 488 | return form_fields |
---|
[16164] | 489 | if self.target is not None and self.target == 'tscs': |
---|
[16131] | 490 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16227] | 491 | for field in TRANS_SHORT_OMIT_EDIT_FIELDS: |
---|
[16131] | 492 | form_fields = form_fields.omit(field) |
---|
| 493 | return form_fields |
---|
[13796] | 494 | if self.target == 'ictwk': |
---|
[13814] | 495 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 496 | for field in REGISTRATION_OMIT_MANAGE_FIELDS: |
---|
[13796] | 497 | form_fields = form_fields.omit(field) |
---|
[13825] | 498 | state = IWorkflowState(self.context).getState() |
---|
| 499 | if state != STARTED: |
---|
| 500 | form_fields['registration_cats'].for_display = True |
---|
[13814] | 501 | return form_fields |
---|
[16807] | 502 | if self.target is not None and self.target == 'flc': |
---|
[16804] | 503 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
| 504 | for field in REGISTRATION_OMIT_MANAGE_FIELDS: |
---|
| 505 | form_fields = form_fields.omit(field) |
---|
| 506 | return form_fields |
---|
[14105] | 507 | if self.target is not None and self.target.startswith('pg'): |
---|
| 508 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 509 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
| 510 | form_fields = form_fields.omit(field) |
---|
| 511 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 512 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 513 | for field in PRE_OMIT_MANAGE_FIELDS: |
---|
| 514 | form_fields = form_fields.omit(field) |
---|
| 515 | elif self.target is not None and self.target.startswith('cbt'): |
---|
| 516 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 517 | for field in CBT_OMIT_MANAGE_FIELDS: |
---|
| 518 | form_fields = form_fields.omit(field) |
---|
| 519 | elif self.target is not None and self.target.startswith('akj'): |
---|
| 520 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 521 | for field in PRE_OMIT_MANAGE_FIELDS: |
---|
| 522 | form_fields = form_fields.omit(field) |
---|
| 523 | elif self.target is not None and self.target.startswith('ak'): |
---|
| 524 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 525 | for field in AFFIL_OMIT_MANAGE_FIELDS: |
---|
| 526 | form_fields = form_fields.omit(field) |
---|
| 527 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 528 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 529 | for field in PUTME_OMIT_MANAGE_FIELDS: |
---|
| 530 | form_fields = form_fields.omit(field) |
---|
[17538] | 531 | elif self.target is not None and self.target.startswith('pt'): |
---|
| 532 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 533 | for field in PT_OMIT_MANAGE_FIELDS: |
---|
| 534 | form_fields = form_fields.omit(field) |
---|
[14105] | 535 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 536 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 537 | for field in PUDE_OMIT_MANAGE_FIELDS: |
---|
| 538 | form_fields = form_fields.omit(field) |
---|
| 539 | else: |
---|
| 540 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 541 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
| 542 | form_fields = form_fields.omit(field) |
---|
[17538] | 543 | try: |
---|
| 544 | form_fields['student_id'].for_display = True |
---|
| 545 | except: |
---|
| 546 | pass |
---|
| 547 | try: |
---|
| 548 | form_fields['applicant_id'].for_display = True |
---|
| 549 | except: |
---|
| 550 | pass |
---|
[13796] | 551 | return form_fields |
---|
| 552 | |
---|
| 553 | |
---|
| 554 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
| 555 | """An applicant-centered edit view for applicant data. |
---|
| 556 | """ |
---|
| 557 | |
---|
[14841] | 558 | def unremovable(self, ticket): |
---|
| 559 | return True |
---|
| 560 | |
---|
[13796] | 561 | @property |
---|
[13887] | 562 | def display_payments(self): |
---|
| 563 | if self.context.special or self.target == 'ictwk': |
---|
| 564 | return True |
---|
| 565 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
| 566 | |
---|
| 567 | @property |
---|
[13796] | 568 | def form_fields(self): |
---|
[16766] | 569 | state = IWorkflowState(self.context).getState() |
---|
[16164] | 570 | if self.target is not None and self.target == 'tscf': |
---|
[16131] | 571 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16471] | 572 | form_fields['courier_tno'].for_display = True |
---|
| 573 | form_fields['proc_date'].for_display = True |
---|
[16227] | 574 | for field in TRANS_OMIT_EDIT_FIELDS: |
---|
[16131] | 575 | form_fields = form_fields.omit(field) |
---|
[16766] | 576 | if state == PAID: |
---|
| 577 | form_fields['order'].for_display = True |
---|
[16804] | 578 | form_fields = form_fields.omit('locked') |
---|
[16078] | 579 | return form_fields |
---|
[16164] | 580 | if self.target is not None and self.target == 'tscs': |
---|
[16131] | 581 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16471] | 582 | form_fields['courier_tno'].for_display = True |
---|
| 583 | form_fields['proc_date'].for_display = True |
---|
[16227] | 584 | for field in TRANS_SHORT_OMIT_EDIT_FIELDS: |
---|
[16131] | 585 | form_fields = form_fields.omit(field) |
---|
[16804] | 586 | form_fields = form_fields.omit('locked') |
---|
[16766] | 587 | if state == PAID: |
---|
| 588 | form_fields['order'].for_display = True |
---|
[16131] | 589 | return form_fields |
---|
[13796] | 590 | if self.target == 'ictwk': |
---|
[13814] | 591 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 592 | for field in REGISTRATION_OMIT_EDIT_FIELDS: |
---|
[13796] | 593 | form_fields = form_fields.omit(field) |
---|
[13825] | 594 | if state != STARTED: |
---|
| 595 | form_fields['registration_cats'].for_display = True |
---|
[13814] | 596 | return form_fields |
---|
[16807] | 597 | if self.target is not None and self.target == 'flc': |
---|
[16804] | 598 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
| 599 | for field in REGISTRATION_OMIT_EDIT_FIELDS: |
---|
| 600 | form_fields = form_fields.omit(field) |
---|
| 601 | return form_fields |
---|
[14105] | 602 | if self.target is not None and self.target.startswith('pg'): |
---|
| 603 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
| 604 | for field in PG_OMIT_EDIT_FIELDS: |
---|
| 605 | form_fields = form_fields.omit(field) |
---|
| 606 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 607 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
| 608 | for field in PRE_OMIT_EDIT_FIELDS: |
---|
| 609 | form_fields = form_fields.omit(field) |
---|
| 610 | elif self.target is not None and self.target.startswith('cbt'): |
---|
| 611 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 612 | for field in CBT_OMIT_EDIT_FIELDS: |
---|
| 613 | form_fields = form_fields.omit(field) |
---|
| 614 | elif self.target is not None and self.target.startswith('akj'): |
---|
| 615 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 616 | for field in PRE_OMIT_EDIT_FIELDS: |
---|
| 617 | form_fields = form_fields.omit(field) |
---|
| 618 | elif self.target is not None and self.target.startswith('ak'): |
---|
| 619 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 620 | for field in AFFIL_OMIT_EDIT_FIELDS: |
---|
| 621 | form_fields = form_fields.omit(field) |
---|
| 622 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 623 | form_fields = grok.AutoFields(IPUTMEApplicantEdit) |
---|
| 624 | for field in PUTME_OMIT_EDIT_FIELDS: |
---|
| 625 | form_fields = form_fields.omit(field) |
---|
[17538] | 626 | elif self.target is not None and self.target.startswith('pt'): |
---|
| 627 | form_fields = grok.AutoFields(IPUTMEApplicantEdit) |
---|
| 628 | for field in PT_OMIT_EDIT_FIELDS: |
---|
| 629 | form_fields = form_fields.omit(field) |
---|
[14105] | 630 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 631 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 632 | for field in PUDE_OMIT_EDIT_FIELDS: |
---|
| 633 | form_fields = form_fields.omit(field) |
---|
| 634 | else: |
---|
| 635 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 636 | for field in UG_OMIT_EDIT_FIELDS: |
---|
| 637 | form_fields = form_fields.omit(field) |
---|
| 638 | form_fields['applicant_id'].for_display = True |
---|
| 639 | form_fields['reg_number'].for_display = True |
---|
[13796] | 640 | return form_fields |
---|
| 641 | |
---|
[13814] | 642 | @property |
---|
| 643 | def label(self): |
---|
| 644 | if self.target == 'ictwk': |
---|
| 645 | container_title = self.context.__parent__.title |
---|
| 646 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
| 647 | 'a':container_title, 'b':self.context.application_number}) |
---|
| 648 | return super(CustomApplicantEditFormPage, self).label |
---|
| 649 | |
---|
[16164] | 650 | def display_fileupload(self, filename): |
---|
[16683] | 651 | if filename[1] == 'res_stat' \ |
---|
[16164] | 652 | and self.target is not None \ |
---|
[16332] | 653 | and not self.target.startswith('tsc'): |
---|
[16164] | 654 | return False |
---|
[16683] | 655 | if filename[1] == 'eligibility' \ |
---|
[16164] | 656 | and self.target is not None \ |
---|
| 657 | and not self.target.startswith('tsc'): |
---|
| 658 | return False |
---|
| 659 | return True |
---|
| 660 | |
---|
| 661 | def dataNotComplete(self, data): |
---|
| 662 | store = getUtility(IExtFileStore) |
---|
[16199] | 663 | if self.context.__parent__.with_picture \ |
---|
| 664 | and self.context.__parent__.picture_editable: |
---|
[16164] | 665 | store = getUtility(IExtFileStore) |
---|
| 666 | if not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
| 667 | return _('No passport picture uploaded.') |
---|
| 668 | if self.target is not None \ |
---|
| 669 | and self.target.startswith('tscf') \ |
---|
| 670 | and not store.getFileByContext(self.context, attr=u'res_stat.pdf'): |
---|
| 671 | return _('No statement of result pdf file uploaded.') |
---|
[17084] | 672 | if self.target is not None \ |
---|
| 673 | and self.target.startswith('tsc') \ |
---|
| 674 | and (not self.context.order or not self.context.charge): |
---|
| 675 | return _('Please select Type of Order and Transcript Charge.') |
---|
[17532] | 676 | if self.target is not None \ |
---|
| 677 | and self.target.startswith('pt') \ |
---|
| 678 | and not self.context.jamb_reg_number: |
---|
| 679 | return _('Please enter your JAMB Registration Number.') |
---|
[16164] | 680 | return False |
---|
| 681 | |
---|
[11782] | 682 | class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage): |
---|
| 683 | """ Approval view |
---|
| 684 | """ |
---|
| 685 | |
---|
| 686 | def update(self): |
---|
[11784] | 687 | if self.context.p_category == 'admission_checking': |
---|
| 688 | if self.context.p_state == 'paid': |
---|
| 689 | flashtype = 'warning' |
---|
| 690 | msg = _('This ticket has already been paid.') |
---|
| 691 | log = None |
---|
| 692 | else: |
---|
| 693 | self.context.approve() |
---|
| 694 | log = 'payment approved: %s' % self.context.p_id |
---|
| 695 | msg = _('Payment approved') |
---|
| 696 | flashtype = 'success' |
---|
| 697 | else: |
---|
| 698 | flashtype, msg, log = self.context.approveApplicantPayment() |
---|
[11782] | 699 | if log is not None: |
---|
| 700 | applicant = self.context.__parent__ |
---|
| 701 | # Add log message to applicants.log |
---|
| 702 | applicant.writeLogMessage(self, log) |
---|
| 703 | # Add log message to payments.log |
---|
| 704 | self.context.logger.info( |
---|
| 705 | '%s,%s,%s,%s,%s,,,,,,' % ( |
---|
| 706 | applicant.applicant_id, |
---|
| 707 | self.context.p_id, self.context.p_category, |
---|
| 708 | self.context.amount_auth, self.context.r_code)) |
---|
| 709 | self.flash(msg, type=flashtype) |
---|
| 710 | return |
---|
[11784] | 711 | |
---|
| 712 | class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip): |
---|
| 713 | """Deliver a PDF slip of the context. |
---|
| 714 | """ |
---|
| 715 | |
---|
| 716 | def update(self): |
---|
| 717 | super(CustomExportPDFPageApplicationSlip, self).update() |
---|
| 718 | if self.context.state == ADMITTED and \ |
---|
| 719 | not self.context.admchecking_fee_paid(): |
---|
| 720 | self.flash( |
---|
| 721 | _('Please pay admission checking fee before trying to download ' |
---|
| 722 | 'the application slip.'), type='warning') |
---|
| 723 | return self.redirect(self.url(self.context)) |
---|
| 724 | return |
---|
[13552] | 725 | |
---|
[13557] | 726 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
[13552] | 727 | |
---|
[13558] | 728 | def _getPDFCreator(self): |
---|
[14061] | 729 | if self.target.startswith('ak'): |
---|
[13558] | 730 | return getUtility(IPDFCreator, name='akoka_pdfcreator') |
---|
| 731 | return getUtility(IPDFCreator) |
---|
| 732 | |
---|
[13552] | 733 | @property |
---|
[13814] | 734 | def form_fields(self): |
---|
[16184] | 735 | if self.target is not None and self.target == 'tscf': |
---|
| 736 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16227] | 737 | for field in TRANS_OMIT_PDF_FIELDS: |
---|
[16184] | 738 | form_fields = form_fields.omit(field) |
---|
| 739 | elif self.target is not None and self.target == 'tscs': |
---|
| 740 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16227] | 741 | for field in TRANS_SHORT_OMIT_PDF_FIELDS: |
---|
[16184] | 742 | form_fields = form_fields.omit(field) |
---|
| 743 | elif self.target is not None and self.target == 'ictwk': |
---|
[13814] | 744 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 745 | for field in REGISTRATION_OMIT_PDF_FIELDS: |
---|
| 746 | form_fields = form_fields.omit(field) |
---|
[16184] | 747 | elif self.target is not None and self.target.startswith('pg'): |
---|
[14105] | 748 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 749 | for field in PG_OMIT_PDF_FIELDS: |
---|
| 750 | form_fields = form_fields.omit(field) |
---|
| 751 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 752 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 753 | for field in PRE_OMIT_PDF_FIELDS: |
---|
| 754 | form_fields = form_fields.omit(field) |
---|
| 755 | elif self.target is not None and self.target.startswith('cbt'): # uniben |
---|
| 756 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 757 | for field in CBT_OMIT_PDF_FIELDS: |
---|
| 758 | form_fields = form_fields.omit(field) |
---|
| 759 | elif self.target is not None and self.target.startswith('akj'): # uniben |
---|
| 760 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 761 | for field in PRE_OMIT_PDF_FIELDS: |
---|
| 762 | form_fields = form_fields.omit(field) |
---|
| 763 | elif self.target is not None and self.target.startswith('ak'): # uniben |
---|
| 764 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 765 | for field in AFFIL_OMIT_PDF_FIELDS: |
---|
| 766 | form_fields = form_fields.omit(field) |
---|
| 767 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 768 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 769 | if self._reduced_slip(): |
---|
| 770 | for field in PUTME_OMIT_RESULT_SLIP_FIELDS: |
---|
| 771 | form_fields = form_fields.omit(field) |
---|
| 772 | else: |
---|
| 773 | for field in PUTME_OMIT_PDF_FIELDS: |
---|
| 774 | form_fields = form_fields.omit(field) |
---|
[17538] | 775 | elif self.target is not None and self.target.startswith('pt'): |
---|
| 776 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 777 | if self._reduced_slip(): |
---|
| 778 | for field in PT_OMIT_RESULT_SLIP_FIELDS: |
---|
| 779 | form_fields = form_fields.omit(field) |
---|
| 780 | else: |
---|
| 781 | for field in PT_OMIT_PDF_FIELDS: |
---|
| 782 | form_fields = form_fields.omit(field) |
---|
[14105] | 783 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 784 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 785 | if self._reduced_slip(): |
---|
| 786 | for field in PUDE_OMIT_RESULT_SLIP_FIELDS: |
---|
| 787 | form_fields = form_fields.omit(field) |
---|
| 788 | else: |
---|
| 789 | for field in PUDE_OMIT_PDF_FIELDS: |
---|
| 790 | form_fields = form_fields.omit(field) |
---|
[16807] | 791 | elif self.target is not None and self.target == 'flc': |
---|
[16804] | 792 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
| 793 | for field in REGISTRATION_OMIT_PDF_FIELDS: |
---|
| 794 | form_fields = form_fields.omit(field) |
---|
[14105] | 795 | else: |
---|
| 796 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 797 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 798 | form_fields = form_fields.omit(field) |
---|
| 799 | if not getattr(self.context, 'student_id'): |
---|
| 800 | form_fields = form_fields.omit('student_id') |
---|
| 801 | if not getattr(self.context, 'screening_score'): |
---|
| 802 | form_fields = form_fields.omit('screening_score') |
---|
| 803 | if not getattr(self.context, 'screening_venue'): |
---|
| 804 | form_fields = form_fields.omit('screening_venue') |
---|
| 805 | if not getattr(self.context, 'screening_date'): |
---|
| 806 | form_fields = form_fields.omit('screening_date') |
---|
[13814] | 807 | return form_fields |
---|
| 808 | |
---|
| 809 | @property |
---|
[13552] | 810 | def title(self): |
---|
| 811 | container_title = self.context.__parent__.title |
---|
| 812 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 813 | ar_translation = translate(_('Application Record'), |
---|
| 814 | 'waeup.kofa', target_language=portal_language) |
---|
[13814] | 815 | if self.target == 'ictwk': |
---|
| 816 | return '%s - Registration Record %s' % (container_title, |
---|
| 817 | self.context.application_number) |
---|
[14061] | 818 | elif self.target.startswith('ab'): |
---|
[13552] | 819 | return 'Federal College of Education (Technical) Asaba - %s %s %s' % ( |
---|
| 820 | container_title, ar_translation, |
---|
| 821 | self.context.application_number) |
---|
[14061] | 822 | elif self.target.startswith('ak'): |
---|
[14064] | 823 | return 'Federal College of Education (Technical) Akoka - %s - %s %s' % ( |
---|
[13552] | 824 | container_title, ar_translation, |
---|
| 825 | self.context.application_number) |
---|
[13615] | 826 | elif self.target == 'pgn': |
---|
| 827 | return 'National Institute for Legislative Studies (NILS) - %s %s %s' % ( |
---|
| 828 | container_title, ar_translation, |
---|
| 829 | self.context.application_number) |
---|
[13552] | 830 | return '%s - %s %s' % (container_title, |
---|
| 831 | ar_translation, self.context.application_number) |
---|
[14147] | 832 | |
---|
[16504] | 833 | class CustomApplicantBaseDisplayFormPage(ApplicantBaseDisplayFormPage): |
---|
| 834 | |
---|
| 835 | @property |
---|
| 836 | def form_fields(self): |
---|
| 837 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
| 838 | if target.startswith('tsc'): |
---|
| 839 | form_fields = grok.AutoFields(ICustomApplicant).select( |
---|
| 840 | 'applicant_id', 'email', 'dispatch_address') |
---|
| 841 | else: |
---|
| 842 | form_fields = grok.AutoFields(ICustomApplicant).select( |
---|
| 843 | 'applicant_id', 'reg_number', 'email', 'course1') |
---|
| 844 | if self.context.__parent__.prefix in ('special',): |
---|
| 845 | form_fields['reg_number'].field.title = u'Identification Number' |
---|
| 846 | return form_fields |
---|
| 847 | return form_fields |
---|
| 848 | |
---|
| 849 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
| 850 | """Deliver a PDF slip of the context. |
---|
| 851 | """ |
---|
| 852 | |
---|
| 853 | @property |
---|
| 854 | def omit_fields(self): |
---|
| 855 | target = getattr(self.context.__parent__.__parent__, 'prefix', None) |
---|
| 856 | if target.startswith('tsc'): |
---|
| 857 | return ('date_of_birth', 'course1') |
---|
[16684] | 858 | return () |
---|
[16504] | 859 | |
---|
| 860 | @property |
---|
| 861 | def note(self): |
---|
| 862 | return |
---|
| 863 | |
---|
| 864 | def render(self): |
---|
| 865 | if self.payment_slip_download_warning: |
---|
| 866 | self.flash(self.payment_slip_download_warning, type='danger') |
---|
| 867 | self.redirect(self.url(self.context)) |
---|
| 868 | return |
---|
| 869 | applicantview = CustomApplicantBaseDisplayFormPage(self.context.__parent__, |
---|
| 870 | self.request) |
---|
| 871 | students_utils = getUtility(IStudentsUtils) |
---|
| 872 | return students_utils.renderPDF(self,'payment_slip.pdf', |
---|
| 873 | self.context.__parent__, applicantview, |
---|
| 874 | note=self.note, omit_fields=self.omit_fields) |
---|
| 875 | |
---|
[14147] | 876 | class ExportScreeningInvitationSlip(UtilityView, grok.View): |
---|
| 877 | """Deliver a PDF slip of the context. |
---|
| 878 | """ |
---|
| 879 | grok.context(ICustomApplicant) |
---|
| 880 | grok.name('screening_invitation_slip.pdf') |
---|
| 881 | grok.require('waeup.viewApplication') |
---|
| 882 | form_fields = None |
---|
[14148] | 883 | label = u'Invitation Letter for Pre-Admission Screening' |
---|
[14147] | 884 | |
---|
| 885 | |
---|
| 886 | @property |
---|
| 887 | def note(self): |
---|
[16345] | 888 | notice = getattr(self.context.__parent__, 'application_slip_notice') |
---|
[16346] | 889 | if notice is None: |
---|
[16347] | 890 | notice = '' |
---|
[14147] | 891 | if self.context.screening_date: |
---|
| 892 | return """ |
---|
| 893 | <br /><br /><br /><br /><font size='12'> |
---|
| 894 | Dear %s, |
---|
| 895 | <br /><br /><br /> |
---|
| 896 | You are invited for your Uniben Admission Screening Exercise on: |
---|
| 897 | <br /><br /> |
---|
| 898 | <strong>%s</strong>. |
---|
| 899 | <br /><br /> |
---|
[14167] | 900 | Please bring along this letter of invitation to the |
---|
[14147] | 901 | <br /><br /> |
---|
[14167] | 902 | <strong>%s</strong> |
---|
| 903 | <br /><br /> |
---|
[14147] | 904 | on your screening date. |
---|
| 905 | <br /><br /><br /> |
---|
| 906 | Signed, |
---|
| 907 | <br /><br /> |
---|
| 908 | The Registrar<br /> |
---|
[14168] | 909 | <br /><br /> |
---|
| 910 | <br /><br /> |
---|
| 911 | %s |
---|
[14147] | 912 | </font> |
---|
| 913 | |
---|
[14167] | 914 | """ % (self.context.display_fullname, self.context.screening_date, |
---|
[14168] | 915 | self.context.screening_venue, notice) |
---|
[14147] | 916 | return |
---|
| 917 | |
---|
| 918 | def update(self): |
---|
| 919 | if not self.context.screening_date: |
---|
| 920 | self.flash(_('Forbidden'), type="warning") |
---|
| 921 | self.redirect(self.url(self.context)) |
---|
| 922 | |
---|
| 923 | def render(self): |
---|
| 924 | applicantview = ApplicantBaseDisplayFormPage(self.context, self.request) |
---|
| 925 | students_utils = getUtility(IStudentsUtils) |
---|
| 926 | return students_utils.renderPDF(self,'screening_invitation_slip.pdf', |
---|
[16117] | 927 | self.context, applicantview, note=self.note) |
---|
| 928 | |
---|
| 929 | class CustomCheckTranscriptStatus(CheckTranscriptStatus): |
---|
| 930 | """A display page for checking transcript processing status. |
---|
| 931 | """ |
---|
[16759] | 932 | grok.template('checktranscriptstatus') |
---|
| 933 | |
---|
[16588] | 934 | websites = (('Uniben Alumni Portal', 'https://alumni.uniben.edu/'), |
---|
[16582] | 935 | ('Uniben Student Portal', 'https://waeup.uniben.edu/'),) |
---|
[16588] | 936 | appl_url1 = 'https://alumni.uniben.edu/applicants/tscf1/register' |
---|
| 937 | appl_url2 = 'https://alumni.uniben.edu/applicants/tscs1/register' |
---|
[16164] | 938 | |
---|
[16229] | 939 | class CreateGraduatedPage(UtilityView, grok.View): |
---|
| 940 | """Create a student object from transcript application data. |
---|
| 941 | """ |
---|
| 942 | grok.context(ICustomApplicant) |
---|
| 943 | grok.name('creategraduated') |
---|
| 944 | grok.require('waeup.createStudents') |
---|
| 945 | |
---|
| 946 | def update(self): |
---|
| 947 | success, msg = self.context.createStudent(view=self, graduated=True) |
---|
| 948 | if success: |
---|
| 949 | self.flash(msg) |
---|
| 950 | else: |
---|
| 951 | self.flash(msg, type='warning') |
---|
| 952 | self.redirect(self.url(self.context)) |
---|
| 953 | return |
---|
| 954 | |
---|
| 955 | def render(self): |
---|
| 956 | return |
---|
| 957 | |
---|
[16164] | 958 | class ResultStatement(AdditionalFile): |
---|
[16547] | 959 | grok.name('res_stat') |
---|
[16164] | 960 | |
---|
| 961 | class EligibilityForm(AdditionalFile): |
---|
[16547] | 962 | grok.name('eligibility') |
---|