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

Last change on this file since 16766 was 16766, checked in by Henrik Bettermann, 3 years ago

Type of order must not be changed after payment was made.

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