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

Last change on this file since 14141 was 14141, checked in by Henrik Bettermann, 8 years ago

Add first and second sitting fields to UG interfaces.

  • Property svn:keywords set to Id
File size: 25.0 KB
RevLine 
[8012]1## $Id: browser.py 14141 2016-09-01 03:58:57Z 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,
33    ExportPDFPageApplicationSlip)
[11782]34from waeup.kofa.applicants.interfaces import (
35    ISpecialApplicant, IApplicantsUtils)
[13558]36from waeup.kofa.browser.interfaces import IPDFCreator
[10378]37from kofacustom.nigeria.applicants.browser import (
38    NigeriaApplicantDisplayFormPage,
[11736]39    NigeriaApplicantManageFormPage,
[13796]40    NigeriaApplicantEditFormPage,
[10378]41    NigeriaPDFApplicationSlip)
[11782]42from waeup.uniben.applicants.interfaces import (
[14105]43    ICustomApplicant,
44    IUnibenRegistration,
45    ICustomUGApplicant,
46    ICustomPGApplicant,
47    ICustomPGApplicantEdit,
48    ICustomUGApplicantEdit,
49    IPUTMEApplicantEdit)
[13825]50from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED
[14105]51from kofacustom.nigeria.applicants.interfaces import (
52    UG_OMIT_DISPLAY_FIELDS,
53    UG_OMIT_PDF_FIELDS,
54    UG_OMIT_MANAGE_FIELDS,
55    UG_OMIT_EDIT_FIELDS,
56    CBT_OMIT_DISPLAY_FIELDS,
57    CBT_OMIT_PDF_FIELDS,
58    CBT_OMIT_MANAGE_FIELDS,
59    CBT_OMIT_EDIT_FIELDS,
60    AFFIL_OMIT_DISPLAY_FIELDS,
61    AFFIL_OMIT_PDF_FIELDS,
62    AFFIL_OMIT_MANAGE_FIELDS,
63    AFFIL_OMIT_EDIT_FIELDS,
64    PG_OMIT_DISPLAY_FIELDS,
65    PG_OMIT_PDF_FIELDS,
66    PG_OMIT_MANAGE_FIELDS,
67    PG_OMIT_EDIT_FIELDS,
68    PUTME_OMIT_DISPLAY_FIELDS,
69    PUTME_OMIT_PDF_FIELDS,
70    PUTME_OMIT_MANAGE_FIELDS,
71    PUTME_OMIT_EDIT_FIELDS,
72    PUTME_OMIT_RESULT_SLIP_FIELDS,
73    PUDE_OMIT_DISPLAY_FIELDS,
74    PUDE_OMIT_PDF_FIELDS,
75    PUDE_OMIT_MANAGE_FIELDS,
76    PUDE_OMIT_EDIT_FIELDS,
77    PUDE_OMIT_RESULT_SLIP_FIELDS,
78    PRE_OMIT_DISPLAY_FIELDS,
79    PRE_OMIT_PDF_FIELDS,
80    PRE_OMIT_MANAGE_FIELDS,
81    PRE_OMIT_EDIT_FIELDS,
82    )
[8012]83
[10378]84from waeup.uniben.interfaces import MessageFactory as _
85
[10338]86PASTQ_ALL = ['ADT','EPCS','ESM','HEK','VTE']
[8012]87
[10338]88PASTQ_AL = ['ENL','FAA','FOL','HIS','LAL',
89            'PHL','THR','BUL','JIL','LAW','PPL','PUL'] + PASTQ_ALL
90
91PASTQ_BS = ['ANT','ANY','CHH','COH','HAE','MED','MEH','PHS','SUR',
92            'PCG','PCH','PCO', 'PCT','PHA','PHM','PMB','ANA','MBC',
93            'MLS','NSC','PSY','DPV','ODR','OSP','PER', 'RES','AEB',
94            'BCH','BOT','CED','EVL','MCB','OPT','PBB','SLT','ZOO',
95            'AEE','ANS', 'CRS','FIS','FOW','SOS'] + PASTQ_ALL
96
97PASTQ_EPS = ['CHE','CVE','DMIC','EEE','MCH','PEE','PRE','CHM',
98             'CSC','GLY','MTH','PHY'] + PASTQ_ALL
99
100PASTQ_MSS = ['ACC','BNK','BUS','ECO','GEO','POL','SAA','SWK'] + PASTQ_ALL
101
[13814]102REGISTRATION_OMIT_DISPLAY_FIELDS = (
103    'locked',
104    'suspended',
[13796]105    )
106
[13814]107REGISTRATION_OMIT_EDIT_FIELDS = (
108    'locked',
109    'suspended',
110    'applicant_id',
111    )
112
113REGISTRATION_OMIT_MANAGE_FIELDS = (
114    'applicant_id',
115    )
116
117
118REGISTRATION_OMIT_PDF_FIELDS = (
119    'locked',
120    'suspended',
121    )
[10587]122class CustomApplicantsContainerPage(ApplicantsContainerPage):
123    """The standard view for regular applicant containers.
124    """
125
126    @property
127    def form_fields(self):
128        form_fields = super(CustomApplicantsContainerPage, self).form_fields
[10589]129        usertype = getattr(self.request.principal, 'user_type', None)
130        if self.request.principal.id == 'zope.anybody' or  \
131            usertype in ('applicant', 'student'):
[10587]132            return form_fields.omit('application_fee')
133        return form_fields
134
[8630]135class CustomApplicantRegistrationPage(ApplicantRegistrationPage):
136    """Captcha'd registration page for applicants.
137    """
138
[10337]139    def _redirect(self, email, password, applicant_id):
140        # Forward email and credentials to landing page.
141        self.redirect(self.url(self.context, 'registration_complete',
142            data = dict(email=email, password=password,
143            applicant_id=applicant_id)))
144        return
[10287]145
[10375]146class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
147    """A display view for applicant data.
[10287]148    """
[10375]149    grok.template('applicantdisplaypage')
[10338]150
[13887]151    @property
152    def display_payments(self):
153        if self.context.special or self.target == 'ictwk':
154            return True
155        return getattr(self.context.__parent__, 'application_fee', None)
156
[10622]157    def _show_pastq_putme(self):
[14141]158        #return self.target.startswith('ase') \
159        #       and self.context.state in ('paid', 'submitted') \
160        #       and getattr(self.context, 'course1') is not None
161        return False
[10338]162
163    @property
[14090]164    def depcode(self):
165        try:
166            code = self.context.course1.__parent__.__parent__.code
167            return code
168        except:
169            return
170
171    @property
[10338]172    def show_pastq_al(self):
[14090]173        return self._show_pastq_putme() and self.depcode in PASTQ_AL
[10338]174
175    @property
176    def show_pastq_bs(self):
[14090]177        return self._show_pastq_putme() and self.depcode in PASTQ_BS
[10338]178
179    @property
180    def show_pastq_eps(self):
[14090]181        return self._show_pastq_putme() and self.depcode in PASTQ_EPS
[10338]182
183    @property
184    def show_pastq_mss(self):
[14090]185        return self._show_pastq_putme() and self.depcode in PASTQ_MSS
[10338]186
[10622]187    @property
188    def show_pastq_pude(self):
189        return self.target.startswith('pude') \
190               and self.context.state in ('paid', 'submitted')
191
[13814]192    @property
193    def label(self):
194        if self.target == 'ictwk':
195            container_title = self.context.__parent__.title
196            return _('${a} <br /> Registration Record ${b}', mapping = {
197                'a':container_title, 'b':self.context.application_number})
198        return super(CustomApplicantDisplayFormPage, self).label
[11784]199
[11782]200    @property
201    def form_fields(self):
[13796]202        if self.target == 'ictwk':
[13814]203            form_fields = grok.AutoFields(IUnibenRegistration)
204            for field in REGISTRATION_OMIT_DISPLAY_FIELDS:
[13796]205                form_fields = form_fields.omit(field)
206            return form_fields
[14105]207        elif self.target is not None and self.target.startswith('pg'):
208            form_fields = grok.AutoFields(ICustomPGApplicant)
209            for field in PG_OMIT_DISPLAY_FIELDS:
210                form_fields = form_fields.omit(field)
211        elif self.target is not None and self.target.startswith('pre'):
212            form_fields = grok.AutoFields(ICustomPGApplicant)
213            for field in PRE_OMIT_DISPLAY_FIELDS:
214                form_fields = form_fields.omit(field)
215        elif self.target is not None and self.target.startswith('cbt'):
216            form_fields = grok.AutoFields(ICustomUGApplicant)
217            for field in CBT_OMIT_DISPLAY_FIELDS:
218                form_fields = form_fields.omit(field)
219        elif self.target is not None and self.target.startswith('akj'):
220            form_fields = grok.AutoFields(ICustomPGApplicant)
221            for field in PRE_OMIT_DISPLAY_FIELDS:
222                form_fields = form_fields.omit(field)
223        elif self.target is not None and self.target.startswith('ak'):
224            form_fields = grok.AutoFields(ICustomUGApplicant)
225            for field in AFFIL_OMIT_DISPLAY_FIELDS:
226                form_fields = form_fields.omit(field)
227        elif self.target is not None and self.target.startswith('ase'): # was putme
228            form_fields = grok.AutoFields(ICustomUGApplicant)
229            for field in PUTME_OMIT_DISPLAY_FIELDS:
230                form_fields = form_fields.omit(field)
231        elif self.target is not None and self.target.startswith('pude'):
232            form_fields = grok.AutoFields(ICustomUGApplicant)
233            for field in PUDE_OMIT_DISPLAY_FIELDS:
234                form_fields = form_fields.omit(field)
235        else:
236            form_fields = grok.AutoFields(ICustomUGApplicant)
237            for field in UG_OMIT_DISPLAY_FIELDS:
238                form_fields = form_fields.omit(field)
239        #form_fields['perm_address'].custom_widget = BytesDisplayWidget
240        form_fields['notice'].custom_widget = BytesDisplayWidget
241        if not getattr(self.context, 'student_id'):
242            form_fields = form_fields.omit('student_id')
243        if not getattr(self.context, 'screening_score'):
244            form_fields = form_fields.omit('screening_score')
245        if not getattr(self.context, 'screening_venue') or self._not_paid():
246            form_fields = form_fields.omit('screening_venue')
247        if not getattr(self.context, 'screening_date') or self._not_paid():
248            form_fields = form_fields.omit('screening_date')
[11784]249        if not self.context.admchecking_fee_paid():
250            form_fields = form_fields.omit(
251                'screening_score', 'aggregate', 'student_id')
[11782]252        return form_fields
253
[11784]254    @property
255    def display_actions(self):
256        state = IWorkflowState(self.context).getState()
257        actions = []
258        if state == ADMITTED and not self.context.admchecking_fee_paid():
259            actions = [_('Add admission checking payment ticket')]
260        return actions
261
262
263    def getCourseAdmitted(self):
264        """Return link, title and code in html format to the certificate
265           admitted.
266        """
267        course_admitted = self.context.course_admitted
268        if getattr(course_admitted, '__parent__',None) and \
269            self.context.admchecking_fee_paid():
270            url = self.url(course_admitted)
271            title = course_admitted.title
272            code = course_admitted.code
273            return '<a href="%s">%s - %s</a>' %(url,code,title)
274        return ''
275
[11786]276    @property
277    def admission_checking_info(self):
278        if self.context.state == ADMITTED and \
279            not self.context.admchecking_fee_paid():
280            return _('You must pay the admission checking fee '
281                     'to view your screening results and course admitted.')
282        return
283
[11784]284    @action(_('Add admission checking payment ticket'), style='primary')
285    def addPaymentTicket(self, **data):
286        self.redirect(self.url(self.context, '@@addacp'))
287        return
288
[11728]289class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
290    """ Page to add an online payment ticket
291    """
[10378]292
[11728]293    @property
294    def custom_requirements(self):
295        store = getUtility(IExtFileStore)
296        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
[11782]297            return _('Upload your 1"x1" Red background passport photo before making payment.')
[11728]298        return ''
299
[11784]300class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View):
301    """ Page to add an admission checking online payment ticket.
302    """
303    grok.context(ICustomApplicant)
304    grok.name('addacp')
305    grok.require('waeup.payApplicant')
306    factory = u'waeup.ApplicantOnlinePayment'
307
308    def _setPaymentDetails(self, payment):
309        container = self.context.__parent__
310        timestamp = ("%d" % int(time()*10000))[1:]
311        session = str(container.year)
312        try:
313            session_config = grok.getSite()['configuration'][session]
314        except KeyError:
315            return _(u'Session configuration object is not available.'), None
316        payment.p_id = "p%s" % timestamp
317        payment.p_item = container.title
318        payment.p_session = container.year
319        payment.amount_auth = 0.0
320        payment.p_category = 'admission_checking'
321        payment.amount_auth = session_config.admchecking_fee
322        if payment.amount_auth in (0.0, None):
323            return _('Amount could not be determined.'), None
324        return
325
[11782]326    def update(self):
[11784]327        if self.context.admchecking_fee_paid():
328              self.flash(
329                  _('Admission checking payment has already been made.'),
330                  type='warning')
331              self.redirect(self.url(self.context))
332              return
[11782]333        payment = createObject(self.factory)
[11784]334        failure = self._setPaymentDetails(payment)
[11782]335        if failure is not None:
336            self.flash(failure[0], type='danger')
337            self.redirect(self.url(self.context))
338            return
339        self.context[payment.p_id] = payment
340        self.flash(_('Payment ticket created.'))
341        self.redirect(self.url(payment))
342        return
[11736]343
[11784]344    def render(self):
345        return
[11736]346
[11784]347
[11782]348class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
349
[11736]350    @property
[13887]351    def display_payments(self):
352        if self.context.special or self.target == 'ictwk':
353            return True
354        return getattr(self.context.__parent__, 'application_fee', None)
355
356    @property
[11736]357    def custom_upload_requirements(self):
358        if not checkPermission('waeup.uploadPassportPictures', self.context):
359            return _('You are not entitled to upload passport pictures.')
[11782]360
[13796]361    @property
[13814]362    def label(self):
363        if self.target == 'ictwk':
364            container_title = self.context.__parent__.title
365            return _('${a} <br /> Registration Record ${b}', mapping = {
366                'a':container_title, 'b':self.context.application_number})
367        return super(CustomApplicantManageFormPage, self).label
368
369    @property
[13796]370    def form_fields(self):
371        if self.target == 'ictwk':
[13814]372            form_fields = grok.AutoFields(IUnibenRegistration)
373            for field in REGISTRATION_OMIT_MANAGE_FIELDS:
[13796]374                form_fields = form_fields.omit(field)
[13825]375            state = IWorkflowState(self.context).getState()
376            if state != STARTED:
377                form_fields['registration_cats'].for_display = True
[13814]378            return form_fields
[14105]379        if self.target is not None and self.target.startswith('pg'):
380            form_fields = grok.AutoFields(ICustomPGApplicant)
381            for field in PG_OMIT_MANAGE_FIELDS:
382                form_fields = form_fields.omit(field)
383        elif self.target is not None and self.target.startswith('pre'):
384            form_fields = grok.AutoFields(ICustomPGApplicant)
385            for field in PRE_OMIT_MANAGE_FIELDS:
386                form_fields = form_fields.omit(field)
387        elif self.target is not None and self.target.startswith('cbt'):
388            form_fields = grok.AutoFields(ICustomUGApplicant)
389            for field in CBT_OMIT_MANAGE_FIELDS:
390                form_fields = form_fields.omit(field)
391        elif self.target is not None and self.target.startswith('akj'):
392            form_fields = grok.AutoFields(ICustomPGApplicant)
393            for field in PRE_OMIT_MANAGE_FIELDS:
394                form_fields = form_fields.omit(field)
395        elif self.target is not None and self.target.startswith('ak'):
396            form_fields = grok.AutoFields(ICustomUGApplicant)
397            for field in AFFIL_OMIT_MANAGE_FIELDS:
398                form_fields = form_fields.omit(field)
399        elif self.target is not None and self.target.startswith('ase'): # was putme
400            form_fields = grok.AutoFields(ICustomUGApplicant)
401            for field in PUTME_OMIT_MANAGE_FIELDS:
402                form_fields = form_fields.omit(field)
403        elif self.target is not None and self.target.startswith('pude'):
404            form_fields = grok.AutoFields(ICustomUGApplicant)
405            for field in PUDE_OMIT_MANAGE_FIELDS:
406                form_fields = form_fields.omit(field)
407        else:
408            form_fields = grok.AutoFields(ICustomUGApplicant)
409            for field in UG_OMIT_MANAGE_FIELDS:
410                form_fields = form_fields.omit(field)
411        form_fields['student_id'].for_display = True
412        form_fields['applicant_id'].for_display = True
[13796]413        return form_fields
414
415
416class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
417    """An applicant-centered edit view for applicant data.
418    """
419
420    @property
[13887]421    def display_payments(self):
422        if self.context.special or self.target == 'ictwk':
423            return True
424        return getattr(self.context.__parent__, 'application_fee', None)
425
426    @property
[13796]427    def form_fields(self):
428        if self.target == 'ictwk':
[13814]429            form_fields = grok.AutoFields(IUnibenRegistration)
430            for field in REGISTRATION_OMIT_EDIT_FIELDS:
[13796]431                form_fields = form_fields.omit(field)
[13825]432            state = IWorkflowState(self.context).getState()
433            if state != STARTED:
434                form_fields['registration_cats'].for_display = True
[13814]435            return form_fields
[14105]436        if self.target is not None and self.target.startswith('pg'):
437            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
438            for field in PG_OMIT_EDIT_FIELDS:
439                form_fields = form_fields.omit(field)
440        elif self.target is not None and self.target.startswith('pre'):
441            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
442            for field in PRE_OMIT_EDIT_FIELDS:
443                form_fields = form_fields.omit(field)
444        elif self.target is not None and self.target.startswith('cbt'):
445            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
446            for field in CBT_OMIT_EDIT_FIELDS:
447                form_fields = form_fields.omit(field)
448        elif self.target is not None and self.target.startswith('akj'):
449            form_fields = grok.AutoFields(ICustomPGApplicant)
450            for field in PRE_OMIT_EDIT_FIELDS:
451                form_fields = form_fields.omit(field)
452        elif self.target is not None and self.target.startswith('ak'):
453            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
454            for field in AFFIL_OMIT_EDIT_FIELDS:
455                form_fields = form_fields.omit(field)
456        elif self.target is not None and self.target.startswith('ase'): # was putme
457            form_fields = grok.AutoFields(IPUTMEApplicantEdit)
458            for field in PUTME_OMIT_EDIT_FIELDS:
459                form_fields = form_fields.omit(field)
460        elif self.target is not None and self.target.startswith('pude'):
461            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
462            for field in PUDE_OMIT_EDIT_FIELDS:
463                form_fields = form_fields.omit(field)
464        else:
465            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
466            for field in UG_OMIT_EDIT_FIELDS:
467                form_fields = form_fields.omit(field)
468        form_fields['applicant_id'].for_display = True
469        form_fields['reg_number'].for_display = True
[13796]470        return form_fields
471
[13814]472    @property
473    def label(self):
474        if self.target == 'ictwk':
475            container_title = self.context.__parent__.title
476            return _('${a} <br /> Registration Record ${b}', mapping = {
477                'a':container_title, 'b':self.context.application_number})
478        return super(CustomApplicantEditFormPage, self).label
479
[11782]480class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage):
481    """ Approval view
482    """
483
484    def update(self):
[11784]485        if self.context.p_category == 'admission_checking':
486            if self.context.p_state == 'paid':
487                flashtype = 'warning'
488                msg = _('This ticket has already been paid.')
489                log = None
490            else:
491                self.context.approve()
492                log = 'payment approved: %s' % self.context.p_id
493                msg = _('Payment approved')
494                flashtype = 'success'
495        else:
496            flashtype, msg, log = self.context.approveApplicantPayment()
[11782]497        if log is not None:
498            applicant = self.context.__parent__
499            # Add log message to applicants.log
500            applicant.writeLogMessage(self, log)
501            # Add log message to payments.log
502            self.context.logger.info(
503                '%s,%s,%s,%s,%s,,,,,,' % (
504                applicant.applicant_id,
505                self.context.p_id, self.context.p_category,
506                self.context.amount_auth, self.context.r_code))
507        self.flash(msg, type=flashtype)
508        return
[11784]509
510class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip):
511    """Deliver a PDF slip of the context.
512    """
513
514    def update(self):
515        super(CustomExportPDFPageApplicationSlip, self).update()
516        if self.context.state == ADMITTED and \
517            not self.context.admchecking_fee_paid():
518            self.flash(
519                _('Please pay admission checking fee before trying to download '
520                  'the application slip.'), type='warning')
521            return self.redirect(self.url(self.context))
522        return
[13552]523
[13557]524class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
[13552]525
[13558]526    def _getPDFCreator(self):
[14061]527        if self.target.startswith('ak'):
[13558]528            return getUtility(IPDFCreator, name='akoka_pdfcreator')
529        return getUtility(IPDFCreator)
530
[13552]531    @property
[13814]532    def form_fields(self):
533        if self.target == 'ictwk':
534            form_fields = grok.AutoFields(IUnibenRegistration)
535            for field in REGISTRATION_OMIT_PDF_FIELDS:
536                form_fields = form_fields.omit(field)
537            return form_fields
[14105]538        if self.target is not None and self.target.startswith('pg'):
539            form_fields = grok.AutoFields(ICustomPGApplicant)
540            for field in PG_OMIT_PDF_FIELDS:
541                form_fields = form_fields.omit(field)
542        elif self.target is not None and self.target.startswith('pre'):
543            form_fields = grok.AutoFields(ICustomPGApplicant)
544            for field in PRE_OMIT_PDF_FIELDS:
545                form_fields = form_fields.omit(field)
546        elif self.target is not None and self.target.startswith('cbt'): # uniben
547            form_fields = grok.AutoFields(ICustomUGApplicant)
548            for field in CBT_OMIT_PDF_FIELDS:
549                form_fields = form_fields.omit(field)
550        elif self.target is not None and self.target.startswith('akj'): # uniben
551            form_fields = grok.AutoFields(ICustomPGApplicant)
552            for field in PRE_OMIT_PDF_FIELDS:
553                form_fields = form_fields.omit(field)
554        elif self.target is not None and self.target.startswith('ak'): # uniben
555            form_fields = grok.AutoFields(ICustomUGApplicant)
556            for field in AFFIL_OMIT_PDF_FIELDS:
557                form_fields = form_fields.omit(field)
558        elif self.target is not None and self.target.startswith('ase'): # was putme
559            form_fields = grok.AutoFields(ICustomUGApplicant)
560            if self._reduced_slip():
561                for field in PUTME_OMIT_RESULT_SLIP_FIELDS:
562                    form_fields = form_fields.omit(field)
563            else:
564                for field in PUTME_OMIT_PDF_FIELDS:
565                    form_fields = form_fields.omit(field)
566        elif self.target is not None and self.target.startswith('pude'):
567            form_fields = grok.AutoFields(ICustomUGApplicant)
568            if self._reduced_slip():
569                for field in PUDE_OMIT_RESULT_SLIP_FIELDS:
570                    form_fields = form_fields.omit(field)
571            else:
572                for field in PUDE_OMIT_PDF_FIELDS:
573                    form_fields = form_fields.omit(field)
574        else:
575            form_fields = grok.AutoFields(ICustomUGApplicant)
576            for field in UG_OMIT_PDF_FIELDS:
577                form_fields = form_fields.omit(field)
578        if not getattr(self.context, 'student_id'):
579            form_fields = form_fields.omit('student_id')
580        if not getattr(self.context, 'screening_score'):
581            form_fields = form_fields.omit('screening_score')
582        if not getattr(self.context, 'screening_venue'):
583            form_fields = form_fields.omit('screening_venue')
584        if not getattr(self.context, 'screening_date'):
585            form_fields = form_fields.omit('screening_date')
[13814]586        return form_fields
587
588    @property
[13552]589    def title(self):
590        container_title = self.context.__parent__.title
591        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
592        ar_translation = translate(_('Application Record'),
593            'waeup.kofa', target_language=portal_language)
[13814]594        if self.target == 'ictwk':
595            return '%s - Registration Record %s' % (container_title,
596            self.context.application_number)
[14061]597        elif self.target.startswith('ab'):
[13552]598            return 'Federal College of Education (Technical) Asaba - %s %s %s' % (
599                container_title, ar_translation,
600                self.context.application_number)
[14061]601        elif self.target.startswith('ak'):
[14064]602            return 'Federal College of Education (Technical) Akoka - %s - %s %s' % (
[13552]603                container_title, ar_translation,
604                self.context.application_number)
[13615]605        elif self.target == 'pgn':
606            return 'National Institute for Legislative Studies (NILS) - %s %s %s' % (
607                container_title, ar_translation,
608                self.context.application_number)
[13552]609        return '%s - %s %s' % (container_title,
610            ar_translation, self.context.application_number)
Note: See TracBrowser for help on using the repository browser.