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