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

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

Enable graduated student record creation from transcript application data.

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