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

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

Show res_stat upload button also to tscf applicants.

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