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