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

Last change on this file since 16189 was 16184, checked in by Henrik Bettermann, 4 years ago

Customize transcript application slip.

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