source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/browser.py @ 17973

Last change on this file since 17973 was 17964, checked in by Henrik Bettermann, 4 weeks ago

Implement African Institute of management and Leadership application.

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