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

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

Configure DESTINATION_COST.

  • Property svn:keywords set to Id
File size: 29.3 KB
RevLine 
[8012]1## $Id: browser.py 16144 2020-07-05 21:01:00Z 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    'nationality',
137    'entry_mode',
138    'entry_session',
139    'end_session',
140    'course_studied',
141    'course_changed',
142    'change_level',
143    )
144
[10587]145class CustomApplicantsContainerPage(ApplicantsContainerPage):
146    """The standard view for regular applicant containers.
147    """
148
149    @property
150    def form_fields(self):
151        form_fields = super(CustomApplicantsContainerPage, self).form_fields
[10589]152        usertype = getattr(self.request.principal, 'user_type', None)
153        if self.request.principal.id == 'zope.anybody' or  \
154            usertype in ('applicant', 'student'):
[10587]155            return form_fields.omit('application_fee')
156        return form_fields
157
[8630]158class CustomApplicantRegistrationPage(ApplicantRegistrationPage):
159    """Captcha'd registration page for applicants.
160    """
161
[10337]162    def _redirect(self, email, password, applicant_id):
163        # Forward email and credentials to landing page.
164        self.redirect(self.url(self.context, 'registration_complete',
165            data = dict(email=email, password=password,
166            applicant_id=applicant_id)))
167        return
[10287]168
[10375]169class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
170    """A display view for applicant data.
[10287]171    """
[10375]172    grok.template('applicantdisplaypage')
[10338]173
[13887]174    @property
175    def display_payments(self):
176        if self.context.special or self.target == 'ictwk':
177            return True
178        return getattr(self.context.__parent__, 'application_fee', None)
179
[10622]180    def _show_pastq_putme(self):
[15487]181        return self.target.startswith('pre') \
[14821]182               and self.context.state in ('paid', 'submitted') \
183               and getattr(self.context, 'course1') is not None
184        # return False
[10338]185
186    @property
[14090]187    def depcode(self):
188        try:
189            code = self.context.course1.__parent__.__parent__.code
190            return code
191        except:
192            return
193
194    @property
[10338]195    def show_pastq_al(self):
[15486]196        return self._show_pastq_putme() # and self.depcode in PASTQ_AL
[10338]197
198    @property
199    def show_pastq_bs(self):
[15486]200        return self._show_pastq_putme() # and self.depcode in PASTQ_BS
[10338]201
202    @property
203    def show_pastq_eps(self):
[15486]204        return self._show_pastq_putme() # and self.depcode in PASTQ_EPS
[10338]205
206    @property
207    def show_pastq_mss(self):
[15486]208        return self._show_pastq_putme() # and self.depcode in PASTQ_MSS
[10338]209
[10622]210    @property
211    def show_pastq_pude(self):
212        return self.target.startswith('pude') \
213               and self.context.state in ('paid', 'submitted')
214
[13814]215    @property
216    def label(self):
217        if self.target == 'ictwk':
218            container_title = self.context.__parent__.title
219            return _('${a} <br /> Registration Record ${b}', mapping = {
220                'a':container_title, 'b':self.context.application_number})
221        return super(CustomApplicantDisplayFormPage, self).label
[11784]222
[11782]223    @property
224    def form_fields(self):
[16131]225        if self.target is not None and self.target == 'transfull':
226            form_fields = grok.AutoFields(ITranscriptApplicant)
227            for field in TRANS_OMIT_FIELDS:
228                form_fields = form_fields.omit(field)
[16078]229            form_fields['dispatch_address'].custom_widget = BytesDisplayWidget
230            form_fields['perm_address'].custom_widget = BytesDisplayWidget
231            return form_fields
[16131]232        if self.target is not None and self.target == 'transshort':
233            form_fields = grok.AutoFields(ITranscriptApplicant)
234            for field in TRANS_SHORT_OMIT_FIELDS:
235                form_fields = form_fields.omit(field)
236            form_fields['dispatch_address'].custom_widget = BytesDisplayWidget
237            form_fields['perm_address'].custom_widget = BytesDisplayWidget
238            return form_fields
[13796]239        if self.target == 'ictwk':
[13814]240            form_fields = grok.AutoFields(IUnibenRegistration)
241            for field in REGISTRATION_OMIT_DISPLAY_FIELDS:
[13796]242                form_fields = form_fields.omit(field)
243            return form_fields
[14105]244        elif self.target is not None and self.target.startswith('pg'):
245            form_fields = grok.AutoFields(ICustomPGApplicant)
246            for field in PG_OMIT_DISPLAY_FIELDS:
247                form_fields = form_fields.omit(field)
248        elif self.target is not None and self.target.startswith('pre'):
249            form_fields = grok.AutoFields(ICustomPGApplicant)
250            for field in PRE_OMIT_DISPLAY_FIELDS:
251                form_fields = form_fields.omit(field)
252        elif self.target is not None and self.target.startswith('cbt'):
253            form_fields = grok.AutoFields(ICustomUGApplicant)
254            for field in CBT_OMIT_DISPLAY_FIELDS:
255                form_fields = form_fields.omit(field)
256        elif self.target is not None and self.target.startswith('akj'):
257            form_fields = grok.AutoFields(ICustomPGApplicant)
258            for field in PRE_OMIT_DISPLAY_FIELDS:
259                form_fields = form_fields.omit(field)
260        elif self.target is not None and self.target.startswith('ak'):
261            form_fields = grok.AutoFields(ICustomUGApplicant)
262            for field in AFFIL_OMIT_DISPLAY_FIELDS:
263                form_fields = form_fields.omit(field)
264        elif self.target is not None and self.target.startswith('ase'): # was putme
265            form_fields = grok.AutoFields(ICustomUGApplicant)
266            for field in PUTME_OMIT_DISPLAY_FIELDS:
267                form_fields = form_fields.omit(field)
268        elif self.target is not None and self.target.startswith('pude'):
269            form_fields = grok.AutoFields(ICustomUGApplicant)
270            for field in PUDE_OMIT_DISPLAY_FIELDS:
271                form_fields = form_fields.omit(field)
272        else:
273            form_fields = grok.AutoFields(ICustomUGApplicant)
274            for field in UG_OMIT_DISPLAY_FIELDS:
275                form_fields = form_fields.omit(field)
276        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
277        form_fields['notice'].custom_widget = BytesDisplayWidget
278        if not getattr(self.context, 'student_id'):
279            form_fields = form_fields.omit('student_id')
280        if not getattr(self.context, 'screening_score'):
281            form_fields = form_fields.omit('screening_score')
282        if not getattr(self.context, 'screening_venue') or self._not_paid():
283            form_fields = form_fields.omit('screening_venue')
284        if not getattr(self.context, 'screening_date') or self._not_paid():
285            form_fields = form_fields.omit('screening_date')
[11784]286        if not self.context.admchecking_fee_paid():
287            form_fields = form_fields.omit(
288                'screening_score', 'aggregate', 'student_id')
[11782]289        return form_fields
290
[11784]291    @property
292    def display_actions(self):
293        state = IWorkflowState(self.context).getState()
294        actions = []
295        if state == ADMITTED and not self.context.admchecking_fee_paid():
296            actions = [_('Add admission checking payment ticket')]
297        return actions
298
299
300    def getCourseAdmitted(self):
301        """Return link, title and code in html format to the certificate
302           admitted.
303        """
[15125]304        if self.admission_checking_info:
305            return '<span class="hint">%s</span>' % self.admission_checking_info
306        return super(CustomApplicantDisplayFormPage, self).getCourseAdmitted()
[11784]307
[11786]308    @property
309    def admission_checking_info(self):
310        if self.context.state == ADMITTED and \
311            not self.context.admchecking_fee_paid():
312            return _('You must pay the admission checking fee '
[15125]313                     'to view your screening results and your course admitted.')
[11786]314        return
315
[11784]316    @action(_('Add admission checking payment ticket'), style='primary')
317    def addPaymentTicket(self, **data):
318        self.redirect(self.url(self.context, '@@addacp'))
319        return
320
[11728]321class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
322    """ Page to add an online payment ticket
323    """
[10378]324
[11728]325    @property
326    def custom_requirements(self):
[15506]327        if self.context.__parent__.with_picture:
328            store = getUtility(IExtFileStore)
329            if not store.getFileByContext(self.context, attr=u'passport.jpg'):
330                return _('Upload your 1"x1" Red background passport photo before making payment.')
[11728]331        return ''
332
[11784]333class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View):
334    """ Page to add an admission checking online payment ticket.
335    """
336    grok.context(ICustomApplicant)
337    grok.name('addacp')
338    grok.require('waeup.payApplicant')
339    factory = u'waeup.ApplicantOnlinePayment'
340
341    def _setPaymentDetails(self, payment):
342        container = self.context.__parent__
343        timestamp = ("%d" % int(time()*10000))[1:]
344        session = str(container.year)
345        try:
346            session_config = grok.getSite()['configuration'][session]
347        except KeyError:
348            return _(u'Session configuration object is not available.'), None
349        payment.p_id = "p%s" % timestamp
350        payment.p_item = container.title
351        payment.p_session = container.year
352        payment.amount_auth = 0.0
353        payment.p_category = 'admission_checking'
354        payment.amount_auth = session_config.admchecking_fee
355        if payment.amount_auth in (0.0, None):
356            return _('Amount could not be determined.'), None
357        return
358
[11782]359    def update(self):
[11784]360        if self.context.admchecking_fee_paid():
361              self.flash(
362                  _('Admission checking payment has already been made.'),
363                  type='warning')
364              self.redirect(self.url(self.context))
365              return
[11782]366        payment = createObject(self.factory)
[11784]367        failure = self._setPaymentDetails(payment)
[11782]368        if failure is not None:
369            self.flash(failure[0], type='danger')
370            self.redirect(self.url(self.context))
371            return
372        self.context[payment.p_id] = payment
373        self.flash(_('Payment ticket created.'))
374        self.redirect(self.url(payment))
375        return
[11736]376
[11784]377    def render(self):
378        return
[11736]379
[11784]380
[11782]381class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
382
[11736]383    @property
[13887]384    def display_payments(self):
385        if self.context.special or self.target == 'ictwk':
386            return True
387        return getattr(self.context.__parent__, 'application_fee', None)
388
389    @property
[11736]390    def custom_upload_requirements(self):
391        if not checkPermission('waeup.uploadPassportPictures', self.context):
392            return _('You are not entitled to upload passport pictures.')
[11782]393
[13796]394    @property
[13814]395    def label(self):
396        if self.target == 'ictwk':
397            container_title = self.context.__parent__.title
398            return _('${a} <br /> Registration Record ${b}', mapping = {
399                'a':container_title, 'b':self.context.application_number})
400        return super(CustomApplicantManageFormPage, self).label
401
402    @property
[13796]403    def form_fields(self):
[16131]404        if self.target is not None and self.target == 'transfull':
[16078]405            form_fields = grok.AutoFields(ITranscriptApplicant)
[16131]406            for field in TRANS_OMIT_FIELDS:
407                form_fields = form_fields.omit(field)
[16078]408            return form_fields
[16131]409        if self.target is not None and self.target == 'transshort':
410            form_fields = grok.AutoFields(ITranscriptApplicant)
411            for field in TRANS_SHORT_OMIT_FIELDS:
412                form_fields = form_fields.omit(field)
413            return form_fields
[13796]414        if self.target == 'ictwk':
[13814]415            form_fields = grok.AutoFields(IUnibenRegistration)
416            for field in REGISTRATION_OMIT_MANAGE_FIELDS:
[13796]417                form_fields = form_fields.omit(field)
[13825]418            state = IWorkflowState(self.context).getState()
419            if state != STARTED:
420                form_fields['registration_cats'].for_display = True
[13814]421            return form_fields
[14105]422        if self.target is not None and self.target.startswith('pg'):
423            form_fields = grok.AutoFields(ICustomPGApplicant)
424            for field in PG_OMIT_MANAGE_FIELDS:
425                form_fields = form_fields.omit(field)
426        elif self.target is not None and self.target.startswith('pre'):
427            form_fields = grok.AutoFields(ICustomPGApplicant)
428            for field in PRE_OMIT_MANAGE_FIELDS:
429                form_fields = form_fields.omit(field)
430        elif self.target is not None and self.target.startswith('cbt'):
431            form_fields = grok.AutoFields(ICustomUGApplicant)
432            for field in CBT_OMIT_MANAGE_FIELDS:
433                form_fields = form_fields.omit(field)
434        elif self.target is not None and self.target.startswith('akj'):
435            form_fields = grok.AutoFields(ICustomPGApplicant)
436            for field in PRE_OMIT_MANAGE_FIELDS:
437                form_fields = form_fields.omit(field)
438        elif self.target is not None and self.target.startswith('ak'):
439            form_fields = grok.AutoFields(ICustomUGApplicant)
440            for field in AFFIL_OMIT_MANAGE_FIELDS:
441                form_fields = form_fields.omit(field)
442        elif self.target is not None and self.target.startswith('ase'): # was putme
443            form_fields = grok.AutoFields(ICustomUGApplicant)
444            for field in PUTME_OMIT_MANAGE_FIELDS:
445                form_fields = form_fields.omit(field)
446        elif self.target is not None and self.target.startswith('pude'):
447            form_fields = grok.AutoFields(ICustomUGApplicant)
448            for field in PUDE_OMIT_MANAGE_FIELDS:
449                form_fields = form_fields.omit(field)
450        else:
451            form_fields = grok.AutoFields(ICustomUGApplicant)
452            for field in UG_OMIT_MANAGE_FIELDS:
453                form_fields = form_fields.omit(field)
454        form_fields['student_id'].for_display = True
455        form_fields['applicant_id'].for_display = True
[13796]456        return form_fields
457
458
459class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
460    """An applicant-centered edit view for applicant data.
461    """
462
[14841]463    def unremovable(self, ticket):
464        return True
465
[13796]466    @property
[13887]467    def display_payments(self):
468        if self.context.special or self.target == 'ictwk':
469            return True
470        return getattr(self.context.__parent__, 'application_fee', None)
471
472    @property
[13796]473    def form_fields(self):
[16131]474        if self.target is not None and self.target == 'transfull':
475            form_fields = grok.AutoFields(ITranscriptApplicant)
476            for field in TRANS_OMIT_FIELDS:
477                form_fields = form_fields.omit(field)
[16078]478            return form_fields
[16131]479        if self.target is not None and self.target == 'transshort':
480            form_fields = grok.AutoFields(ITranscriptApplicant)
481            for field in TRANS_SHORT_OMIT_FIELDS:
482                form_fields = form_fields.omit(field)
483            return form_fields
[13796]484        if self.target == 'ictwk':
[13814]485            form_fields = grok.AutoFields(IUnibenRegistration)
486            for field in REGISTRATION_OMIT_EDIT_FIELDS:
[13796]487                form_fields = form_fields.omit(field)
[13825]488            state = IWorkflowState(self.context).getState()
489            if state != STARTED:
490                form_fields['registration_cats'].for_display = True
[13814]491            return form_fields
[14105]492        if self.target is not None and self.target.startswith('pg'):
493            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
494            for field in PG_OMIT_EDIT_FIELDS:
495                form_fields = form_fields.omit(field)
496        elif self.target is not None and self.target.startswith('pre'):
497            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
498            for field in PRE_OMIT_EDIT_FIELDS:
499                form_fields = form_fields.omit(field)
500        elif self.target is not None and self.target.startswith('cbt'):
501            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
502            for field in CBT_OMIT_EDIT_FIELDS:
503                form_fields = form_fields.omit(field)
504        elif self.target is not None and self.target.startswith('akj'):
505            form_fields = grok.AutoFields(ICustomPGApplicant)
506            for field in PRE_OMIT_EDIT_FIELDS:
507                form_fields = form_fields.omit(field)
508        elif self.target is not None and self.target.startswith('ak'):
509            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
510            for field in AFFIL_OMIT_EDIT_FIELDS:
511                form_fields = form_fields.omit(field)
512        elif self.target is not None and self.target.startswith('ase'): # was putme
513            form_fields = grok.AutoFields(IPUTMEApplicantEdit)
514            for field in PUTME_OMIT_EDIT_FIELDS:
515                form_fields = form_fields.omit(field)
516        elif self.target is not None and self.target.startswith('pude'):
517            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
518            for field in PUDE_OMIT_EDIT_FIELDS:
519                form_fields = form_fields.omit(field)
520        else:
521            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
522            for field in UG_OMIT_EDIT_FIELDS:
523                form_fields = form_fields.omit(field)
524        form_fields['applicant_id'].for_display = True
525        form_fields['reg_number'].for_display = True
[13796]526        return form_fields
527
[13814]528    @property
529    def label(self):
530        if self.target == 'ictwk':
531            container_title = self.context.__parent__.title
532            return _('${a} <br /> Registration Record ${b}', mapping = {
533                'a':container_title, 'b':self.context.application_number})
534        return super(CustomApplicantEditFormPage, self).label
535
[11782]536class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage):
537    """ Approval view
538    """
539
540    def update(self):
[11784]541        if self.context.p_category == 'admission_checking':
542            if self.context.p_state == 'paid':
543                flashtype = 'warning'
544                msg = _('This ticket has already been paid.')
545                log = None
546            else:
547                self.context.approve()
548                log = 'payment approved: %s' % self.context.p_id
549                msg = _('Payment approved')
550                flashtype = 'success'
551        else:
552            flashtype, msg, log = self.context.approveApplicantPayment()
[11782]553        if log is not None:
554            applicant = self.context.__parent__
555            # Add log message to applicants.log
556            applicant.writeLogMessage(self, log)
557            # Add log message to payments.log
558            self.context.logger.info(
559                '%s,%s,%s,%s,%s,,,,,,' % (
560                applicant.applicant_id,
561                self.context.p_id, self.context.p_category,
562                self.context.amount_auth, self.context.r_code))
563        self.flash(msg, type=flashtype)
564        return
[11784]565
566class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip):
567    """Deliver a PDF slip of the context.
568    """
569
570    def update(self):
571        super(CustomExportPDFPageApplicationSlip, self).update()
572        if self.context.state == ADMITTED and \
573            not self.context.admchecking_fee_paid():
574            self.flash(
575                _('Please pay admission checking fee before trying to download '
576                  'the application slip.'), type='warning')
577            return self.redirect(self.url(self.context))
578        return
[13552]579
[13557]580class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
[13552]581
[13558]582    def _getPDFCreator(self):
[14061]583        if self.target.startswith('ak'):
[13558]584            return getUtility(IPDFCreator, name='akoka_pdfcreator')
585        return getUtility(IPDFCreator)
586
[13552]587    @property
[13814]588    def form_fields(self):
589        if self.target == 'ictwk':
590            form_fields = grok.AutoFields(IUnibenRegistration)
591            for field in REGISTRATION_OMIT_PDF_FIELDS:
592                form_fields = form_fields.omit(field)
593            return form_fields
[14105]594        if self.target is not None and self.target.startswith('pg'):
595            form_fields = grok.AutoFields(ICustomPGApplicant)
596            for field in PG_OMIT_PDF_FIELDS:
597                form_fields = form_fields.omit(field)
598        elif self.target is not None and self.target.startswith('pre'):
599            form_fields = grok.AutoFields(ICustomPGApplicant)
600            for field in PRE_OMIT_PDF_FIELDS:
601                form_fields = form_fields.omit(field)
602        elif self.target is not None and self.target.startswith('cbt'): # uniben
603            form_fields = grok.AutoFields(ICustomUGApplicant)
604            for field in CBT_OMIT_PDF_FIELDS:
605                form_fields = form_fields.omit(field)
606        elif self.target is not None and self.target.startswith('akj'): # uniben
607            form_fields = grok.AutoFields(ICustomPGApplicant)
608            for field in PRE_OMIT_PDF_FIELDS:
609                form_fields = form_fields.omit(field)
610        elif self.target is not None and self.target.startswith('ak'): # uniben
611            form_fields = grok.AutoFields(ICustomUGApplicant)
612            for field in AFFIL_OMIT_PDF_FIELDS:
613                form_fields = form_fields.omit(field)
614        elif self.target is not None and self.target.startswith('ase'): # was putme
615            form_fields = grok.AutoFields(ICustomUGApplicant)
616            if self._reduced_slip():
617                for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
618                    form_fields = form_fields.omit(field)
619            else:
620                for field in PUTME_OMIT_PDF_FIELDS:
621                    form_fields = form_fields.omit(field)
622        elif self.target is not None and self.target.startswith('pude'):
623            form_fields = grok.AutoFields(ICustomUGApplicant)
624            if self._reduced_slip():
625                for field in PUDE_OMIT_RESULT_SLIP_FIELDS:
626                    form_fields = form_fields.omit(field)
627            else:
628                for field in PUDE_OMIT_PDF_FIELDS:
629                    form_fields = form_fields.omit(field)
630        else:
631            form_fields = grok.AutoFields(ICustomUGApplicant)
632            for field in UG_OMIT_PDF_FIELDS:
633                form_fields = form_fields.omit(field)
634        if not getattr(self.context, 'student_id'):
635            form_fields = form_fields.omit('student_id')
636        if not getattr(self.context, 'screening_score'):
637            form_fields = form_fields.omit('screening_score')
638        if not getattr(self.context, 'screening_venue'):
639            form_fields = form_fields.omit('screening_venue')
640        if not getattr(self.context, 'screening_date'):
641            form_fields = form_fields.omit('screening_date')
[13814]642        return form_fields
643
644    @property
[13552]645    def title(self):
646        container_title = self.context.__parent__.title
647        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
648        ar_translation = translate(_('Application Record'),
649            'waeup.kofa', target_language=portal_language)
[13814]650        if self.target == 'ictwk':
651            return '%s - Registration Record %s' % (container_title,
652            self.context.application_number)
[14061]653        elif self.target.startswith('ab'):
[13552]654            return 'Federal College of Education (Technical) Asaba - %s %s %s' % (
655                container_title, ar_translation,
656                self.context.application_number)
[14061]657        elif self.target.startswith('ak'):
[14064]658            return 'Federal College of Education (Technical) Akoka - %s - %s %s' % (
[13552]659                container_title, ar_translation,
660                self.context.application_number)
[13615]661        elif self.target == 'pgn':
662            return 'National Institute for Legislative Studies (NILS) - %s %s %s' % (
663                container_title, ar_translation,
664                self.context.application_number)
[13552]665        return '%s - %s %s' % (container_title,
666            ar_translation, self.context.application_number)
[14147]667
668class ExportScreeningInvitationSlip(UtilityView, grok.View):
669    """Deliver a PDF slip of the context.
670    """
671    grok.context(ICustomApplicant)
672    grok.name('screening_invitation_slip.pdf')
673    grok.require('waeup.viewApplication')
674    form_fields = None
[14148]675    label = u'Invitation Letter for Pre-Admission Screening'
[14147]676
677
678    @property
679    def note(self):
[14168]680        notice = getattr(self.context.__parent__, 'application_slip_notice', None)
[14147]681        if self.context.screening_date:
682            return """
683<br /><br /><br /><br /><font size='12'>
684Dear %s,
685<br /><br /><br />
686You are invited for your Uniben Admission Screening Exercise on:
687<br /><br />
688<strong>%s</strong>.
689<br /><br />
[14167]690Please bring along this letter of invitation to the
[14147]691<br /><br />
[14167]692<strong>%s</strong>
693<br /><br />
[14147]694on your screening date.
695<br /><br /><br />
696Signed,
697<br /><br />
698The Registrar<br />
[14168]699<br /><br />
700<br /><br />
701%s
[14147]702</font>
703
[14167]704""" % (self.context.display_fullname, self.context.screening_date,
[14168]705       self.context.screening_venue, notice)
[14147]706        return
707
708    def update(self):
709        if not self.context.screening_date:
710            self.flash(_('Forbidden'), type="warning")
711            self.redirect(self.url(self.context))
712
713    def render(self):
714        applicantview = ApplicantBaseDisplayFormPage(self.context, self.request)
715        students_utils = getUtility(IStudentsUtils)
716        return students_utils.renderPDF(self,'screening_invitation_slip.pdf',
[16117]717            self.context, applicantview, note=self.note)
718
719class CustomCheckTranscriptStatus(CheckTranscriptStatus):
720    """A display page for checking transcript processing status.
721    """
[16119]722    websites = (('Uniben Alumni Portal', 'https://uniben-alumni.waeup.org/'),
723                ('Uniben Student Portal', 'https://uniben.waeup.org/'),)
[16131]724    appl_url1 = 'https://uniben-alumni.waeup.org/applicants/transfull1/register'
725    appl_url2 = 'https://uniben-alumni.waeup.org/applicants/transshort1/register'
Note: See TracBrowser for help on using the repository browser.