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