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

Last change on this file since 17497 was 17084, checked in by Henrik Bettermann, 2 years ago

Charge and order fields must not be required.

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