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