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