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

Last change on this file since 16140 was 16131, checked in by Henrik Bettermann, 5 years ago

Configure transcript applications.

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