[8012] | 1 | ## $Id: browser.py 16164 2020-07-13 07:17:03Z 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, |
---|
| 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, |
---|
[10378] | 45 | NigeriaPDFApplicationSlip) |
---|
[11782] | 46 | from waeup.uniben.applicants.interfaces import ( |
---|
[14105] | 47 | ICustomApplicant, |
---|
| 48 | IUnibenRegistration, |
---|
| 49 | ICustomUGApplicant, |
---|
| 50 | ICustomPGApplicant, |
---|
| 51 | ICustomPGApplicantEdit, |
---|
| 52 | ICustomUGApplicantEdit, |
---|
[16078] | 53 | IPUTMEApplicantEdit, |
---|
| 54 | ITranscriptApplicant) |
---|
[13825] | 55 | from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED |
---|
[14105] | 56 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
| 57 | UG_OMIT_DISPLAY_FIELDS, |
---|
| 58 | UG_OMIT_PDF_FIELDS, |
---|
| 59 | UG_OMIT_MANAGE_FIELDS, |
---|
| 60 | UG_OMIT_EDIT_FIELDS, |
---|
| 61 | CBT_OMIT_DISPLAY_FIELDS, |
---|
| 62 | CBT_OMIT_PDF_FIELDS, |
---|
| 63 | CBT_OMIT_MANAGE_FIELDS, |
---|
| 64 | CBT_OMIT_EDIT_FIELDS, |
---|
| 65 | AFFIL_OMIT_DISPLAY_FIELDS, |
---|
| 66 | AFFIL_OMIT_PDF_FIELDS, |
---|
| 67 | AFFIL_OMIT_MANAGE_FIELDS, |
---|
| 68 | AFFIL_OMIT_EDIT_FIELDS, |
---|
| 69 | PG_OMIT_DISPLAY_FIELDS, |
---|
| 70 | PG_OMIT_PDF_FIELDS, |
---|
| 71 | PG_OMIT_MANAGE_FIELDS, |
---|
| 72 | PG_OMIT_EDIT_FIELDS, |
---|
| 73 | PUTME_OMIT_DISPLAY_FIELDS, |
---|
| 74 | PUTME_OMIT_PDF_FIELDS, |
---|
| 75 | PUTME_OMIT_MANAGE_FIELDS, |
---|
| 76 | PUTME_OMIT_EDIT_FIELDS, |
---|
| 77 | PUTME_OMIT_RESULT_SLIP_FIELDS, |
---|
| 78 | PUDE_OMIT_DISPLAY_FIELDS, |
---|
| 79 | PUDE_OMIT_PDF_FIELDS, |
---|
| 80 | PUDE_OMIT_MANAGE_FIELDS, |
---|
| 81 | PUDE_OMIT_EDIT_FIELDS, |
---|
| 82 | PUDE_OMIT_RESULT_SLIP_FIELDS, |
---|
| 83 | PRE_OMIT_DISPLAY_FIELDS, |
---|
| 84 | PRE_OMIT_PDF_FIELDS, |
---|
| 85 | PRE_OMIT_MANAGE_FIELDS, |
---|
| 86 | PRE_OMIT_EDIT_FIELDS, |
---|
| 87 | ) |
---|
[8012] | 88 | |
---|
[10378] | 89 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
| 90 | |
---|
[14839] | 91 | PASTQ_ALL = ['ADT','CIT','DEF','DEM','EPCS','ESM','HEK','HSE','VTE'] |
---|
[8012] | 92 | |
---|
[14839] | 93 | PASTQ_AL = ['ENL','FAA','FOL','HIS','LAL', 'PHL','THR','BUL','JIL', |
---|
| 94 | 'LAW','PPL','PUL'] + PASTQ_ALL |
---|
[10338] | 95 | |
---|
| 96 | PASTQ_BS = ['ANT','ANY','CHH','COH','HAE','MED','MEH','PHS','SUR', |
---|
| 97 | 'PCG','PCH','PCO', 'PCT','PHA','PHM','PMB','ANA','MBC', |
---|
| 98 | 'MLS','NSC','PSY','DPV','ODR','OSP','PER', 'RES','AEB', |
---|
| 99 | 'BCH','BOT','CED','EVL','MCB','OPT','PBB','SLT','ZOO', |
---|
| 100 | 'AEE','ANS', 'CRS','FIS','FOW','SOS'] + PASTQ_ALL |
---|
| 101 | |
---|
[14839] | 102 | PASTQ_EPS = ['ARC','CHE','CVE','DMIC','EEE','GEM','MCH','PEE','PRE','CHM', |
---|
[14850] | 103 | 'CSC','GLY','MTH','QSV','PHY','CPE','STR'] + PASTQ_ALL |
---|
[10338] | 104 | |
---|
[14848] | 105 | PASTQ_MSS = ['ACC','BNK','BUS','ECO','ESM','GEO','POL','SAA','SWK', |
---|
| 106 | 'ACT','ENT','HRM','INS','MKT'] + PASTQ_ALL |
---|
[10338] | 107 | |
---|
[13814] | 108 | REGISTRATION_OMIT_DISPLAY_FIELDS = ( |
---|
| 109 | 'locked', |
---|
| 110 | 'suspended', |
---|
[13796] | 111 | ) |
---|
| 112 | |
---|
[13814] | 113 | REGISTRATION_OMIT_EDIT_FIELDS = ( |
---|
| 114 | 'locked', |
---|
| 115 | 'suspended', |
---|
| 116 | 'applicant_id', |
---|
| 117 | ) |
---|
| 118 | |
---|
| 119 | REGISTRATION_OMIT_MANAGE_FIELDS = ( |
---|
| 120 | 'applicant_id', |
---|
| 121 | ) |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | REGISTRATION_OMIT_PDF_FIELDS = ( |
---|
| 125 | 'locked', |
---|
| 126 | 'suspended', |
---|
| 127 | ) |
---|
[14848] | 128 | |
---|
| 129 | PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_PDF_FIELDS + ( |
---|
| 130 | 'fst_sit_results', 'scd_sit_results') |
---|
| 131 | |
---|
[16131] | 132 | TRANS_OMIT_FIELDS = ('locked', 'suspended', 'applicant_id',) |
---|
| 133 | |
---|
| 134 | TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS + ( |
---|
| 135 | 'date_of_birth', |
---|
| 136 | 'sex', |
---|
[16151] | 137 | #'nationality', |
---|
[16131] | 138 | 'entry_mode', |
---|
| 139 | 'entry_session', |
---|
| 140 | 'end_session', |
---|
| 141 | 'course_studied', |
---|
| 142 | 'course_changed', |
---|
[16151] | 143 | #'change_level', |
---|
[16131] | 144 | ) |
---|
| 145 | |
---|
[10587] | 146 | class CustomApplicantsContainerPage(ApplicantsContainerPage): |
---|
| 147 | """The standard view for regular applicant containers. |
---|
| 148 | """ |
---|
| 149 | |
---|
| 150 | @property |
---|
| 151 | def form_fields(self): |
---|
| 152 | form_fields = super(CustomApplicantsContainerPage, self).form_fields |
---|
[10589] | 153 | usertype = getattr(self.request.principal, 'user_type', None) |
---|
| 154 | if self.request.principal.id == 'zope.anybody' or \ |
---|
| 155 | usertype in ('applicant', 'student'): |
---|
[10587] | 156 | return form_fields.omit('application_fee') |
---|
| 157 | return form_fields |
---|
| 158 | |
---|
[8630] | 159 | class CustomApplicantRegistrationPage(ApplicantRegistrationPage): |
---|
| 160 | """Captcha'd registration page for applicants. |
---|
| 161 | """ |
---|
| 162 | |
---|
[10337] | 163 | def _redirect(self, email, password, applicant_id): |
---|
| 164 | # Forward email and credentials to landing page. |
---|
| 165 | self.redirect(self.url(self.context, 'registration_complete', |
---|
| 166 | data = dict(email=email, password=password, |
---|
| 167 | applicant_id=applicant_id))) |
---|
| 168 | return |
---|
[10287] | 169 | |
---|
[10375] | 170 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
| 171 | """A display view for applicant data. |
---|
[10287] | 172 | """ |
---|
[10375] | 173 | grok.template('applicantdisplaypage') |
---|
[10338] | 174 | |
---|
[13887] | 175 | @property |
---|
| 176 | def display_payments(self): |
---|
| 177 | if self.context.special or self.target == 'ictwk': |
---|
| 178 | return True |
---|
| 179 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
| 180 | |
---|
[10622] | 181 | def _show_pastq_putme(self): |
---|
[15487] | 182 | return self.target.startswith('pre') \ |
---|
[14821] | 183 | and self.context.state in ('paid', 'submitted') \ |
---|
| 184 | and getattr(self.context, 'course1') is not None |
---|
| 185 | # return False |
---|
[10338] | 186 | |
---|
| 187 | @property |
---|
[14090] | 188 | def depcode(self): |
---|
| 189 | try: |
---|
| 190 | code = self.context.course1.__parent__.__parent__.code |
---|
| 191 | return code |
---|
| 192 | except: |
---|
| 193 | return |
---|
| 194 | |
---|
| 195 | @property |
---|
[10338] | 196 | def show_pastq_al(self): |
---|
[15486] | 197 | return self._show_pastq_putme() # and self.depcode in PASTQ_AL |
---|
[10338] | 198 | |
---|
| 199 | @property |
---|
| 200 | def show_pastq_bs(self): |
---|
[15486] | 201 | return self._show_pastq_putme() # and self.depcode in PASTQ_BS |
---|
[10338] | 202 | |
---|
| 203 | @property |
---|
| 204 | def show_pastq_eps(self): |
---|
[15486] | 205 | return self._show_pastq_putme() # and self.depcode in PASTQ_EPS |
---|
[10338] | 206 | |
---|
| 207 | @property |
---|
| 208 | def show_pastq_mss(self): |
---|
[15486] | 209 | return self._show_pastq_putme() # and self.depcode in PASTQ_MSS |
---|
[10338] | 210 | |
---|
[10622] | 211 | @property |
---|
| 212 | def show_pastq_pude(self): |
---|
| 213 | return self.target.startswith('pude') \ |
---|
| 214 | and self.context.state in ('paid', 'submitted') |
---|
| 215 | |
---|
[13814] | 216 | @property |
---|
| 217 | def label(self): |
---|
| 218 | if self.target == 'ictwk': |
---|
| 219 | container_title = self.context.__parent__.title |
---|
| 220 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
| 221 | 'a':container_title, 'b':self.context.application_number}) |
---|
| 222 | return super(CustomApplicantDisplayFormPage, self).label |
---|
[11784] | 223 | |
---|
[11782] | 224 | @property |
---|
| 225 | def form_fields(self): |
---|
[16164] | 226 | if self.target is not None and self.target == 'tscf': |
---|
[16131] | 227 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 228 | for field in TRANS_OMIT_FIELDS: |
---|
| 229 | form_fields = form_fields.omit(field) |
---|
[16078] | 230 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
[16151] | 231 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
[16078] | 232 | return form_fields |
---|
[16164] | 233 | if self.target is not None and self.target == 'tscs': |
---|
[16131] | 234 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 235 | for field in TRANS_SHORT_OMIT_FIELDS: |
---|
| 236 | form_fields = form_fields.omit(field) |
---|
| 237 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
[16151] | 238 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
[16131] | 239 | return form_fields |
---|
[13796] | 240 | if self.target == 'ictwk': |
---|
[13814] | 241 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 242 | for field in REGISTRATION_OMIT_DISPLAY_FIELDS: |
---|
[13796] | 243 | form_fields = form_fields.omit(field) |
---|
| 244 | return form_fields |
---|
[14105] | 245 | elif self.target is not None and self.target.startswith('pg'): |
---|
| 246 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 247 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
| 248 | form_fields = form_fields.omit(field) |
---|
| 249 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 250 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 251 | for field in PRE_OMIT_DISPLAY_FIELDS: |
---|
| 252 | form_fields = form_fields.omit(field) |
---|
| 253 | elif self.target is not None and self.target.startswith('cbt'): |
---|
| 254 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 255 | for field in CBT_OMIT_DISPLAY_FIELDS: |
---|
| 256 | form_fields = form_fields.omit(field) |
---|
| 257 | elif self.target is not None and self.target.startswith('akj'): |
---|
| 258 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 259 | for field in PRE_OMIT_DISPLAY_FIELDS: |
---|
| 260 | form_fields = form_fields.omit(field) |
---|
| 261 | elif self.target is not None and self.target.startswith('ak'): |
---|
| 262 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 263 | for field in AFFIL_OMIT_DISPLAY_FIELDS: |
---|
| 264 | form_fields = form_fields.omit(field) |
---|
| 265 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 266 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 267 | for field in PUTME_OMIT_DISPLAY_FIELDS: |
---|
| 268 | form_fields = form_fields.omit(field) |
---|
| 269 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 270 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 271 | for field in PUDE_OMIT_DISPLAY_FIELDS: |
---|
| 272 | form_fields = form_fields.omit(field) |
---|
| 273 | else: |
---|
| 274 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 275 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
| 276 | form_fields = form_fields.omit(field) |
---|
| 277 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 278 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
| 279 | if not getattr(self.context, 'student_id'): |
---|
| 280 | form_fields = form_fields.omit('student_id') |
---|
| 281 | if not getattr(self.context, 'screening_score'): |
---|
| 282 | form_fields = form_fields.omit('screening_score') |
---|
| 283 | if not getattr(self.context, 'screening_venue') or self._not_paid(): |
---|
| 284 | form_fields = form_fields.omit('screening_venue') |
---|
| 285 | if not getattr(self.context, 'screening_date') or self._not_paid(): |
---|
| 286 | form_fields = form_fields.omit('screening_date') |
---|
[11784] | 287 | if not self.context.admchecking_fee_paid(): |
---|
| 288 | form_fields = form_fields.omit( |
---|
| 289 | 'screening_score', 'aggregate', 'student_id') |
---|
[11782] | 290 | return form_fields |
---|
| 291 | |
---|
[11784] | 292 | @property |
---|
| 293 | def display_actions(self): |
---|
| 294 | state = IWorkflowState(self.context).getState() |
---|
| 295 | actions = [] |
---|
| 296 | if state == ADMITTED and not self.context.admchecking_fee_paid(): |
---|
| 297 | actions = [_('Add admission checking payment ticket')] |
---|
| 298 | return actions |
---|
| 299 | |
---|
| 300 | |
---|
| 301 | def getCourseAdmitted(self): |
---|
| 302 | """Return link, title and code in html format to the certificate |
---|
| 303 | admitted. |
---|
| 304 | """ |
---|
[15125] | 305 | if self.admission_checking_info: |
---|
| 306 | return '<span class="hint">%s</span>' % self.admission_checking_info |
---|
| 307 | return super(CustomApplicantDisplayFormPage, self).getCourseAdmitted() |
---|
[11784] | 308 | |
---|
[11786] | 309 | @property |
---|
| 310 | def admission_checking_info(self): |
---|
| 311 | if self.context.state == ADMITTED and \ |
---|
| 312 | not self.context.admchecking_fee_paid(): |
---|
| 313 | return _('You must pay the admission checking fee ' |
---|
[15125] | 314 | 'to view your screening results and your course admitted.') |
---|
[11786] | 315 | return |
---|
| 316 | |
---|
[11784] | 317 | @action(_('Add admission checking payment ticket'), style='primary') |
---|
| 318 | def addPaymentTicket(self, **data): |
---|
| 319 | self.redirect(self.url(self.context, '@@addacp')) |
---|
| 320 | return |
---|
| 321 | |
---|
[11728] | 322 | class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage): |
---|
| 323 | """ Page to add an online payment ticket |
---|
| 324 | """ |
---|
[10378] | 325 | |
---|
[11728] | 326 | @property |
---|
| 327 | def custom_requirements(self): |
---|
[15506] | 328 | if self.context.__parent__.with_picture: |
---|
| 329 | store = getUtility(IExtFileStore) |
---|
| 330 | if not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
| 331 | return _('Upload your 1"x1" Red background passport photo before making payment.') |
---|
[11728] | 332 | return '' |
---|
| 333 | |
---|
[11784] | 334 | class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View): |
---|
| 335 | """ Page to add an admission checking online payment ticket. |
---|
| 336 | """ |
---|
| 337 | grok.context(ICustomApplicant) |
---|
| 338 | grok.name('addacp') |
---|
| 339 | grok.require('waeup.payApplicant') |
---|
| 340 | factory = u'waeup.ApplicantOnlinePayment' |
---|
| 341 | |
---|
| 342 | def _setPaymentDetails(self, payment): |
---|
| 343 | container = self.context.__parent__ |
---|
| 344 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
| 345 | session = str(container.year) |
---|
| 346 | try: |
---|
| 347 | session_config = grok.getSite()['configuration'][session] |
---|
| 348 | except KeyError: |
---|
| 349 | return _(u'Session configuration object is not available.'), None |
---|
| 350 | payment.p_id = "p%s" % timestamp |
---|
| 351 | payment.p_item = container.title |
---|
| 352 | payment.p_session = container.year |
---|
| 353 | payment.amount_auth = 0.0 |
---|
| 354 | payment.p_category = 'admission_checking' |
---|
| 355 | payment.amount_auth = session_config.admchecking_fee |
---|
| 356 | if payment.amount_auth in (0.0, None): |
---|
| 357 | return _('Amount could not be determined.'), None |
---|
| 358 | return |
---|
| 359 | |
---|
[11782] | 360 | def update(self): |
---|
[11784] | 361 | if self.context.admchecking_fee_paid(): |
---|
| 362 | self.flash( |
---|
| 363 | _('Admission checking payment has already been made.'), |
---|
| 364 | type='warning') |
---|
| 365 | self.redirect(self.url(self.context)) |
---|
| 366 | return |
---|
[11782] | 367 | payment = createObject(self.factory) |
---|
[11784] | 368 | failure = self._setPaymentDetails(payment) |
---|
[11782] | 369 | if failure is not None: |
---|
| 370 | self.flash(failure[0], type='danger') |
---|
| 371 | self.redirect(self.url(self.context)) |
---|
| 372 | return |
---|
| 373 | self.context[payment.p_id] = payment |
---|
| 374 | self.flash(_('Payment ticket created.')) |
---|
| 375 | self.redirect(self.url(payment)) |
---|
| 376 | return |
---|
[11736] | 377 | |
---|
[11784] | 378 | def render(self): |
---|
| 379 | return |
---|
[11736] | 380 | |
---|
[11784] | 381 | |
---|
[11782] | 382 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
| 383 | |
---|
[11736] | 384 | @property |
---|
[13887] | 385 | def display_payments(self): |
---|
| 386 | if self.context.special or self.target == 'ictwk': |
---|
| 387 | return True |
---|
| 388 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
| 389 | |
---|
| 390 | @property |
---|
[11736] | 391 | def custom_upload_requirements(self): |
---|
| 392 | if not checkPermission('waeup.uploadPassportPictures', self.context): |
---|
| 393 | return _('You are not entitled to upload passport pictures.') |
---|
[11782] | 394 | |
---|
[13796] | 395 | @property |
---|
[13814] | 396 | def label(self): |
---|
| 397 | if self.target == 'ictwk': |
---|
| 398 | container_title = self.context.__parent__.title |
---|
| 399 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
| 400 | 'a':container_title, 'b':self.context.application_number}) |
---|
| 401 | return super(CustomApplicantManageFormPage, self).label |
---|
| 402 | |
---|
| 403 | @property |
---|
[13796] | 404 | def form_fields(self): |
---|
[16164] | 405 | if self.target is not None and self.target == 'tscf': |
---|
[16078] | 406 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
[16131] | 407 | for field in TRANS_OMIT_FIELDS: |
---|
| 408 | form_fields = form_fields.omit(field) |
---|
[16078] | 409 | return form_fields |
---|
[16164] | 410 | if self.target is not None and self.target == 'tscs': |
---|
[16131] | 411 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 412 | for field in TRANS_SHORT_OMIT_FIELDS: |
---|
| 413 | form_fields = form_fields.omit(field) |
---|
| 414 | return form_fields |
---|
[13796] | 415 | if self.target == 'ictwk': |
---|
[13814] | 416 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 417 | for field in REGISTRATION_OMIT_MANAGE_FIELDS: |
---|
[13796] | 418 | form_fields = form_fields.omit(field) |
---|
[13825] | 419 | state = IWorkflowState(self.context).getState() |
---|
| 420 | if state != STARTED: |
---|
| 421 | form_fields['registration_cats'].for_display = True |
---|
[13814] | 422 | return form_fields |
---|
[14105] | 423 | if self.target is not None and self.target.startswith('pg'): |
---|
| 424 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 425 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
| 426 | form_fields = form_fields.omit(field) |
---|
| 427 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 428 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 429 | for field in PRE_OMIT_MANAGE_FIELDS: |
---|
| 430 | form_fields = form_fields.omit(field) |
---|
| 431 | elif self.target is not None and self.target.startswith('cbt'): |
---|
| 432 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 433 | for field in CBT_OMIT_MANAGE_FIELDS: |
---|
| 434 | form_fields = form_fields.omit(field) |
---|
| 435 | elif self.target is not None and self.target.startswith('akj'): |
---|
| 436 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 437 | for field in PRE_OMIT_MANAGE_FIELDS: |
---|
| 438 | form_fields = form_fields.omit(field) |
---|
| 439 | elif self.target is not None and self.target.startswith('ak'): |
---|
| 440 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 441 | for field in AFFIL_OMIT_MANAGE_FIELDS: |
---|
| 442 | form_fields = form_fields.omit(field) |
---|
| 443 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 444 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 445 | for field in PUTME_OMIT_MANAGE_FIELDS: |
---|
| 446 | form_fields = form_fields.omit(field) |
---|
| 447 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 448 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 449 | for field in PUDE_OMIT_MANAGE_FIELDS: |
---|
| 450 | form_fields = form_fields.omit(field) |
---|
| 451 | else: |
---|
| 452 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 453 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
| 454 | form_fields = form_fields.omit(field) |
---|
| 455 | form_fields['student_id'].for_display = True |
---|
| 456 | form_fields['applicant_id'].for_display = True |
---|
[13796] | 457 | return form_fields |
---|
| 458 | |
---|
| 459 | |
---|
| 460 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
| 461 | """An applicant-centered edit view for applicant data. |
---|
| 462 | """ |
---|
| 463 | |
---|
[14841] | 464 | def unremovable(self, ticket): |
---|
| 465 | return True |
---|
| 466 | |
---|
[13796] | 467 | @property |
---|
[13887] | 468 | def display_payments(self): |
---|
| 469 | if self.context.special or self.target == 'ictwk': |
---|
| 470 | return True |
---|
| 471 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
| 472 | |
---|
| 473 | @property |
---|
[13796] | 474 | def form_fields(self): |
---|
[16164] | 475 | if self.target is not None and self.target == 'tscf': |
---|
[16131] | 476 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 477 | for field in TRANS_OMIT_FIELDS: |
---|
| 478 | form_fields = form_fields.omit(field) |
---|
[16078] | 479 | return form_fields |
---|
[16164] | 480 | if self.target is not None and self.target == 'tscs': |
---|
[16131] | 481 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
| 482 | for field in TRANS_SHORT_OMIT_FIELDS: |
---|
| 483 | form_fields = form_fields.omit(field) |
---|
| 484 | return form_fields |
---|
[13796] | 485 | if self.target == 'ictwk': |
---|
[13814] | 486 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 487 | for field in REGISTRATION_OMIT_EDIT_FIELDS: |
---|
[13796] | 488 | form_fields = form_fields.omit(field) |
---|
[13825] | 489 | state = IWorkflowState(self.context).getState() |
---|
| 490 | if state != STARTED: |
---|
| 491 | form_fields['registration_cats'].for_display = True |
---|
[13814] | 492 | return form_fields |
---|
[14105] | 493 | if self.target is not None and self.target.startswith('pg'): |
---|
| 494 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
| 495 | for field in PG_OMIT_EDIT_FIELDS: |
---|
| 496 | form_fields = form_fields.omit(field) |
---|
| 497 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 498 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
| 499 | for field in PRE_OMIT_EDIT_FIELDS: |
---|
| 500 | form_fields = form_fields.omit(field) |
---|
| 501 | elif self.target is not None and self.target.startswith('cbt'): |
---|
| 502 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 503 | for field in CBT_OMIT_EDIT_FIELDS: |
---|
| 504 | form_fields = form_fields.omit(field) |
---|
| 505 | elif self.target is not None and self.target.startswith('akj'): |
---|
| 506 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 507 | for field in PRE_OMIT_EDIT_FIELDS: |
---|
| 508 | form_fields = form_fields.omit(field) |
---|
| 509 | elif self.target is not None and self.target.startswith('ak'): |
---|
| 510 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 511 | for field in AFFIL_OMIT_EDIT_FIELDS: |
---|
| 512 | form_fields = form_fields.omit(field) |
---|
| 513 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 514 | form_fields = grok.AutoFields(IPUTMEApplicantEdit) |
---|
| 515 | for field in PUTME_OMIT_EDIT_FIELDS: |
---|
| 516 | form_fields = form_fields.omit(field) |
---|
| 517 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 518 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 519 | for field in PUDE_OMIT_EDIT_FIELDS: |
---|
| 520 | form_fields = form_fields.omit(field) |
---|
| 521 | else: |
---|
| 522 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 523 | for field in UG_OMIT_EDIT_FIELDS: |
---|
| 524 | form_fields = form_fields.omit(field) |
---|
| 525 | form_fields['applicant_id'].for_display = True |
---|
| 526 | form_fields['reg_number'].for_display = True |
---|
[13796] | 527 | return form_fields |
---|
| 528 | |
---|
[13814] | 529 | @property |
---|
| 530 | def label(self): |
---|
| 531 | if self.target == 'ictwk': |
---|
| 532 | container_title = self.context.__parent__.title |
---|
| 533 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
| 534 | 'a':container_title, 'b':self.context.application_number}) |
---|
| 535 | return super(CustomApplicantEditFormPage, self).label |
---|
| 536 | |
---|
[16164] | 537 | def display_fileupload(self, filename): |
---|
| 538 | if filename[1] == 'res_stat.pdf' \ |
---|
| 539 | and self.target is not None \ |
---|
| 540 | and not self.target.startswith('tscf'): |
---|
| 541 | return False |
---|
| 542 | if filename[1] == 'eligibility.pdf' \ |
---|
| 543 | and self.target is not None \ |
---|
| 544 | and not self.target.startswith('tsc'): |
---|
| 545 | return False |
---|
| 546 | return True |
---|
| 547 | |
---|
| 548 | def dataNotComplete(self, data): |
---|
| 549 | store = getUtility(IExtFileStore) |
---|
| 550 | if self.context.__parent__.with_picture: |
---|
| 551 | store = getUtility(IExtFileStore) |
---|
| 552 | if not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
| 553 | return _('No passport picture uploaded.') |
---|
| 554 | if self.target is not None \ |
---|
| 555 | and self.target.startswith('tscf') \ |
---|
| 556 | and not store.getFileByContext(self.context, attr=u'res_stat.pdf'): |
---|
| 557 | return _('No statement of result pdf file uploaded.') |
---|
| 558 | if self.target is not None \ |
---|
| 559 | and self.target.startswith('tsc') \ |
---|
| 560 | and not store.getFileByContext(self.context, attr=u'eligibility.pdf'): |
---|
| 561 | return _('No eligibility form pdf file uploaded.') |
---|
| 562 | return False |
---|
| 563 | |
---|
[11782] | 564 | class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage): |
---|
| 565 | """ Approval view |
---|
| 566 | """ |
---|
| 567 | |
---|
| 568 | def update(self): |
---|
[11784] | 569 | if self.context.p_category == 'admission_checking': |
---|
| 570 | if self.context.p_state == 'paid': |
---|
| 571 | flashtype = 'warning' |
---|
| 572 | msg = _('This ticket has already been paid.') |
---|
| 573 | log = None |
---|
| 574 | else: |
---|
| 575 | self.context.approve() |
---|
| 576 | log = 'payment approved: %s' % self.context.p_id |
---|
| 577 | msg = _('Payment approved') |
---|
| 578 | flashtype = 'success' |
---|
| 579 | else: |
---|
| 580 | flashtype, msg, log = self.context.approveApplicantPayment() |
---|
[11782] | 581 | if log is not None: |
---|
| 582 | applicant = self.context.__parent__ |
---|
| 583 | # Add log message to applicants.log |
---|
| 584 | applicant.writeLogMessage(self, log) |
---|
| 585 | # Add log message to payments.log |
---|
| 586 | self.context.logger.info( |
---|
| 587 | '%s,%s,%s,%s,%s,,,,,,' % ( |
---|
| 588 | applicant.applicant_id, |
---|
| 589 | self.context.p_id, self.context.p_category, |
---|
| 590 | self.context.amount_auth, self.context.r_code)) |
---|
| 591 | self.flash(msg, type=flashtype) |
---|
| 592 | return |
---|
[11784] | 593 | |
---|
| 594 | class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip): |
---|
| 595 | """Deliver a PDF slip of the context. |
---|
| 596 | """ |
---|
| 597 | |
---|
| 598 | def update(self): |
---|
| 599 | super(CustomExportPDFPageApplicationSlip, self).update() |
---|
| 600 | if self.context.state == ADMITTED and \ |
---|
| 601 | not self.context.admchecking_fee_paid(): |
---|
| 602 | self.flash( |
---|
| 603 | _('Please pay admission checking fee before trying to download ' |
---|
| 604 | 'the application slip.'), type='warning') |
---|
| 605 | return self.redirect(self.url(self.context)) |
---|
| 606 | return |
---|
[13552] | 607 | |
---|
[13557] | 608 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
[13552] | 609 | |
---|
[13558] | 610 | def _getPDFCreator(self): |
---|
[14061] | 611 | if self.target.startswith('ak'): |
---|
[13558] | 612 | return getUtility(IPDFCreator, name='akoka_pdfcreator') |
---|
| 613 | return getUtility(IPDFCreator) |
---|
| 614 | |
---|
[13552] | 615 | @property |
---|
[13814] | 616 | def form_fields(self): |
---|
| 617 | if self.target == 'ictwk': |
---|
| 618 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
| 619 | for field in REGISTRATION_OMIT_PDF_FIELDS: |
---|
| 620 | form_fields = form_fields.omit(field) |
---|
| 621 | return form_fields |
---|
[14105] | 622 | if self.target is not None and self.target.startswith('pg'): |
---|
| 623 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 624 | for field in PG_OMIT_PDF_FIELDS: |
---|
| 625 | form_fields = form_fields.omit(field) |
---|
| 626 | elif self.target is not None and self.target.startswith('pre'): |
---|
| 627 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 628 | for field in PRE_OMIT_PDF_FIELDS: |
---|
| 629 | form_fields = form_fields.omit(field) |
---|
| 630 | elif self.target is not None and self.target.startswith('cbt'): # uniben |
---|
| 631 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 632 | for field in CBT_OMIT_PDF_FIELDS: |
---|
| 633 | form_fields = form_fields.omit(field) |
---|
| 634 | elif self.target is not None and self.target.startswith('akj'): # uniben |
---|
| 635 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 636 | for field in PRE_OMIT_PDF_FIELDS: |
---|
| 637 | form_fields = form_fields.omit(field) |
---|
| 638 | elif self.target is not None and self.target.startswith('ak'): # uniben |
---|
| 639 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 640 | for field in AFFIL_OMIT_PDF_FIELDS: |
---|
| 641 | form_fields = form_fields.omit(field) |
---|
| 642 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
| 643 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 644 | if self._reduced_slip(): |
---|
| 645 | for field in PUTME_OMIT_RESULT_SLIP_FIELDS: |
---|
| 646 | form_fields = form_fields.omit(field) |
---|
| 647 | else: |
---|
| 648 | for field in PUTME_OMIT_PDF_FIELDS: |
---|
| 649 | form_fields = form_fields.omit(field) |
---|
| 650 | elif self.target is not None and self.target.startswith('pude'): |
---|
| 651 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 652 | if self._reduced_slip(): |
---|
| 653 | for field in PUDE_OMIT_RESULT_SLIP_FIELDS: |
---|
| 654 | form_fields = form_fields.omit(field) |
---|
| 655 | else: |
---|
| 656 | for field in PUDE_OMIT_PDF_FIELDS: |
---|
| 657 | form_fields = form_fields.omit(field) |
---|
| 658 | else: |
---|
| 659 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 660 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 661 | form_fields = form_fields.omit(field) |
---|
| 662 | if not getattr(self.context, 'student_id'): |
---|
| 663 | form_fields = form_fields.omit('student_id') |
---|
| 664 | if not getattr(self.context, 'screening_score'): |
---|
| 665 | form_fields = form_fields.omit('screening_score') |
---|
| 666 | if not getattr(self.context, 'screening_venue'): |
---|
| 667 | form_fields = form_fields.omit('screening_venue') |
---|
| 668 | if not getattr(self.context, 'screening_date'): |
---|
| 669 | form_fields = form_fields.omit('screening_date') |
---|
[13814] | 670 | return form_fields |
---|
| 671 | |
---|
| 672 | @property |
---|
[13552] | 673 | def title(self): |
---|
| 674 | container_title = self.context.__parent__.title |
---|
| 675 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
| 676 | ar_translation = translate(_('Application Record'), |
---|
| 677 | 'waeup.kofa', target_language=portal_language) |
---|
[13814] | 678 | if self.target == 'ictwk': |
---|
| 679 | return '%s - Registration Record %s' % (container_title, |
---|
| 680 | self.context.application_number) |
---|
[14061] | 681 | elif self.target.startswith('ab'): |
---|
[13552] | 682 | return 'Federal College of Education (Technical) Asaba - %s %s %s' % ( |
---|
| 683 | container_title, ar_translation, |
---|
| 684 | self.context.application_number) |
---|
[14061] | 685 | elif self.target.startswith('ak'): |
---|
[14064] | 686 | return 'Federal College of Education (Technical) Akoka - %s - %s %s' % ( |
---|
[13552] | 687 | container_title, ar_translation, |
---|
| 688 | self.context.application_number) |
---|
[13615] | 689 | elif self.target == 'pgn': |
---|
| 690 | return 'National Institute for Legislative Studies (NILS) - %s %s %s' % ( |
---|
| 691 | container_title, ar_translation, |
---|
| 692 | self.context.application_number) |
---|
[13552] | 693 | return '%s - %s %s' % (container_title, |
---|
| 694 | ar_translation, self.context.application_number) |
---|
[14147] | 695 | |
---|
| 696 | class ExportScreeningInvitationSlip(UtilityView, grok.View): |
---|
| 697 | """Deliver a PDF slip of the context. |
---|
| 698 | """ |
---|
| 699 | grok.context(ICustomApplicant) |
---|
| 700 | grok.name('screening_invitation_slip.pdf') |
---|
| 701 | grok.require('waeup.viewApplication') |
---|
| 702 | form_fields = None |
---|
[14148] | 703 | label = u'Invitation Letter for Pre-Admission Screening' |
---|
[14147] | 704 | |
---|
| 705 | |
---|
| 706 | @property |
---|
| 707 | def note(self): |
---|
[14168] | 708 | notice = getattr(self.context.__parent__, 'application_slip_notice', None) |
---|
[14147] | 709 | if self.context.screening_date: |
---|
| 710 | return """ |
---|
| 711 | <br /><br /><br /><br /><font size='12'> |
---|
| 712 | Dear %s, |
---|
| 713 | <br /><br /><br /> |
---|
| 714 | You are invited for your Uniben Admission Screening Exercise on: |
---|
| 715 | <br /><br /> |
---|
| 716 | <strong>%s</strong>. |
---|
| 717 | <br /><br /> |
---|
[14167] | 718 | Please bring along this letter of invitation to the |
---|
[14147] | 719 | <br /><br /> |
---|
[14167] | 720 | <strong>%s</strong> |
---|
| 721 | <br /><br /> |
---|
[14147] | 722 | on your screening date. |
---|
| 723 | <br /><br /><br /> |
---|
| 724 | Signed, |
---|
| 725 | <br /><br /> |
---|
| 726 | The Registrar<br /> |
---|
[14168] | 727 | <br /><br /> |
---|
| 728 | <br /><br /> |
---|
| 729 | %s |
---|
[14147] | 730 | </font> |
---|
| 731 | |
---|
[14167] | 732 | """ % (self.context.display_fullname, self.context.screening_date, |
---|
[14168] | 733 | self.context.screening_venue, notice) |
---|
[14147] | 734 | return |
---|
| 735 | |
---|
| 736 | def update(self): |
---|
| 737 | if not self.context.screening_date: |
---|
| 738 | self.flash(_('Forbidden'), type="warning") |
---|
| 739 | self.redirect(self.url(self.context)) |
---|
| 740 | |
---|
| 741 | def render(self): |
---|
| 742 | applicantview = ApplicantBaseDisplayFormPage(self.context, self.request) |
---|
| 743 | students_utils = getUtility(IStudentsUtils) |
---|
| 744 | return students_utils.renderPDF(self,'screening_invitation_slip.pdf', |
---|
[16117] | 745 | self.context, applicantview, note=self.note) |
---|
| 746 | |
---|
| 747 | class CustomCheckTranscriptStatus(CheckTranscriptStatus): |
---|
| 748 | """A display page for checking transcript processing status. |
---|
| 749 | """ |
---|
[16119] | 750 | websites = (('Uniben Alumni Portal', 'https://uniben-alumni.waeup.org/'), |
---|
| 751 | ('Uniben Student Portal', 'https://uniben.waeup.org/'),) |
---|
[16164] | 752 | appl_url1 = 'https://uniben-alumni.waeup.org/applicants/tscf1/register' |
---|
| 753 | appl_url2 = 'https://uniben-alumni.waeup.org/applicants/tscs1/register' |
---|
| 754 | |
---|
| 755 | class ResultStatement(AdditionalFile): |
---|
| 756 | grok.name('res_stat.pdf') |
---|
| 757 | |
---|
| 758 | class EligibilityForm(AdditionalFile): |
---|
| 759 | grok.name('eligibility.pdf') |
---|