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

Last change on this file since 11767 was 11752, checked in by Henrik Bettermann, 11 years ago

Change warning message.

Update locales.

  • Property svn:keywords set to Id
File size: 5.1 KB
RevLine 
[8012]1## $Id: browser.py 11752 2014-07-07 11:13:08Z 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
[11728]21from zope.component import getUtility
[11736]22from zope.security import checkPermission
[11728]23from waeup.kofa.interfaces import IExtFileStore
[10587]24from waeup.kofa.applicants.browser import (
[11728]25    ApplicantRegistrationPage, ApplicantsContainerPage,
26    ApplicationFeePaymentAddPage)
[10378]27from kofacustom.nigeria.applicants.browser import (
28    NigeriaApplicantDisplayFormPage,
[11736]29    NigeriaApplicantManageFormPage,
[10378]30    NigeriaPDFApplicationSlip)
[8012]31
[10378]32from waeup.uniben.interfaces import MessageFactory as _
33
[10338]34PASTQ_ALL = ['ADT','EPCS','ESM','HEK','VTE']
[8012]35
[10338]36PASTQ_AL = ['ENL','FAA','FOL','HIS','LAL',
37            'PHL','THR','BUL','JIL','LAW','PPL','PUL'] + PASTQ_ALL
38
39PASTQ_BS = ['ANT','ANY','CHH','COH','HAE','MED','MEH','PHS','SUR',
40            'PCG','PCH','PCO', 'PCT','PHA','PHM','PMB','ANA','MBC',
41            'MLS','NSC','PSY','DPV','ODR','OSP','PER', 'RES','AEB',
42            'BCH','BOT','CED','EVL','MCB','OPT','PBB','SLT','ZOO',
43            'AEE','ANS', 'CRS','FIS','FOW','SOS'] + PASTQ_ALL
44
45PASTQ_EPS = ['CHE','CVE','DMIC','EEE','MCH','PEE','PRE','CHM',
46             'CSC','GLY','MTH','PHY'] + PASTQ_ALL
47
48PASTQ_MSS = ['ACC','BNK','BUS','ECO','GEO','POL','SAA','SWK'] + PASTQ_ALL
49
[10587]50class CustomApplicantsContainerPage(ApplicantsContainerPage):
51    """The standard view for regular applicant containers.
52    """
53
54    @property
55    def form_fields(self):
56        form_fields = super(CustomApplicantsContainerPage, self).form_fields
[10589]57        usertype = getattr(self.request.principal, 'user_type', None)
58        if self.request.principal.id == 'zope.anybody' or  \
59            usertype in ('applicant', 'student'):
[10587]60            return form_fields.omit('application_fee')
61        return form_fields
62
[8630]63class CustomApplicantRegistrationPage(ApplicantRegistrationPage):
64    """Captcha'd registration page for applicants.
65    """
66
[10337]67    def _redirect(self, email, password, applicant_id):
68        # Forward email and credentials to landing page.
69        self.redirect(self.url(self.context, 'registration_complete',
70            data = dict(email=email, password=password,
71            applicant_id=applicant_id)))
72        return
[10287]73
[10375]74class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
75    """A display view for applicant data.
[10287]76    """
[10375]77    grok.template('applicantdisplaypage')
[10338]78
[10622]79    def _show_pastq_putme(self):
[10338]80        return self.target.startswith('putme') \
[10375]81               and self.context.state in ('paid', 'submitted') \
[10338]82               and getattr(self.context, 'course1') is not None
83
84    @property
85    def show_pastq_al(self):
[10622]86        return self._show_pastq_putme() \
[10338]87               and self.context.course1.__parent__.__parent__.code in PASTQ_AL
88
89    @property
90    def show_pastq_bs(self):
[10622]91        return self._show_pastq_putme() \
[10338]92               and self.context.course1.__parent__.__parent__.code in PASTQ_BS
93
94    @property
95    def show_pastq_eps(self):
[10622]96        return self._show_pastq_putme() \
[10338]97               and self.context.course1.__parent__.__parent__.code in PASTQ_EPS
98
99    @property
100    def show_pastq_mss(self):
[10622]101        return self._show_pastq_putme() \
[10338]102               and self.context.course1.__parent__.__parent__.code in PASTQ_MSS
103
[10622]104    @property
105    def show_pastq_pude(self):
106        return self.target.startswith('pude') \
107               and self.context.state in ('paid', 'submitted')
108
[10378]109class CustomNigeriaPDFApplicationSlip(NigeriaPDFApplicationSlip):
[10338]110
[10378]111
112    @property
113    def note(self):
114        if self.target is not None and not self.target.startswith('pg') \
115            and not self._reduced_slip():
116            return _(u'<br /><br /><br />'
117                      'Comfirm your exam venue 72 hours to the exam.')
118        return
119
[11728]120class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage):
121    """ Page to add an online payment ticket
122    """
[10378]123
[11728]124    @property
125    def custom_requirements(self):
126        store = getUtility(IExtFileStore)
127        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
[11752]128            return _('Upload your 1"x1" Red  background passport photo before making payment.')
[11728]129        return ''
130
[11736]131
132class ApplicantManageFormPage(NigeriaApplicantManageFormPage):
133
134    @property
135    def custom_upload_requirements(self):
136        if not checkPermission('waeup.uploadPassportPictures', self.context):
137            return _('You are not entitled to upload passport pictures.')
Note: See TracBrowser for help on using the repository browser.