## $Id: browser.py 17964 2024-11-27 00:30:20Z henrik $ ## ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## """UI components for basic applicants and related components. """ import grok from time import time from zope.component import getUtility, createObject from zope.formlib.textwidgets import BytesDisplayWidget from zope.security import checkPermission from zope.i18n import translate from hurry.workflow.interfaces import IWorkflowState from waeup.kofa.browser.layout import action, UtilityView from waeup.kofa.interfaces import IExtFileStore, IKofaUtils from waeup.kofa.applicants.browser import ( ApplicantRegistrationPage, ApplicantsContainerPage, ApplicationFeePaymentAddPage, OnlinePaymentApprovePage, ExportPDFPageApplicationSlip, ApplicantBaseDisplayFormPage, CheckTranscriptStatus, AdditionalFile,) from waeup.kofa.students.interfaces import IStudentsUtils from waeup.kofa.applicants.interfaces import ( ISpecialApplicant, IApplicantsUtils) from waeup.kofa.browser.interfaces import IPDFCreator from kofacustom.nigeria.applicants.browser import ( NigeriaApplicantDisplayFormPage, NigeriaApplicantManageFormPage, NigeriaApplicantEditFormPage, NigeriaPDFApplicationSlip, NigeriaExportPDFPaymentSlipPage) from waeup.uniben.applicants.interfaces import ( ICustomApplicant, IUnibenRegistration, ICustomUGApplicant, ICustomPGApplicant, ICustomPGApplicantEdit, ICustomUGApplicantEdit, IPUTMEApplicantEdit, ITranscriptApplicant, IFrenchApplicant, IAfrimalApplicant) from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED from kofacustom.nigeria.applicants.interfaces import ( OMIT_DISPLAY_FIELDS, UG_OMIT_DISPLAY_FIELDS, UG_OMIT_PDF_FIELDS, UG_OMIT_MANAGE_FIELDS, UG_OMIT_EDIT_FIELDS, CBT_OMIT_DISPLAY_FIELDS, CBT_OMIT_PDF_FIELDS, CBT_OMIT_MANAGE_FIELDS, CBT_OMIT_EDIT_FIELDS, AFFIL_OMIT_DISPLAY_FIELDS, AFFIL_OMIT_PDF_FIELDS, AFFIL_OMIT_MANAGE_FIELDS, AFFIL_OMIT_EDIT_FIELDS, PG_OMIT_DISPLAY_FIELDS, PG_OMIT_PDF_FIELDS, PG_OMIT_MANAGE_FIELDS, PG_OMIT_EDIT_FIELDS, PUTME_OMIT_DISPLAY_FIELDS, PUTME_OMIT_PDF_FIELDS, PUTME_OMIT_MANAGE_FIELDS, PUTME_OMIT_EDIT_FIELDS, PUTME_OMIT_RESULT_SLIP_FIELDS, PUDE_OMIT_DISPLAY_FIELDS, PUDE_OMIT_PDF_FIELDS, PUDE_OMIT_MANAGE_FIELDS, PUDE_OMIT_EDIT_FIELDS, PUDE_OMIT_RESULT_SLIP_FIELDS, PRE_OMIT_DISPLAY_FIELDS, PRE_OMIT_PDF_FIELDS, PRE_OMIT_MANAGE_FIELDS, PRE_OMIT_EDIT_FIELDS, ) from waeup.uniben.interfaces import MessageFactory as _ PASTQ_ALL = ['ADT','CIT','DEF','DEM','EPCS','ESM','HEK','HSE','VTE'] PASTQ_AL = ['ENL','FAA','FOL','HIS','LAL', 'PHL','THR','BUL','JIL', 'LAW','PPL','PUL'] + PASTQ_ALL PASTQ_BS = ['ANT','ANY','CHH','COH','HAE','MED','MEH','PHS','SUR', 'PCG','PCH','PCO', 'PCT','PHA','PHM','PMB','ANA','MBC', 'MLS','NSC','PSY','DPV','ODR','OSP','PER', 'RES','AEB', 'BCH','BOT','CED','EVL','MCB','OPT','PBB','SLT','ZOO', 'AEE','ANS', 'CRS','FIS','FOW','SOS'] + PASTQ_ALL PASTQ_EPS = ['ARC','CHE','CVE','DMIC','EEE','GEM','MCH','PEE','PRE','CHM', 'CSC','GLY','MTH','QSV','PHY','CPE','STR'] + PASTQ_ALL PASTQ_MSS = ['ACC','BNK','BUS','ECO','ESM','GEO','POL','SAA','SWK', 'ACT','ENT','HRM','INS','MKT'] + PASTQ_ALL PT_OMIT_FIELDS = ( 'student_id', 'notice', 'screening_score', 'screening_venue', 'screening_date', 'jamb_age', 'jamb_subjects', 'jamb_score', #'jamb_reg_number', 'aggregate', 'hq_type', 'hq_matric_no', 'hq_degree', 'hq_school', 'hq_session', 'hq_disc', 'jamb_subjects_list', 'programme_type') PT_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PT_OMIT_FIELDS PT_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PT_OMIT_FIELDS PT_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + PT_OMIT_FIELDS PT_OMIT_PDF_FIELDS = PT_OMIT_DISPLAY_FIELDS + ('phone',) PT_OMIT_RESULT_SLIP_FIELDS = PT_OMIT_DISPLAY_FIELDS + ( 'phone', 'date_of_birth', 'sex', 'nationality', 'lga', #'perm_address', 'course2', 'screening_venue', 'screening_date') REGISTRATION_OMIT_DISPLAY_FIELDS = ( 'locked', 'suspended', 'course_admitted', ) REGISTRATION_OMIT_EDIT_FIELDS = ( 'locked', 'suspended', 'applicant_id', 'course_admitted', ) REGISTRATION_OMIT_MANAGE_FIELDS = ( 'applicant_id', ) REGISTRATION_OMIT_PDF_FIELDS = ( 'locked', 'suspended', 'course_admitted', ) PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_PDF_FIELDS + ( 'fst_sit_results', 'scd_sit_results') TRANS_OMIT_FIELDS = ('suspended',) #TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS + ( # 'date_of_birth', # 'sex', # #'nationality', # 'entry_mode', # 'entry_session', # 'end_session', # 'course_studied', # 'course_changed', # #'change_level', # ) TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS TRANS_OMIT_EDIT_FIELDS = TRANS_OMIT_FIELDS + ('applicant_id', ) TRANS_SHORT_OMIT_EDIT_FIELDS = TRANS_SHORT_OMIT_FIELDS + ('applicant_id', ) TRANS_OMIT_PDF_FIELDS = TRANS_OMIT_FIELDS + ('locked', ) TRANS_SHORT_OMIT_PDF_FIELDS = TRANS_SHORT_OMIT_FIELDS + ('locked', ) class CustomApplicantsContainerPage(ApplicantsContainerPage): """The standard view for regular applicant containers. """ @property def form_fields(self): form_fields = super(CustomApplicantsContainerPage, self).form_fields usertype = getattr(self.request.principal, 'user_type', None) if self.request.principal.id == 'zope.anybody' or \ usertype in ('applicant', 'student'): return form_fields.omit('application_fee') return form_fields class CustomApplicantRegistrationPage(ApplicantRegistrationPage): """Captcha'd registration page for applicants. """ def _redirect(self, email, password, applicant_id): # Forward email and credentials to landing page. self.redirect(self.url(self.context, 'registration_complete', data = dict(email=email, password=password, applicant_id=applicant_id))) return @property def label(self): if self.context.prefix.startswith('tsc'): return _('Request for ${a}', mapping = {'a':self.context.title}) return _('Apply for ${a}', mapping = {'a':self.context.title}) class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): """A display view for applicant data. """ grok.template('applicantdisplaypage') @property def display_payments(self): if self.context.special or self.target == 'ictwk': return True return getattr(self.context.__parent__, 'application_fee', None) def _show_pastq_putme(self): return self.target.startswith('pre') \ and self.context.state in ('paid', 'submitted') \ and getattr(self.context, 'course1') is not None # return False @property def depcode(self): try: code = self.context.course1.__parent__.__parent__.code return code except: return @property def show_pastq_al(self): return self._show_pastq_putme() # and self.depcode in PASTQ_AL @property def show_pastq_bs(self): return self._show_pastq_putme() # and self.depcode in PASTQ_BS @property def show_pastq_eps(self): return self._show_pastq_putme() # and self.depcode in PASTQ_EPS @property def show_pastq_mss(self): return self._show_pastq_putme() # and self.depcode in PASTQ_MSS @property def show_pastq_pude(self): return self.target.startswith('pude') \ and self.context.state in ('paid', 'submitted') @property def label(self): if self.target == 'ictwk': container_title = self.context.__parent__.title return _('${a}
Registration Record ${b}', mapping = { 'a':container_title, 'b':self.context.application_number}) return super(CustomApplicantDisplayFormPage, self).label @property def form_fields(self): if self.target is not None and self.target == 'tscf': form_fields = grok.AutoFields(ITranscriptApplicant) for field in TRANS_OMIT_FIELDS: form_fields = form_fields.omit(field) form_fields['dispatch_address'].custom_widget = BytesDisplayWidget #form_fields['perm_address'].custom_widget = BytesDisplayWidget return form_fields if self.target is not None and self.target == 'tscs': form_fields = grok.AutoFields(ITranscriptApplicant) for field in TRANS_SHORT_OMIT_FIELDS: form_fields = form_fields.omit(field) form_fields['dispatch_address'].custom_widget = BytesDisplayWidget #form_fields['perm_address'].custom_widget = BytesDisplayWidget return form_fields if self.target is not None and self.target == 'flc': form_fields = grok.AutoFields(IFrenchApplicant) for field in REGISTRATION_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target == 'afrimal': form_fields = grok.AutoFields(IAfrimalApplicant) for field in REGISTRATION_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target == 'ictwk': form_fields = grok.AutoFields(IUnibenRegistration) for field in REGISTRATION_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) return form_fields elif self.target is not None and self.target.startswith('pg'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PG_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pre'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('cbt'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in CBT_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('akj'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ak'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in AFFIL_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ase'): # was putme form_fields = grok.AutoFields(ICustomUGApplicant) for field in PUTME_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pt'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in PT_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pude'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in PUDE_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) else: form_fields = grok.AutoFields(ICustomUGApplicant) for field in UG_OMIT_DISPLAY_FIELDS: form_fields = form_fields.omit(field) #form_fields['perm_address'].custom_widget = BytesDisplayWidget try: form_fields['notice'].custom_widget = BytesDisplayWidget except: pass if not getattr(self.context, 'student_id'): form_fields = form_fields.omit('student_id') if not getattr(self.context, 'screening_score'): form_fields = form_fields.omit('screening_score') if not getattr(self.context, 'screening_venue') or self._not_paid(): form_fields = form_fields.omit('screening_venue') if not getattr(self.context, 'screening_date') or self._not_paid(): form_fields = form_fields.omit('screening_date') if not self.context.admchecking_fee_paid(): form_fields = form_fields.omit( 'screening_score', 'aggregate', 'student_id') return form_fields @property def display_actions(self): state = IWorkflowState(self.context).getState() actions = [] if state == ADMITTED and not self.context.admchecking_fee_paid(): actions = [_('Add admission checking payment ticket')] return actions def getCourseAdmitted(self): """Return link, title and code in html format to the certificate admitted. """ if self.admission_checking_info: return '%s' % self.admission_checking_info return super(CustomApplicantDisplayFormPage, self).getCourseAdmitted() @property def admission_checking_info(self): if self.context.state == ADMITTED and \ not self.context.admchecking_fee_paid(): return _('You must pay the admission checking fee ' 'to view your screening results and your course admitted.') return @action(_('Add admission checking payment ticket'), style='primary') def addPaymentTicket(self, **data): self.redirect(self.url(self.context, '@@addacp')) return class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage): """ Page to add an online payment ticket """ @property def custom_requirements(self): if self.context.__parent__.with_picture: store = getUtility(IExtFileStore) if self.context.__parent__.picture_editable \ and not store.getFileByContext(self.context, attr=u'passport.jpg'): return _('Upload your 1"x1" Red background passport photo before making payment.') return '' class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View): """ Page to add an admission checking online payment ticket. """ grok.context(ICustomApplicant) grok.name('addacp') grok.require('waeup.payApplicant') factory = u'waeup.ApplicantOnlinePayment' def _setPaymentDetails(self, payment): container = self.context.__parent__ timestamp = ("%d" % int(time()*10000))[1:] session = str(container.year) try: session_config = grok.getSite()['configuration'][session] except KeyError: return _(u'Session configuration object is not available.'), None payment.p_id = "p%s" % timestamp payment.p_item = container.title payment.p_session = container.year payment.amount_auth = 0.0 payment.p_category = 'admission_checking' payment.amount_auth = session_config.admchecking_fee if payment.amount_auth in (0.0, None): return _('Amount could not be determined.'), None return def update(self): if self.context.admchecking_fee_paid(): self.flash( _('Admission checking payment has already been made.'), type='warning') self.redirect(self.url(self.context)) return payment = createObject(self.factory) failure = self._setPaymentDetails(payment) if failure is not None: self.flash(failure[0], type='danger') self.redirect(self.url(self.context)) return self.context[payment.p_id] = payment self.flash(_('Payment ticket created.')) self.redirect(self.url(payment)) return def render(self): return class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): @property def display_payments(self): if self.context.special or self.target == 'ictwk': return True return getattr(self.context.__parent__, 'application_fee', None) @property def custom_upload_requirements(self): if not checkPermission('waeup.uploadPassportPictures', self.context): return _('You are not entitled to upload passport pictures.') def display_fileupload(self, filename): if filename[1] == 'res_stat' \ and self.target is not None \ and not self.target.startswith('tsc'): return False if filename[1] == 'eligibility' \ and self.target is not None \ and not self.target.startswith('tsc'): return False return True @property def label(self): if self.target == 'ictwk': container_title = self.context.__parent__.title return _('${a}
Registration Record ${b}', mapping = { 'a':container_title, 'b':self.context.application_number}) return super(CustomApplicantManageFormPage, self).label @property def form_fields(self): if self.target is not None and self.target == 'tscf': form_fields = grok.AutoFields(ITranscriptApplicant) for field in TRANS_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target == 'tscs': form_fields = grok.AutoFields(ITranscriptApplicant) for field in TRANS_SHORT_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target == 'ictwk': form_fields = grok.AutoFields(IUnibenRegistration) for field in REGISTRATION_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) state = IWorkflowState(self.context).getState() if state != STARTED: form_fields['registration_cats'].for_display = True return form_fields if self.target is not None and self.target == 'flc': form_fields = grok.AutoFields(IFrenchApplicant) for field in REGISTRATION_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target == 'afrimal': form_fields = grok.AutoFields(IAfrimalApplicant) for field in REGISTRATION_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target.startswith('pg'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PG_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pre'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('cbt'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in CBT_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('akj'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ak'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in AFFIL_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ase'): # was putme form_fields = grok.AutoFields(ICustomUGApplicant) for field in PUTME_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pt'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in PT_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pude'): form_fields = grok.AutoFields(ICustomUGApplicant) for field in PUDE_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) else: form_fields = grok.AutoFields(ICustomUGApplicant) for field in UG_OMIT_MANAGE_FIELDS: form_fields = form_fields.omit(field) try: form_fields['student_id'].for_display = True except: pass try: form_fields['applicant_id'].for_display = True except: pass return form_fields class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): """An applicant-centered edit view for applicant data. """ def unremovable(self, ticket): return True @property def display_payments(self): if self.context.special or self.target == 'ictwk': return True return getattr(self.context.__parent__, 'application_fee', None) @property def form_fields(self): state = IWorkflowState(self.context).getState() if self.target is not None and self.target == 'tscf': form_fields = grok.AutoFields(ITranscriptApplicant) form_fields['courier_tno'].for_display = True form_fields['proc_date'].for_display = True if state == PAID: form_fields['order'].for_display = True form_fields = form_fields.omit('locked') form_fields['date_of_birth'].field.required = True #form_fields['nationality'].field.required = True form_fields['email'].field.required = True form_fields['phone'].field.required = True form_fields['dispatch_address'].field.required = True form_fields['entry_mode'].field.required = True form_fields['entry_session'].field.required = True form_fields['end_session'].field.required = True form_fields['course_studied'].field.required = True form_fields['collected'].field.required = True form_fields['order'].field.required = True form_fields['charge'].field.required = True form_fields['no_copies'].field.required = True for field in TRANS_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target == 'tscs': form_fields = grok.AutoFields(ITranscriptApplicant) form_fields['courier_tno'].for_display = True form_fields['proc_date'].for_display = True form_fields['date_of_birth'].field.required = True #form_fields['nationality'].field.required = True form_fields['email'].field.required = True form_fields['phone'].field.required = True form_fields['dispatch_address'].field.required = True form_fields['entry_mode'].field.required = True form_fields['entry_session'].field.required = True form_fields['end_session'].field.required = True form_fields['course_studied'].field.required = True form_fields['collected'].field.required = True form_fields['order'].field.required = True form_fields['charge'].field.required = True form_fields['no_copies'].field.required = True for field in TRANS_SHORT_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) form_fields = form_fields.omit('locked') if state == PAID: form_fields['order'].for_display = True return form_fields if self.target == 'ictwk': form_fields = grok.AutoFields(IUnibenRegistration) for field in REGISTRATION_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) if state != STARTED: form_fields['registration_cats'].for_display = True return form_fields if self.target is not None and self.target == 'flc': form_fields = grok.AutoFields(IFrenchApplicant) for field in REGISTRATION_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target == 'afrimal': form_fields = grok.AutoFields(IAfrimalApplicant) for field in REGISTRATION_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) return form_fields if self.target is not None and self.target.startswith('pg'): form_fields = grok.AutoFields(ICustomPGApplicantEdit) for field in PG_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pre'): form_fields = grok.AutoFields(ICustomPGApplicantEdit) for field in PRE_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('cbt'): form_fields = grok.AutoFields(ICustomUGApplicantEdit) for field in CBT_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('akj'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ak'): form_fields = grok.AutoFields(ICustomUGApplicantEdit) for field in AFFIL_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ase'): # was putme form_fields = grok.AutoFields(IPUTMEApplicantEdit) for field in PUTME_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pt'): form_fields = grok.AutoFields(IPUTMEApplicantEdit) for field in PT_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pude'): form_fields = grok.AutoFields(ICustomUGApplicantEdit) for field in PUDE_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) else: form_fields = grok.AutoFields(ICustomUGApplicantEdit) for field in UG_OMIT_EDIT_FIELDS: form_fields = form_fields.omit(field) form_fields['applicant_id'].for_display = True form_fields['reg_number'].for_display = True return form_fields @property def label(self): if self.target == 'ictwk': container_title = self.context.__parent__.title return _('${a}
Registration Record ${b}', mapping = { 'a':container_title, 'b':self.context.application_number}) return super(CustomApplicantEditFormPage, self).label def display_fileupload(self, filename): if filename[1] == 'res_stat' \ and self.target is not None \ and not self.target.startswith('tsc'): return False if filename[1] == 'eligibility' \ and self.target is not None \ and not self.target.startswith('tsc'): return False return True def dataNotComplete(self, data): store = getUtility(IExtFileStore) if self.context.__parent__.with_picture \ and self.context.__parent__.picture_editable: store = getUtility(IExtFileStore) if not store.getFileByContext(self.context, attr=u'passport.jpg'): return _('No passport picture uploaded.') if self.target is not None \ and self.target.startswith('tscf') \ and not store.getFileByContext(self.context, attr=u'res_stat.pdf'): return _('No statement of result pdf file uploaded.') if self.target is not None \ and self.target.startswith('tsc') \ and (not self.context.order or not self.context.charge): return _('Please select Type of Order and Transcript Charge.') if self.target is not None \ and self.target.startswith('pt') \ and not self.context.jamb_reg_number: return _('Please enter your JAMB Registration Number.') return False class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage): """ Approval view """ def update(self): if self.context.p_category == 'admission_checking': if self.context.p_state == 'paid': flashtype = 'warning' msg = _('This ticket has already been paid.') log = None else: self.context.approve() log = 'payment approved: %s' % self.context.p_id msg = _('Payment approved') flashtype = 'success' else: flashtype, msg, log = self.context.approveApplicantPayment() if log is not None: applicant = self.context.__parent__ # Add log message to applicants.log applicant.writeLogMessage(self, log) # Add log message to payments.log self.context.logger.info( '%s,%s,%s,%s,%s,,,,,,' % ( applicant.applicant_id, self.context.p_id, self.context.p_category, self.context.amount_auth, self.context.r_code)) self.flash(msg, type=flashtype) return class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip): """Deliver a PDF slip of the context. """ def update(self): super(CustomExportPDFPageApplicationSlip, self).update() if self.context.state == ADMITTED and \ not self.context.admchecking_fee_paid(): self.flash( _('Please pay admission checking fee before trying to download ' 'the application slip.'), type='warning') return self.redirect(self.url(self.context)) return class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): def _getPDFCreator(self): if self.target.startswith('ak'): return getUtility(IPDFCreator, name='akoka_pdfcreator') return getUtility(IPDFCreator) @property def form_fields(self): if self.target is not None and self.target == 'tscf': form_fields = grok.AutoFields(ITranscriptApplicant) for field in TRANS_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target == 'tscs': form_fields = grok.AutoFields(ITranscriptApplicant) for field in TRANS_SHORT_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target == 'ictwk': form_fields = grok.AutoFields(IUnibenRegistration) for field in REGISTRATION_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pg'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PG_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pre'): form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('cbt'): # uniben form_fields = grok.AutoFields(ICustomUGApplicant) for field in CBT_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('akj'): # uniben form_fields = grok.AutoFields(ICustomPGApplicant) for field in PRE_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ak'): # uniben form_fields = grok.AutoFields(ICustomUGApplicant) for field in AFFIL_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('ase'): # was putme form_fields = grok.AutoFields(ICustomUGApplicant) if self._reduced_slip(): for field in PUTME_OMIT_RESULT_SLIP_FIELDS: form_fields = form_fields.omit(field) else: for field in PUTME_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pt'): form_fields = grok.AutoFields(ICustomUGApplicant) if self._reduced_slip(): for field in PT_OMIT_RESULT_SLIP_FIELDS: form_fields = form_fields.omit(field) else: for field in PT_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target.startswith('pude'): form_fields = grok.AutoFields(ICustomUGApplicant) if self._reduced_slip(): for field in PUDE_OMIT_RESULT_SLIP_FIELDS: form_fields = form_fields.omit(field) else: for field in PUDE_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target == 'flc': form_fields = grok.AutoFields(IFrenchApplicant) for field in REGISTRATION_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) elif self.target is not None and self.target == 'afrimal': form_fields = grok.AutoFields(IAfrimalApplicant) for field in REGISTRATION_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) else: form_fields = grok.AutoFields(ICustomUGApplicant) for field in UG_OMIT_PDF_FIELDS: form_fields = form_fields.omit(field) if not getattr(self.context, 'student_id'): form_fields = form_fields.omit('student_id') if not getattr(self.context, 'screening_score'): form_fields = form_fields.omit('screening_score') if not getattr(self.context, 'screening_venue'): form_fields = form_fields.omit('screening_venue') if not getattr(self.context, 'screening_date'): form_fields = form_fields.omit('screening_date') return form_fields @property def title(self): container_title = self.context.__parent__.title portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE ar_translation = translate(_('Application Record'), 'waeup.kofa', target_language=portal_language) if self.target == 'ictwk': return '%s - Registration Record %s' % (container_title, self.context.application_number) elif self.target.startswith('ab'): return 'Federal College of Education (Technical) Asaba - %s %s %s' % ( container_title, ar_translation, self.context.application_number) elif self.target.startswith('ak'): return 'Federal College of Education (Technical) Akoka - %s - %s %s' % ( container_title, ar_translation, self.context.application_number) elif self.target == 'pgn': return 'National Institute for Legislative Studies (NILS) - %s %s %s' % ( container_title, ar_translation, self.context.application_number) return '%s - %s %s' % (container_title, ar_translation, self.context.application_number) class CustomApplicantBaseDisplayFormPage(ApplicantBaseDisplayFormPage): @property def form_fields(self): target = getattr(self.context.__parent__, 'prefix', None) if target.startswith('tsc'): form_fields = grok.AutoFields(ICustomApplicant).select( 'applicant_id', 'email', 'dispatch_address') else: form_fields = grok.AutoFields(ICustomApplicant).select( 'applicant_id', 'reg_number', 'email', 'course1') if self.context.__parent__.prefix in ('special',): form_fields['reg_number'].field.title = u'Identification Number' return form_fields return form_fields class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): """Deliver a PDF slip of the context. """ @property def omit_fields(self): target = getattr(self.context.__parent__.__parent__, 'prefix', None) if target.startswith('tsc'): return ('date_of_birth', 'course1') return () @property def note(self): return def render(self): if self.payment_slip_download_warning: self.flash(self.payment_slip_download_warning, type='danger') self.redirect(self.url(self.context)) return applicantview = CustomApplicantBaseDisplayFormPage(self.context.__parent__, self.request) students_utils = getUtility(IStudentsUtils) return students_utils.renderPDF(self,'payment_slip.pdf', self.context.__parent__, applicantview, note=self.note, omit_fields=self.omit_fields) class ExportScreeningInvitationSlip(UtilityView, grok.View): """Deliver a PDF slip of the context. """ grok.context(ICustomApplicant) grok.name('screening_invitation_slip.pdf') grok.require('waeup.viewApplication') form_fields = None label = u'Invitation Letter for Pre-Admission Screening' @property def note(self): notice = getattr(self.context.__parent__, 'application_slip_notice') if notice is None: notice = '' if self.context.screening_date: return """



Dear %s,


You are invited for your Uniben Admission Screening Exercise on:

%s.

Please bring along this letter of invitation to the

%s

on your screening date.


Signed,

The Registrar




%s
""" % (self.context.display_fullname, self.context.screening_date, self.context.screening_venue, notice) return def update(self): if not self.context.screening_date: self.flash(_('Forbidden'), type="warning") self.redirect(self.url(self.context)) def render(self): applicantview = ApplicantBaseDisplayFormPage(self.context, self.request) students_utils = getUtility(IStudentsUtils) return students_utils.renderPDF(self,'screening_invitation_slip.pdf', self.context, applicantview, note=self.note) class CustomCheckTranscriptStatus(CheckTranscriptStatus): """A display page for checking transcript processing status. """ grok.template('checktranscriptstatus') websites = (('Uniben Alumni Portal', 'https://alumni.uniben.edu/'), ('Uniben Student Portal', 'https://waeup.uniben.edu/'),) appl_url1 = 'https://alumni.uniben.edu/applicants/tscf1/register' appl_url2 = 'https://alumni.uniben.edu/applicants/tscs1/register' class CreateGraduatedPage(UtilityView, grok.View): """Create a student object from transcript application data. """ grok.context(ICustomApplicant) grok.name('creategraduated') grok.require('waeup.createStudents') def update(self): success, msg = self.context.createStudent(view=self, graduated=True) if success: self.flash(msg) else: self.flash(msg, type='warning') self.redirect(self.url(self.context)) return def render(self): return class ResultStatement(AdditionalFile): grok.name('res_stat') class EligibilityForm(AdditionalFile): grok.name('eligibility')