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

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

Do not prevend applicants from paying.

  • Property svn:keywords set to Id
File size: 31.5 KB
RevLine 
[8012]1## $Id: browser.py 16211 2020-08-24 12:53:08Z 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
[16210]132TRANS_OMIT_FIELDS = ('suspended', 'applicant_id',)
[16131]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)
[16211]338            if self.context.__parent__.picture_editable \
339                and not store.getFileByContext(self.context, attr=u'passport.jpg'):
[15506]340                return _('Upload your 1"x1" Red background passport photo before making payment.')
[11728]341        return ''
342
[11784]343class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View):
344    """ Page to add an admission checking online payment ticket.
345    """
346    grok.context(ICustomApplicant)
347    grok.name('addacp')
348    grok.require('waeup.payApplicant')
349    factory = u'waeup.ApplicantOnlinePayment'
350
351    def _setPaymentDetails(self, payment):
352        container = self.context.__parent__
353        timestamp = ("%d" % int(time()*10000))[1:]
354        session = str(container.year)
355        try:
356            session_config = grok.getSite()['configuration'][session]
357        except KeyError:
358            return _(u'Session configuration object is not available.'), None
359        payment.p_id = "p%s" % timestamp
360        payment.p_item = container.title
361        payment.p_session = container.year
362        payment.amount_auth = 0.0
363        payment.p_category = 'admission_checking'
364        payment.amount_auth = session_config.admchecking_fee
365        if payment.amount_auth in (0.0, None):
366            return _('Amount could not be determined.'), None
367        return
368
[11782]369    def update(self):
[11784]370        if self.context.admchecking_fee_paid():
371              self.flash(
372                  _('Admission checking payment has already been made.'),
373                  type='warning')
374              self.redirect(self.url(self.context))
375              return
[11782]376        payment = createObject(self.factory)
[11784]377        failure = self._setPaymentDetails(payment)
[11782]378        if failure is not None:
379            self.flash(failure[0], type='danger')
380            self.redirect(self.url(self.context))
381            return
382        self.context[payment.p_id] = payment
383        self.flash(_('Payment ticket created.'))
384        self.redirect(self.url(payment))
385        return
[11736]386
[11784]387    def render(self):
388        return
[11736]389
[11784]390
[11782]391class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
392
[11736]393    @property
[13887]394    def display_payments(self):
395        if self.context.special or self.target == 'ictwk':
396            return True
397        return getattr(self.context.__parent__, 'application_fee', None)
398
399    @property
[11736]400    def custom_upload_requirements(self):
401        if not checkPermission('waeup.uploadPassportPictures', self.context):
402            return _('You are not entitled to upload passport pictures.')
[11782]403
[13796]404    @property
[13814]405    def label(self):
406        if self.target == 'ictwk':
407            container_title = self.context.__parent__.title
408            return _('${a} <br /> Registration Record ${b}', mapping = {
409                'a':container_title, 'b':self.context.application_number})
410        return super(CustomApplicantManageFormPage, self).label
411
412    @property
[13796]413    def form_fields(self):
[16164]414        if self.target is not None and self.target == 'tscf':
[16078]415            form_fields = grok.AutoFields(ITranscriptApplicant)
[16131]416            for field in TRANS_OMIT_FIELDS:
417                form_fields = form_fields.omit(field)
[16078]418            return form_fields
[16164]419        if self.target is not None and self.target == 'tscs':
[16131]420            form_fields = grok.AutoFields(ITranscriptApplicant)
421            for field in TRANS_SHORT_OMIT_FIELDS:
422                form_fields = form_fields.omit(field)
423            return form_fields
[13796]424        if self.target == 'ictwk':
[13814]425            form_fields = grok.AutoFields(IUnibenRegistration)
426            for field in REGISTRATION_OMIT_MANAGE_FIELDS:
[13796]427                form_fields = form_fields.omit(field)
[13825]428            state = IWorkflowState(self.context).getState()
429            if state != STARTED:
430                form_fields['registration_cats'].for_display = True
[13814]431            return form_fields
[14105]432        if self.target is not None and self.target.startswith('pg'):
433            form_fields = grok.AutoFields(ICustomPGApplicant)
434            for field in PG_OMIT_MANAGE_FIELDS:
435                form_fields = form_fields.omit(field)
436        elif self.target is not None and self.target.startswith('pre'):
437            form_fields = grok.AutoFields(ICustomPGApplicant)
438            for field in PRE_OMIT_MANAGE_FIELDS:
439                form_fields = form_fields.omit(field)
440        elif self.target is not None and self.target.startswith('cbt'):
441            form_fields = grok.AutoFields(ICustomUGApplicant)
442            for field in CBT_OMIT_MANAGE_FIELDS:
443                form_fields = form_fields.omit(field)
444        elif self.target is not None and self.target.startswith('akj'):
445            form_fields = grok.AutoFields(ICustomPGApplicant)
446            for field in PRE_OMIT_MANAGE_FIELDS:
447                form_fields = form_fields.omit(field)
448        elif self.target is not None and self.target.startswith('ak'):
449            form_fields = grok.AutoFields(ICustomUGApplicant)
450            for field in AFFIL_OMIT_MANAGE_FIELDS:
451                form_fields = form_fields.omit(field)
452        elif self.target is not None and self.target.startswith('ase'): # was putme
453            form_fields = grok.AutoFields(ICustomUGApplicant)
454            for field in PUTME_OMIT_MANAGE_FIELDS:
455                form_fields = form_fields.omit(field)
456        elif self.target is not None and self.target.startswith('pude'):
457            form_fields = grok.AutoFields(ICustomUGApplicant)
458            for field in PUDE_OMIT_MANAGE_FIELDS:
459                form_fields = form_fields.omit(field)
460        else:
461            form_fields = grok.AutoFields(ICustomUGApplicant)
462            for field in UG_OMIT_MANAGE_FIELDS:
463                form_fields = form_fields.omit(field)
464        form_fields['student_id'].for_display = True
465        form_fields['applicant_id'].for_display = True
[13796]466        return form_fields
467
468
469class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
470    """An applicant-centered edit view for applicant data.
471    """
472
[14841]473    def unremovable(self, ticket):
474        return True
475
[13796]476    @property
[13887]477    def display_payments(self):
478        if self.context.special or self.target == 'ictwk':
479            return True
480        return getattr(self.context.__parent__, 'application_fee', None)
481
482    @property
[13796]483    def form_fields(self):
[16164]484        if self.target is not None and self.target == 'tscf':
[16131]485            form_fields = grok.AutoFields(ITranscriptApplicant)
486            for field in TRANS_OMIT_FIELDS:
487                form_fields = form_fields.omit(field)
[16210]488                form_fields = form_fields.omit('locked')
[16078]489            return form_fields
[16164]490        if self.target is not None and self.target == 'tscs':
[16131]491            form_fields = grok.AutoFields(ITranscriptApplicant)
492            for field in TRANS_SHORT_OMIT_FIELDS:
493                form_fields = form_fields.omit(field)
[16210]494                form_fields = form_fields.omit('locked')
[16131]495            return form_fields
[13796]496        if self.target == 'ictwk':
[13814]497            form_fields = grok.AutoFields(IUnibenRegistration)
498            for field in REGISTRATION_OMIT_EDIT_FIELDS:
[13796]499                form_fields = form_fields.omit(field)
[13825]500            state = IWorkflowState(self.context).getState()
501            if state != STARTED:
502                form_fields['registration_cats'].for_display = True
[13814]503            return form_fields
[14105]504        if self.target is not None and self.target.startswith('pg'):
505            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
506            for field in PG_OMIT_EDIT_FIELDS:
507                form_fields = form_fields.omit(field)
508        elif self.target is not None and self.target.startswith('pre'):
509            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
510            for field in PRE_OMIT_EDIT_FIELDS:
511                form_fields = form_fields.omit(field)
512        elif self.target is not None and self.target.startswith('cbt'):
513            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
514            for field in CBT_OMIT_EDIT_FIELDS:
515                form_fields = form_fields.omit(field)
516        elif self.target is not None and self.target.startswith('akj'):
517            form_fields = grok.AutoFields(ICustomPGApplicant)
518            for field in PRE_OMIT_EDIT_FIELDS:
519                form_fields = form_fields.omit(field)
520        elif self.target is not None and self.target.startswith('ak'):
521            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
522            for field in AFFIL_OMIT_EDIT_FIELDS:
523                form_fields = form_fields.omit(field)
524        elif self.target is not None and self.target.startswith('ase'): # was putme
525            form_fields = grok.AutoFields(IPUTMEApplicantEdit)
526            for field in PUTME_OMIT_EDIT_FIELDS:
527                form_fields = form_fields.omit(field)
528        elif self.target is not None and self.target.startswith('pude'):
529            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
530            for field in PUDE_OMIT_EDIT_FIELDS:
531                form_fields = form_fields.omit(field)
532        else:
533            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
534            for field in UG_OMIT_EDIT_FIELDS:
535                form_fields = form_fields.omit(field)
536        form_fields['applicant_id'].for_display = True
537        form_fields['reg_number'].for_display = True
[13796]538        return form_fields
539
[13814]540    @property
541    def label(self):
542        if self.target == 'ictwk':
543            container_title = self.context.__parent__.title
544            return _('${a} <br /> Registration Record ${b}', mapping = {
545                'a':container_title, 'b':self.context.application_number})
546        return super(CustomApplicantEditFormPage, self).label
547
[16164]548    def display_fileupload(self, filename):
549        if filename[1] == 'res_stat.pdf' \
550            and self.target is not None \
551            and not self.target.startswith('tscf'):
552            return False
553        if filename[1] == 'eligibility.pdf' \
554            and self.target is not None \
555            and not self.target.startswith('tsc'):
556            return False
557        return True
558
559    def dataNotComplete(self, data):
560        store = getUtility(IExtFileStore)
[16199]561        if self.context.__parent__.with_picture \
562            and self.context.__parent__.picture_editable:
[16164]563            store = getUtility(IExtFileStore)
564            if not store.getFileByContext(self.context, attr=u'passport.jpg'):
565                return _('No passport picture uploaded.')
566        if self.target is not None \
567            and self.target.startswith('tscf') \
568            and not store.getFileByContext(self.context, attr=u'res_stat.pdf'):
569            return _('No statement of result pdf file uploaded.')
[16178]570        #if self.target is not None \
571        #    and self.target.startswith('tsc') \
572        #    and not store.getFileByContext(self.context, attr=u'eligibility.pdf'):
573        #    return _('No eligibility form pdf file uploaded.')
[16164]574        return False
575
[11782]576class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage):
577    """ Approval view
578    """
579
580    def update(self):
[11784]581        if self.context.p_category == 'admission_checking':
582            if self.context.p_state == 'paid':
583                flashtype = 'warning'
584                msg = _('This ticket has already been paid.')
585                log = None
586            else:
587                self.context.approve()
588                log = 'payment approved: %s' % self.context.p_id
589                msg = _('Payment approved')
590                flashtype = 'success'
591        else:
592            flashtype, msg, log = self.context.approveApplicantPayment()
[11782]593        if log is not None:
594            applicant = self.context.__parent__
595            # Add log message to applicants.log
596            applicant.writeLogMessage(self, log)
597            # Add log message to payments.log
598            self.context.logger.info(
599                '%s,%s,%s,%s,%s,,,,,,' % (
600                applicant.applicant_id,
601                self.context.p_id, self.context.p_category,
602                self.context.amount_auth, self.context.r_code))
603        self.flash(msg, type=flashtype)
604        return
[11784]605
606class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip):
607    """Deliver a PDF slip of the context.
608    """
609
610    def update(self):
611        super(CustomExportPDFPageApplicationSlip, self).update()
612        if self.context.state == ADMITTED and \
613            not self.context.admchecking_fee_paid():
614            self.flash(
615                _('Please pay admission checking fee before trying to download '
616                  'the application slip.'), type='warning')
617            return self.redirect(self.url(self.context))
618        return
[13552]619
[13557]620class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
[13552]621
[13558]622    def _getPDFCreator(self):
[14061]623        if self.target.startswith('ak'):
[13558]624            return getUtility(IPDFCreator, name='akoka_pdfcreator')
625        return getUtility(IPDFCreator)
626
[13552]627    @property
[13814]628    def form_fields(self):
[16184]629        if self.target is not None and self.target == 'tscf':
630            form_fields = grok.AutoFields(ITranscriptApplicant)
631            for field in TRANS_OMIT_FIELDS:
632                form_fields = form_fields.omit(field)
633        elif self.target is not None and self.target == 'tscs':
634            form_fields = grok.AutoFields(ITranscriptApplicant)
635            for field in TRANS_SHORT_OMIT_FIELDS:
636                form_fields = form_fields.omit(field)
637        elif self.target is not None and self.target == 'ictwk':
[13814]638            form_fields = grok.AutoFields(IUnibenRegistration)
639            for field in REGISTRATION_OMIT_PDF_FIELDS:
640                form_fields = form_fields.omit(field)
[16184]641        elif self.target is not None and self.target.startswith('pg'):
[14105]642            form_fields = grok.AutoFields(ICustomPGApplicant)
643            for field in PG_OMIT_PDF_FIELDS:
644                form_fields = form_fields.omit(field)
645        elif self.target is not None and self.target.startswith('pre'):
646            form_fields = grok.AutoFields(ICustomPGApplicant)
647            for field in PRE_OMIT_PDF_FIELDS:
648                form_fields = form_fields.omit(field)
649        elif self.target is not None and self.target.startswith('cbt'): # uniben
650            form_fields = grok.AutoFields(ICustomUGApplicant)
651            for field in CBT_OMIT_PDF_FIELDS:
652                form_fields = form_fields.omit(field)
653        elif self.target is not None and self.target.startswith('akj'): # uniben
654            form_fields = grok.AutoFields(ICustomPGApplicant)
655            for field in PRE_OMIT_PDF_FIELDS:
656                form_fields = form_fields.omit(field)
657        elif self.target is not None and self.target.startswith('ak'): # uniben
658            form_fields = grok.AutoFields(ICustomUGApplicant)
659            for field in AFFIL_OMIT_PDF_FIELDS:
660                form_fields = form_fields.omit(field)
661        elif self.target is not None and self.target.startswith('ase'): # was putme
662            form_fields = grok.AutoFields(ICustomUGApplicant)
663            if self._reduced_slip():
664                for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
665                    form_fields = form_fields.omit(field)
666            else:
667                for field in PUTME_OMIT_PDF_FIELDS:
668                    form_fields = form_fields.omit(field)
669        elif self.target is not None and self.target.startswith('pude'):
670            form_fields = grok.AutoFields(ICustomUGApplicant)
671            if self._reduced_slip():
672                for field in PUDE_OMIT_RESULT_SLIP_FIELDS:
673                    form_fields = form_fields.omit(field)
674            else:
675                for field in PUDE_OMIT_PDF_FIELDS:
676                    form_fields = form_fields.omit(field)
677        else:
678            form_fields = grok.AutoFields(ICustomUGApplicant)
679            for field in UG_OMIT_PDF_FIELDS:
680                form_fields = form_fields.omit(field)
681        if not getattr(self.context, 'student_id'):
682            form_fields = form_fields.omit('student_id')
683        if not getattr(self.context, 'screening_score'):
684            form_fields = form_fields.omit('screening_score')
685        if not getattr(self.context, 'screening_venue'):
686            form_fields = form_fields.omit('screening_venue')
687        if not getattr(self.context, 'screening_date'):
688            form_fields = form_fields.omit('screening_date')
[13814]689        return form_fields
690
691    @property
[13552]692    def title(self):
693        container_title = self.context.__parent__.title
694        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
695        ar_translation = translate(_('Application Record'),
696            'waeup.kofa', target_language=portal_language)
[13814]697        if self.target == 'ictwk':
698            return '%s - Registration Record %s' % (container_title,
699            self.context.application_number)
[14061]700        elif self.target.startswith('ab'):
[13552]701            return 'Federal College of Education (Technical) Asaba - %s %s %s' % (
702                container_title, ar_translation,
703                self.context.application_number)
[14061]704        elif self.target.startswith('ak'):
[14064]705            return 'Federal College of Education (Technical) Akoka - %s - %s %s' % (
[13552]706                container_title, ar_translation,
707                self.context.application_number)
[13615]708        elif self.target == 'pgn':
709            return 'National Institute for Legislative Studies (NILS) - %s %s %s' % (
710                container_title, ar_translation,
711                self.context.application_number)
[13552]712        return '%s - %s %s' % (container_title,
713            ar_translation, self.context.application_number)
[14147]714
715class ExportScreeningInvitationSlip(UtilityView, grok.View):
716    """Deliver a PDF slip of the context.
717    """
718    grok.context(ICustomApplicant)
719    grok.name('screening_invitation_slip.pdf')
720    grok.require('waeup.viewApplication')
721    form_fields = None
[14148]722    label = u'Invitation Letter for Pre-Admission Screening'
[14147]723
724
725    @property
726    def note(self):
[14168]727        notice = getattr(self.context.__parent__, 'application_slip_notice', None)
[14147]728        if self.context.screening_date:
729            return """
730<br /><br /><br /><br /><font size='12'>
731Dear %s,
732<br /><br /><br />
733You are invited for your Uniben Admission Screening Exercise on:
734<br /><br />
735<strong>%s</strong>.
736<br /><br />
[14167]737Please bring along this letter of invitation to the
[14147]738<br /><br />
[14167]739<strong>%s</strong>
740<br /><br />
[14147]741on your screening date.
742<br /><br /><br />
743Signed,
744<br /><br />
745The Registrar<br />
[14168]746<br /><br />
747<br /><br />
748%s
[14147]749</font>
750
[14167]751""" % (self.context.display_fullname, self.context.screening_date,
[14168]752       self.context.screening_venue, notice)
[14147]753        return
754
755    def update(self):
756        if not self.context.screening_date:
757            self.flash(_('Forbidden'), type="warning")
758            self.redirect(self.url(self.context))
759
760    def render(self):
761        applicantview = ApplicantBaseDisplayFormPage(self.context, self.request)
762        students_utils = getUtility(IStudentsUtils)
763        return students_utils.renderPDF(self,'screening_invitation_slip.pdf',
[16117]764            self.context, applicantview, note=self.note)
765
766class CustomCheckTranscriptStatus(CheckTranscriptStatus):
767    """A display page for checking transcript processing status.
768    """
[16119]769    websites = (('Uniben Alumni Portal', 'https://uniben-alumni.waeup.org/'),
770                ('Uniben Student Portal', 'https://uniben.waeup.org/'),)
[16164]771    appl_url1 = 'https://uniben-alumni.waeup.org/applicants/tscf1/register'
772    appl_url2 = 'https://uniben-alumni.waeup.org/applicants/tscs1/register'
773
774class ResultStatement(AdditionalFile):
775    grok.name('res_stat.pdf')
776
777class EligibilityForm(AdditionalFile):
778    grok.name('eligibility.pdf')
Note: See TracBrowser for help on using the repository browser.