1 | ## $Id: browser.py 17964 2024-11-27 00:30:20Z 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 | CheckTranscriptStatus, |
---|
36 | AdditionalFile,) |
---|
37 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
38 | from waeup.kofa.applicants.interfaces import ( |
---|
39 | ISpecialApplicant, IApplicantsUtils) |
---|
40 | from waeup.kofa.browser.interfaces import IPDFCreator |
---|
41 | from kofacustom.nigeria.applicants.browser import ( |
---|
42 | NigeriaApplicantDisplayFormPage, |
---|
43 | NigeriaApplicantManageFormPage, |
---|
44 | NigeriaApplicantEditFormPage, |
---|
45 | NigeriaPDFApplicationSlip, |
---|
46 | NigeriaExportPDFPaymentSlipPage) |
---|
47 | from waeup.uniben.applicants.interfaces import ( |
---|
48 | ICustomApplicant, |
---|
49 | IUnibenRegistration, |
---|
50 | ICustomUGApplicant, |
---|
51 | ICustomPGApplicant, |
---|
52 | ICustomPGApplicantEdit, |
---|
53 | ICustomUGApplicantEdit, |
---|
54 | IPUTMEApplicantEdit, |
---|
55 | ITranscriptApplicant, |
---|
56 | IFrenchApplicant, |
---|
57 | IAfrimalApplicant) |
---|
58 | from waeup.kofa.applicants.workflow import ADMITTED, PAID, STARTED |
---|
59 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
60 | OMIT_DISPLAY_FIELDS, |
---|
61 | UG_OMIT_DISPLAY_FIELDS, |
---|
62 | UG_OMIT_PDF_FIELDS, |
---|
63 | UG_OMIT_MANAGE_FIELDS, |
---|
64 | UG_OMIT_EDIT_FIELDS, |
---|
65 | CBT_OMIT_DISPLAY_FIELDS, |
---|
66 | CBT_OMIT_PDF_FIELDS, |
---|
67 | CBT_OMIT_MANAGE_FIELDS, |
---|
68 | CBT_OMIT_EDIT_FIELDS, |
---|
69 | AFFIL_OMIT_DISPLAY_FIELDS, |
---|
70 | AFFIL_OMIT_PDF_FIELDS, |
---|
71 | AFFIL_OMIT_MANAGE_FIELDS, |
---|
72 | AFFIL_OMIT_EDIT_FIELDS, |
---|
73 | PG_OMIT_DISPLAY_FIELDS, |
---|
74 | PG_OMIT_PDF_FIELDS, |
---|
75 | PG_OMIT_MANAGE_FIELDS, |
---|
76 | PG_OMIT_EDIT_FIELDS, |
---|
77 | PUTME_OMIT_DISPLAY_FIELDS, |
---|
78 | PUTME_OMIT_PDF_FIELDS, |
---|
79 | PUTME_OMIT_MANAGE_FIELDS, |
---|
80 | PUTME_OMIT_EDIT_FIELDS, |
---|
81 | PUTME_OMIT_RESULT_SLIP_FIELDS, |
---|
82 | PUDE_OMIT_DISPLAY_FIELDS, |
---|
83 | PUDE_OMIT_PDF_FIELDS, |
---|
84 | PUDE_OMIT_MANAGE_FIELDS, |
---|
85 | PUDE_OMIT_EDIT_FIELDS, |
---|
86 | PUDE_OMIT_RESULT_SLIP_FIELDS, |
---|
87 | PRE_OMIT_DISPLAY_FIELDS, |
---|
88 | PRE_OMIT_PDF_FIELDS, |
---|
89 | PRE_OMIT_MANAGE_FIELDS, |
---|
90 | PRE_OMIT_EDIT_FIELDS, |
---|
91 | ) |
---|
92 | |
---|
93 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
94 | |
---|
95 | PASTQ_ALL = ['ADT','CIT','DEF','DEM','EPCS','ESM','HEK','HSE','VTE'] |
---|
96 | |
---|
97 | PASTQ_AL = ['ENL','FAA','FOL','HIS','LAL', 'PHL','THR','BUL','JIL', |
---|
98 | 'LAW','PPL','PUL'] + PASTQ_ALL |
---|
99 | |
---|
100 | PASTQ_BS = ['ANT','ANY','CHH','COH','HAE','MED','MEH','PHS','SUR', |
---|
101 | 'PCG','PCH','PCO', 'PCT','PHA','PHM','PMB','ANA','MBC', |
---|
102 | 'MLS','NSC','PSY','DPV','ODR','OSP','PER', 'RES','AEB', |
---|
103 | 'BCH','BOT','CED','EVL','MCB','OPT','PBB','SLT','ZOO', |
---|
104 | 'AEE','ANS', 'CRS','FIS','FOW','SOS'] + PASTQ_ALL |
---|
105 | |
---|
106 | PASTQ_EPS = ['ARC','CHE','CVE','DMIC','EEE','GEM','MCH','PEE','PRE','CHM', |
---|
107 | 'CSC','GLY','MTH','QSV','PHY','CPE','STR'] + PASTQ_ALL |
---|
108 | |
---|
109 | PASTQ_MSS = ['ACC','BNK','BUS','ECO','ESM','GEO','POL','SAA','SWK', |
---|
110 | 'ACT','ENT','HRM','INS','MKT'] + PASTQ_ALL |
---|
111 | |
---|
112 | PT_OMIT_FIELDS = ( |
---|
113 | 'student_id', |
---|
114 | 'notice', |
---|
115 | 'screening_score', |
---|
116 | 'screening_venue', |
---|
117 | 'screening_date', |
---|
118 | 'jamb_age', |
---|
119 | 'jamb_subjects', |
---|
120 | 'jamb_score', |
---|
121 | #'jamb_reg_number', |
---|
122 | 'aggregate', |
---|
123 | 'hq_type', 'hq_matric_no', |
---|
124 | 'hq_degree', 'hq_school', |
---|
125 | 'hq_session', 'hq_disc', |
---|
126 | 'jamb_subjects_list', 'programme_type') |
---|
127 | |
---|
128 | PT_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + PT_OMIT_FIELDS |
---|
129 | |
---|
130 | PT_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + PT_OMIT_FIELDS |
---|
131 | |
---|
132 | PT_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + PT_OMIT_FIELDS |
---|
133 | |
---|
134 | PT_OMIT_PDF_FIELDS = PT_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
135 | PT_OMIT_RESULT_SLIP_FIELDS = PT_OMIT_DISPLAY_FIELDS + ( |
---|
136 | 'phone', |
---|
137 | 'date_of_birth', 'sex', |
---|
138 | 'nationality', 'lga', #'perm_address', |
---|
139 | 'course2', 'screening_venue', |
---|
140 | 'screening_date') |
---|
141 | |
---|
142 | |
---|
143 | REGISTRATION_OMIT_DISPLAY_FIELDS = ( |
---|
144 | 'locked', |
---|
145 | 'suspended', |
---|
146 | 'course_admitted', |
---|
147 | ) |
---|
148 | |
---|
149 | REGISTRATION_OMIT_EDIT_FIELDS = ( |
---|
150 | 'locked', |
---|
151 | 'suspended', |
---|
152 | 'applicant_id', |
---|
153 | 'course_admitted', |
---|
154 | ) |
---|
155 | |
---|
156 | REGISTRATION_OMIT_MANAGE_FIELDS = ( |
---|
157 | 'applicant_id', |
---|
158 | ) |
---|
159 | |
---|
160 | |
---|
161 | REGISTRATION_OMIT_PDF_FIELDS = ( |
---|
162 | 'locked', |
---|
163 | 'suspended', |
---|
164 | 'course_admitted', |
---|
165 | ) |
---|
166 | |
---|
167 | PUTME_OMIT_PDF_FIELDS = PUTME_OMIT_PDF_FIELDS + ( |
---|
168 | 'fst_sit_results', 'scd_sit_results') |
---|
169 | |
---|
170 | TRANS_OMIT_FIELDS = ('suspended',) |
---|
171 | |
---|
172 | #TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS + ( |
---|
173 | # 'date_of_birth', |
---|
174 | # 'sex', |
---|
175 | # #'nationality', |
---|
176 | # 'entry_mode', |
---|
177 | # 'entry_session', |
---|
178 | # 'end_session', |
---|
179 | # 'course_studied', |
---|
180 | # 'course_changed', |
---|
181 | # #'change_level', |
---|
182 | # ) |
---|
183 | |
---|
184 | TRANS_SHORT_OMIT_FIELDS = TRANS_OMIT_FIELDS |
---|
185 | |
---|
186 | TRANS_OMIT_EDIT_FIELDS = TRANS_OMIT_FIELDS + ('applicant_id', ) |
---|
187 | |
---|
188 | TRANS_SHORT_OMIT_EDIT_FIELDS = TRANS_SHORT_OMIT_FIELDS + ('applicant_id', ) |
---|
189 | |
---|
190 | TRANS_OMIT_PDF_FIELDS = TRANS_OMIT_FIELDS + ('locked', ) |
---|
191 | |
---|
192 | TRANS_SHORT_OMIT_PDF_FIELDS = TRANS_SHORT_OMIT_FIELDS + ('locked', ) |
---|
193 | |
---|
194 | class CustomApplicantsContainerPage(ApplicantsContainerPage): |
---|
195 | """The standard view for regular applicant containers. |
---|
196 | """ |
---|
197 | |
---|
198 | @property |
---|
199 | def form_fields(self): |
---|
200 | form_fields = super(CustomApplicantsContainerPage, self).form_fields |
---|
201 | usertype = getattr(self.request.principal, 'user_type', None) |
---|
202 | if self.request.principal.id == 'zope.anybody' or \ |
---|
203 | usertype in ('applicant', 'student'): |
---|
204 | return form_fields.omit('application_fee') |
---|
205 | return form_fields |
---|
206 | |
---|
207 | class CustomApplicantRegistrationPage(ApplicantRegistrationPage): |
---|
208 | """Captcha'd registration page for applicants. |
---|
209 | """ |
---|
210 | |
---|
211 | def _redirect(self, email, password, applicant_id): |
---|
212 | # Forward email and credentials to landing page. |
---|
213 | self.redirect(self.url(self.context, 'registration_complete', |
---|
214 | data = dict(email=email, password=password, |
---|
215 | applicant_id=applicant_id))) |
---|
216 | return |
---|
217 | |
---|
218 | @property |
---|
219 | def label(self): |
---|
220 | if self.context.prefix.startswith('tsc'): |
---|
221 | return _('Request for ${a}', |
---|
222 | mapping = {'a':self.context.title}) |
---|
223 | return _('Apply for ${a}', |
---|
224 | mapping = {'a':self.context.title}) |
---|
225 | |
---|
226 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
227 | """A display view for applicant data. |
---|
228 | """ |
---|
229 | grok.template('applicantdisplaypage') |
---|
230 | |
---|
231 | @property |
---|
232 | def display_payments(self): |
---|
233 | if self.context.special or self.target == 'ictwk': |
---|
234 | return True |
---|
235 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
236 | |
---|
237 | def _show_pastq_putme(self): |
---|
238 | return self.target.startswith('pre') \ |
---|
239 | and self.context.state in ('paid', 'submitted') \ |
---|
240 | and getattr(self.context, 'course1') is not None |
---|
241 | # return False |
---|
242 | |
---|
243 | @property |
---|
244 | def depcode(self): |
---|
245 | try: |
---|
246 | code = self.context.course1.__parent__.__parent__.code |
---|
247 | return code |
---|
248 | except: |
---|
249 | return |
---|
250 | |
---|
251 | @property |
---|
252 | def show_pastq_al(self): |
---|
253 | return self._show_pastq_putme() # and self.depcode in PASTQ_AL |
---|
254 | |
---|
255 | @property |
---|
256 | def show_pastq_bs(self): |
---|
257 | return self._show_pastq_putme() # and self.depcode in PASTQ_BS |
---|
258 | |
---|
259 | @property |
---|
260 | def show_pastq_eps(self): |
---|
261 | return self._show_pastq_putme() # and self.depcode in PASTQ_EPS |
---|
262 | |
---|
263 | @property |
---|
264 | def show_pastq_mss(self): |
---|
265 | return self._show_pastq_putme() # and self.depcode in PASTQ_MSS |
---|
266 | |
---|
267 | @property |
---|
268 | def show_pastq_pude(self): |
---|
269 | return self.target.startswith('pude') \ |
---|
270 | and self.context.state in ('paid', 'submitted') |
---|
271 | |
---|
272 | @property |
---|
273 | def label(self): |
---|
274 | if self.target == 'ictwk': |
---|
275 | container_title = self.context.__parent__.title |
---|
276 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
277 | 'a':container_title, 'b':self.context.application_number}) |
---|
278 | return super(CustomApplicantDisplayFormPage, self).label |
---|
279 | |
---|
280 | @property |
---|
281 | def form_fields(self): |
---|
282 | if self.target is not None and self.target == 'tscf': |
---|
283 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
284 | for field in TRANS_OMIT_FIELDS: |
---|
285 | form_fields = form_fields.omit(field) |
---|
286 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
287 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
288 | return form_fields |
---|
289 | if self.target is not None and self.target == 'tscs': |
---|
290 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
291 | for field in TRANS_SHORT_OMIT_FIELDS: |
---|
292 | form_fields = form_fields.omit(field) |
---|
293 | form_fields['dispatch_address'].custom_widget = BytesDisplayWidget |
---|
294 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
295 | return form_fields |
---|
296 | if self.target is not None and self.target == 'flc': |
---|
297 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
298 | for field in REGISTRATION_OMIT_DISPLAY_FIELDS: |
---|
299 | form_fields = form_fields.omit(field) |
---|
300 | return form_fields |
---|
301 | if self.target is not None and self.target == 'afrimal': |
---|
302 | form_fields = grok.AutoFields(IAfrimalApplicant) |
---|
303 | for field in REGISTRATION_OMIT_DISPLAY_FIELDS: |
---|
304 | form_fields = form_fields.omit(field) |
---|
305 | return form_fields |
---|
306 | if self.target == 'ictwk': |
---|
307 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
308 | for field in REGISTRATION_OMIT_DISPLAY_FIELDS: |
---|
309 | form_fields = form_fields.omit(field) |
---|
310 | return form_fields |
---|
311 | elif self.target is not None and self.target.startswith('pg'): |
---|
312 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
313 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
314 | form_fields = form_fields.omit(field) |
---|
315 | elif self.target is not None and self.target.startswith('pre'): |
---|
316 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
317 | for field in PRE_OMIT_DISPLAY_FIELDS: |
---|
318 | form_fields = form_fields.omit(field) |
---|
319 | elif self.target is not None and self.target.startswith('cbt'): |
---|
320 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
321 | for field in CBT_OMIT_DISPLAY_FIELDS: |
---|
322 | form_fields = form_fields.omit(field) |
---|
323 | elif self.target is not None and self.target.startswith('akj'): |
---|
324 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
325 | for field in PRE_OMIT_DISPLAY_FIELDS: |
---|
326 | form_fields = form_fields.omit(field) |
---|
327 | elif self.target is not None and self.target.startswith('ak'): |
---|
328 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
329 | for field in AFFIL_OMIT_DISPLAY_FIELDS: |
---|
330 | form_fields = form_fields.omit(field) |
---|
331 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
332 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
333 | for field in PUTME_OMIT_DISPLAY_FIELDS: |
---|
334 | form_fields = form_fields.omit(field) |
---|
335 | elif self.target is not None and self.target.startswith('pt'): |
---|
336 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
337 | for field in PT_OMIT_DISPLAY_FIELDS: |
---|
338 | form_fields = form_fields.omit(field) |
---|
339 | elif self.target is not None and self.target.startswith('pude'): |
---|
340 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
341 | for field in PUDE_OMIT_DISPLAY_FIELDS: |
---|
342 | form_fields = form_fields.omit(field) |
---|
343 | else: |
---|
344 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
345 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
346 | form_fields = form_fields.omit(field) |
---|
347 | #form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
348 | try: |
---|
349 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
350 | except: |
---|
351 | pass |
---|
352 | if not getattr(self.context, 'student_id'): |
---|
353 | form_fields = form_fields.omit('student_id') |
---|
354 | if not getattr(self.context, 'screening_score'): |
---|
355 | form_fields = form_fields.omit('screening_score') |
---|
356 | if not getattr(self.context, 'screening_venue') or self._not_paid(): |
---|
357 | form_fields = form_fields.omit('screening_venue') |
---|
358 | if not getattr(self.context, 'screening_date') or self._not_paid(): |
---|
359 | form_fields = form_fields.omit('screening_date') |
---|
360 | if not self.context.admchecking_fee_paid(): |
---|
361 | form_fields = form_fields.omit( |
---|
362 | 'screening_score', 'aggregate', 'student_id') |
---|
363 | return form_fields |
---|
364 | |
---|
365 | @property |
---|
366 | def display_actions(self): |
---|
367 | state = IWorkflowState(self.context).getState() |
---|
368 | actions = [] |
---|
369 | if state == ADMITTED and not self.context.admchecking_fee_paid(): |
---|
370 | actions = [_('Add admission checking payment ticket')] |
---|
371 | return actions |
---|
372 | |
---|
373 | |
---|
374 | def getCourseAdmitted(self): |
---|
375 | """Return link, title and code in html format to the certificate |
---|
376 | admitted. |
---|
377 | """ |
---|
378 | if self.admission_checking_info: |
---|
379 | return '<span class="hint">%s</span>' % self.admission_checking_info |
---|
380 | return super(CustomApplicantDisplayFormPage, self).getCourseAdmitted() |
---|
381 | |
---|
382 | @property |
---|
383 | def admission_checking_info(self): |
---|
384 | if self.context.state == ADMITTED and \ |
---|
385 | not self.context.admchecking_fee_paid(): |
---|
386 | return _('You must pay the admission checking fee ' |
---|
387 | 'to view your screening results and your course admitted.') |
---|
388 | return |
---|
389 | |
---|
390 | @action(_('Add admission checking payment ticket'), style='primary') |
---|
391 | def addPaymentTicket(self, **data): |
---|
392 | self.redirect(self.url(self.context, '@@addacp')) |
---|
393 | return |
---|
394 | |
---|
395 | class CustomApplicationFeePaymentAddPage(ApplicationFeePaymentAddPage): |
---|
396 | """ Page to add an online payment ticket |
---|
397 | """ |
---|
398 | |
---|
399 | @property |
---|
400 | def custom_requirements(self): |
---|
401 | if self.context.__parent__.with_picture: |
---|
402 | store = getUtility(IExtFileStore) |
---|
403 | if self.context.__parent__.picture_editable \ |
---|
404 | and not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
405 | return _('Upload your 1"x1" Red background passport photo before making payment.') |
---|
406 | return '' |
---|
407 | |
---|
408 | class AdmissionCheckingFeePaymentAddPage(UtilityView, grok.View): |
---|
409 | """ Page to add an admission checking online payment ticket. |
---|
410 | """ |
---|
411 | grok.context(ICustomApplicant) |
---|
412 | grok.name('addacp') |
---|
413 | grok.require('waeup.payApplicant') |
---|
414 | factory = u'waeup.ApplicantOnlinePayment' |
---|
415 | |
---|
416 | def _setPaymentDetails(self, payment): |
---|
417 | container = self.context.__parent__ |
---|
418 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
419 | session = str(container.year) |
---|
420 | try: |
---|
421 | session_config = grok.getSite()['configuration'][session] |
---|
422 | except KeyError: |
---|
423 | return _(u'Session configuration object is not available.'), None |
---|
424 | payment.p_id = "p%s" % timestamp |
---|
425 | payment.p_item = container.title |
---|
426 | payment.p_session = container.year |
---|
427 | payment.amount_auth = 0.0 |
---|
428 | payment.p_category = 'admission_checking' |
---|
429 | payment.amount_auth = session_config.admchecking_fee |
---|
430 | if payment.amount_auth in (0.0, None): |
---|
431 | return _('Amount could not be determined.'), None |
---|
432 | return |
---|
433 | |
---|
434 | def update(self): |
---|
435 | if self.context.admchecking_fee_paid(): |
---|
436 | self.flash( |
---|
437 | _('Admission checking payment has already been made.'), |
---|
438 | type='warning') |
---|
439 | self.redirect(self.url(self.context)) |
---|
440 | return |
---|
441 | payment = createObject(self.factory) |
---|
442 | failure = self._setPaymentDetails(payment) |
---|
443 | if failure is not None: |
---|
444 | self.flash(failure[0], type='danger') |
---|
445 | self.redirect(self.url(self.context)) |
---|
446 | return |
---|
447 | self.context[payment.p_id] = payment |
---|
448 | self.flash(_('Payment ticket created.')) |
---|
449 | self.redirect(self.url(payment)) |
---|
450 | return |
---|
451 | |
---|
452 | def render(self): |
---|
453 | return |
---|
454 | |
---|
455 | |
---|
456 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
457 | |
---|
458 | @property |
---|
459 | def display_payments(self): |
---|
460 | if self.context.special or self.target == 'ictwk': |
---|
461 | return True |
---|
462 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
463 | |
---|
464 | @property |
---|
465 | def custom_upload_requirements(self): |
---|
466 | if not checkPermission('waeup.uploadPassportPictures', self.context): |
---|
467 | return _('You are not entitled to upload passport pictures.') |
---|
468 | |
---|
469 | def display_fileupload(self, filename): |
---|
470 | if filename[1] == 'res_stat' \ |
---|
471 | and self.target is not None \ |
---|
472 | and not self.target.startswith('tsc'): |
---|
473 | return False |
---|
474 | if filename[1] == 'eligibility' \ |
---|
475 | and self.target is not None \ |
---|
476 | and not self.target.startswith('tsc'): |
---|
477 | return False |
---|
478 | return True |
---|
479 | |
---|
480 | @property |
---|
481 | def label(self): |
---|
482 | if self.target == 'ictwk': |
---|
483 | container_title = self.context.__parent__.title |
---|
484 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
485 | 'a':container_title, 'b':self.context.application_number}) |
---|
486 | return super(CustomApplicantManageFormPage, self).label |
---|
487 | |
---|
488 | @property |
---|
489 | def form_fields(self): |
---|
490 | if self.target is not None and self.target == 'tscf': |
---|
491 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
492 | for field in TRANS_OMIT_EDIT_FIELDS: |
---|
493 | form_fields = form_fields.omit(field) |
---|
494 | return form_fields |
---|
495 | if self.target is not None and self.target == 'tscs': |
---|
496 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
497 | for field in TRANS_SHORT_OMIT_EDIT_FIELDS: |
---|
498 | form_fields = form_fields.omit(field) |
---|
499 | return form_fields |
---|
500 | if self.target == 'ictwk': |
---|
501 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
502 | for field in REGISTRATION_OMIT_MANAGE_FIELDS: |
---|
503 | form_fields = form_fields.omit(field) |
---|
504 | state = IWorkflowState(self.context).getState() |
---|
505 | if state != STARTED: |
---|
506 | form_fields['registration_cats'].for_display = True |
---|
507 | return form_fields |
---|
508 | if self.target is not None and self.target == 'flc': |
---|
509 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
510 | for field in REGISTRATION_OMIT_MANAGE_FIELDS: |
---|
511 | form_fields = form_fields.omit(field) |
---|
512 | return form_fields |
---|
513 | if self.target is not None and self.target == 'afrimal': |
---|
514 | form_fields = grok.AutoFields(IAfrimalApplicant) |
---|
515 | for field in REGISTRATION_OMIT_MANAGE_FIELDS: |
---|
516 | form_fields = form_fields.omit(field) |
---|
517 | return form_fields |
---|
518 | if self.target is not None and self.target.startswith('pg'): |
---|
519 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
520 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
521 | form_fields = form_fields.omit(field) |
---|
522 | elif self.target is not None and self.target.startswith('pre'): |
---|
523 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
524 | for field in PRE_OMIT_MANAGE_FIELDS: |
---|
525 | form_fields = form_fields.omit(field) |
---|
526 | elif self.target is not None and self.target.startswith('cbt'): |
---|
527 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
528 | for field in CBT_OMIT_MANAGE_FIELDS: |
---|
529 | form_fields = form_fields.omit(field) |
---|
530 | elif self.target is not None and self.target.startswith('akj'): |
---|
531 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
532 | for field in PRE_OMIT_MANAGE_FIELDS: |
---|
533 | form_fields = form_fields.omit(field) |
---|
534 | elif self.target is not None and self.target.startswith('ak'): |
---|
535 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
536 | for field in AFFIL_OMIT_MANAGE_FIELDS: |
---|
537 | form_fields = form_fields.omit(field) |
---|
538 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
539 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
540 | for field in PUTME_OMIT_MANAGE_FIELDS: |
---|
541 | form_fields = form_fields.omit(field) |
---|
542 | elif self.target is not None and self.target.startswith('pt'): |
---|
543 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
544 | for field in PT_OMIT_MANAGE_FIELDS: |
---|
545 | form_fields = form_fields.omit(field) |
---|
546 | elif self.target is not None and self.target.startswith('pude'): |
---|
547 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
548 | for field in PUDE_OMIT_MANAGE_FIELDS: |
---|
549 | form_fields = form_fields.omit(field) |
---|
550 | else: |
---|
551 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
552 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
553 | form_fields = form_fields.omit(field) |
---|
554 | try: |
---|
555 | form_fields['student_id'].for_display = True |
---|
556 | except: |
---|
557 | pass |
---|
558 | try: |
---|
559 | form_fields['applicant_id'].for_display = True |
---|
560 | except: |
---|
561 | pass |
---|
562 | return form_fields |
---|
563 | |
---|
564 | |
---|
565 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
566 | """An applicant-centered edit view for applicant data. |
---|
567 | """ |
---|
568 | |
---|
569 | def unremovable(self, ticket): |
---|
570 | return True |
---|
571 | |
---|
572 | @property |
---|
573 | def display_payments(self): |
---|
574 | if self.context.special or self.target == 'ictwk': |
---|
575 | return True |
---|
576 | return getattr(self.context.__parent__, 'application_fee', None) |
---|
577 | |
---|
578 | @property |
---|
579 | def form_fields(self): |
---|
580 | state = IWorkflowState(self.context).getState() |
---|
581 | if self.target is not None and self.target == 'tscf': |
---|
582 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
583 | form_fields['courier_tno'].for_display = True |
---|
584 | form_fields['proc_date'].for_display = True |
---|
585 | if state == PAID: |
---|
586 | form_fields['order'].for_display = True |
---|
587 | form_fields = form_fields.omit('locked') |
---|
588 | |
---|
589 | form_fields['date_of_birth'].field.required = True |
---|
590 | #form_fields['nationality'].field.required = True |
---|
591 | form_fields['email'].field.required = True |
---|
592 | form_fields['phone'].field.required = True |
---|
593 | form_fields['dispatch_address'].field.required = True |
---|
594 | form_fields['entry_mode'].field.required = True |
---|
595 | form_fields['entry_session'].field.required = True |
---|
596 | form_fields['end_session'].field.required = True |
---|
597 | form_fields['course_studied'].field.required = True |
---|
598 | form_fields['collected'].field.required = True |
---|
599 | form_fields['order'].field.required = True |
---|
600 | form_fields['charge'].field.required = True |
---|
601 | form_fields['no_copies'].field.required = True |
---|
602 | |
---|
603 | for field in TRANS_OMIT_EDIT_FIELDS: |
---|
604 | form_fields = form_fields.omit(field) |
---|
605 | return form_fields |
---|
606 | if self.target is not None and self.target == 'tscs': |
---|
607 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
608 | form_fields['courier_tno'].for_display = True |
---|
609 | form_fields['proc_date'].for_display = True |
---|
610 | |
---|
611 | form_fields['date_of_birth'].field.required = True |
---|
612 | #form_fields['nationality'].field.required = True |
---|
613 | form_fields['email'].field.required = True |
---|
614 | form_fields['phone'].field.required = True |
---|
615 | form_fields['dispatch_address'].field.required = True |
---|
616 | form_fields['entry_mode'].field.required = True |
---|
617 | form_fields['entry_session'].field.required = True |
---|
618 | form_fields['end_session'].field.required = True |
---|
619 | form_fields['course_studied'].field.required = True |
---|
620 | form_fields['collected'].field.required = True |
---|
621 | form_fields['order'].field.required = True |
---|
622 | form_fields['charge'].field.required = True |
---|
623 | form_fields['no_copies'].field.required = True |
---|
624 | |
---|
625 | for field in TRANS_SHORT_OMIT_EDIT_FIELDS: |
---|
626 | form_fields = form_fields.omit(field) |
---|
627 | form_fields = form_fields.omit('locked') |
---|
628 | if state == PAID: |
---|
629 | form_fields['order'].for_display = True |
---|
630 | return form_fields |
---|
631 | if self.target == 'ictwk': |
---|
632 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
633 | for field in REGISTRATION_OMIT_EDIT_FIELDS: |
---|
634 | form_fields = form_fields.omit(field) |
---|
635 | if state != STARTED: |
---|
636 | form_fields['registration_cats'].for_display = True |
---|
637 | return form_fields |
---|
638 | if self.target is not None and self.target == 'flc': |
---|
639 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
640 | for field in REGISTRATION_OMIT_EDIT_FIELDS: |
---|
641 | form_fields = form_fields.omit(field) |
---|
642 | return form_fields |
---|
643 | if self.target is not None and self.target == 'afrimal': |
---|
644 | form_fields = grok.AutoFields(IAfrimalApplicant) |
---|
645 | for field in REGISTRATION_OMIT_EDIT_FIELDS: |
---|
646 | form_fields = form_fields.omit(field) |
---|
647 | return form_fields |
---|
648 | if self.target is not None and self.target.startswith('pg'): |
---|
649 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
650 | for field in PG_OMIT_EDIT_FIELDS: |
---|
651 | form_fields = form_fields.omit(field) |
---|
652 | elif self.target is not None and self.target.startswith('pre'): |
---|
653 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
654 | for field in PRE_OMIT_EDIT_FIELDS: |
---|
655 | form_fields = form_fields.omit(field) |
---|
656 | elif self.target is not None and self.target.startswith('cbt'): |
---|
657 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
658 | for field in CBT_OMIT_EDIT_FIELDS: |
---|
659 | form_fields = form_fields.omit(field) |
---|
660 | elif self.target is not None and self.target.startswith('akj'): |
---|
661 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
662 | for field in PRE_OMIT_EDIT_FIELDS: |
---|
663 | form_fields = form_fields.omit(field) |
---|
664 | elif self.target is not None and self.target.startswith('ak'): |
---|
665 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
666 | for field in AFFIL_OMIT_EDIT_FIELDS: |
---|
667 | form_fields = form_fields.omit(field) |
---|
668 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
669 | form_fields = grok.AutoFields(IPUTMEApplicantEdit) |
---|
670 | for field in PUTME_OMIT_EDIT_FIELDS: |
---|
671 | form_fields = form_fields.omit(field) |
---|
672 | elif self.target is not None and self.target.startswith('pt'): |
---|
673 | form_fields = grok.AutoFields(IPUTMEApplicantEdit) |
---|
674 | for field in PT_OMIT_EDIT_FIELDS: |
---|
675 | form_fields = form_fields.omit(field) |
---|
676 | elif self.target is not None and self.target.startswith('pude'): |
---|
677 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
678 | for field in PUDE_OMIT_EDIT_FIELDS: |
---|
679 | form_fields = form_fields.omit(field) |
---|
680 | else: |
---|
681 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
682 | for field in UG_OMIT_EDIT_FIELDS: |
---|
683 | form_fields = form_fields.omit(field) |
---|
684 | form_fields['applicant_id'].for_display = True |
---|
685 | form_fields['reg_number'].for_display = True |
---|
686 | return form_fields |
---|
687 | |
---|
688 | @property |
---|
689 | def label(self): |
---|
690 | if self.target == 'ictwk': |
---|
691 | container_title = self.context.__parent__.title |
---|
692 | return _('${a} <br /> Registration Record ${b}', mapping = { |
---|
693 | 'a':container_title, 'b':self.context.application_number}) |
---|
694 | return super(CustomApplicantEditFormPage, self).label |
---|
695 | |
---|
696 | def display_fileupload(self, filename): |
---|
697 | if filename[1] == 'res_stat' \ |
---|
698 | and self.target is not None \ |
---|
699 | and not self.target.startswith('tsc'): |
---|
700 | return False |
---|
701 | if filename[1] == 'eligibility' \ |
---|
702 | and self.target is not None \ |
---|
703 | and not self.target.startswith('tsc'): |
---|
704 | return False |
---|
705 | return True |
---|
706 | |
---|
707 | def dataNotComplete(self, data): |
---|
708 | store = getUtility(IExtFileStore) |
---|
709 | if self.context.__parent__.with_picture \ |
---|
710 | and self.context.__parent__.picture_editable: |
---|
711 | store = getUtility(IExtFileStore) |
---|
712 | if not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
713 | return _('No passport picture uploaded.') |
---|
714 | if self.target is not None \ |
---|
715 | and self.target.startswith('tscf') \ |
---|
716 | and not store.getFileByContext(self.context, attr=u'res_stat.pdf'): |
---|
717 | return _('No statement of result pdf file uploaded.') |
---|
718 | if self.target is not None \ |
---|
719 | and self.target.startswith('tsc') \ |
---|
720 | and (not self.context.order or not self.context.charge): |
---|
721 | return _('Please select Type of Order and Transcript Charge.') |
---|
722 | if self.target is not None \ |
---|
723 | and self.target.startswith('pt') \ |
---|
724 | and not self.context.jamb_reg_number: |
---|
725 | return _('Please enter your JAMB Registration Number.') |
---|
726 | return False |
---|
727 | |
---|
728 | class CustomOnlinePaymentApprovePage(OnlinePaymentApprovePage): |
---|
729 | """ Approval view |
---|
730 | """ |
---|
731 | |
---|
732 | def update(self): |
---|
733 | if self.context.p_category == 'admission_checking': |
---|
734 | if self.context.p_state == 'paid': |
---|
735 | flashtype = 'warning' |
---|
736 | msg = _('This ticket has already been paid.') |
---|
737 | log = None |
---|
738 | else: |
---|
739 | self.context.approve() |
---|
740 | log = 'payment approved: %s' % self.context.p_id |
---|
741 | msg = _('Payment approved') |
---|
742 | flashtype = 'success' |
---|
743 | else: |
---|
744 | flashtype, msg, log = self.context.approveApplicantPayment() |
---|
745 | if log is not None: |
---|
746 | applicant = self.context.__parent__ |
---|
747 | # Add log message to applicants.log |
---|
748 | applicant.writeLogMessage(self, log) |
---|
749 | # Add log message to payments.log |
---|
750 | self.context.logger.info( |
---|
751 | '%s,%s,%s,%s,%s,,,,,,' % ( |
---|
752 | applicant.applicant_id, |
---|
753 | self.context.p_id, self.context.p_category, |
---|
754 | self.context.amount_auth, self.context.r_code)) |
---|
755 | self.flash(msg, type=flashtype) |
---|
756 | return |
---|
757 | |
---|
758 | class CustomExportPDFPageApplicationSlip(ExportPDFPageApplicationSlip): |
---|
759 | """Deliver a PDF slip of the context. |
---|
760 | """ |
---|
761 | |
---|
762 | def update(self): |
---|
763 | super(CustomExportPDFPageApplicationSlip, self).update() |
---|
764 | if self.context.state == ADMITTED and \ |
---|
765 | not self.context.admchecking_fee_paid(): |
---|
766 | self.flash( |
---|
767 | _('Please pay admission checking fee before trying to download ' |
---|
768 | 'the application slip.'), type='warning') |
---|
769 | return self.redirect(self.url(self.context)) |
---|
770 | return |
---|
771 | |
---|
772 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
773 | |
---|
774 | def _getPDFCreator(self): |
---|
775 | if self.target.startswith('ak'): |
---|
776 | return getUtility(IPDFCreator, name='akoka_pdfcreator') |
---|
777 | return getUtility(IPDFCreator) |
---|
778 | |
---|
779 | @property |
---|
780 | def form_fields(self): |
---|
781 | if self.target is not None and self.target == 'tscf': |
---|
782 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
783 | for field in TRANS_OMIT_PDF_FIELDS: |
---|
784 | form_fields = form_fields.omit(field) |
---|
785 | elif self.target is not None and self.target == 'tscs': |
---|
786 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
787 | for field in TRANS_SHORT_OMIT_PDF_FIELDS: |
---|
788 | form_fields = form_fields.omit(field) |
---|
789 | elif self.target is not None and self.target == 'ictwk': |
---|
790 | form_fields = grok.AutoFields(IUnibenRegistration) |
---|
791 | for field in REGISTRATION_OMIT_PDF_FIELDS: |
---|
792 | form_fields = form_fields.omit(field) |
---|
793 | elif self.target is not None and self.target.startswith('pg'): |
---|
794 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
795 | for field in PG_OMIT_PDF_FIELDS: |
---|
796 | form_fields = form_fields.omit(field) |
---|
797 | elif self.target is not None and self.target.startswith('pre'): |
---|
798 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
799 | for field in PRE_OMIT_PDF_FIELDS: |
---|
800 | form_fields = form_fields.omit(field) |
---|
801 | elif self.target is not None and self.target.startswith('cbt'): # uniben |
---|
802 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
803 | for field in CBT_OMIT_PDF_FIELDS: |
---|
804 | form_fields = form_fields.omit(field) |
---|
805 | elif self.target is not None and self.target.startswith('akj'): # uniben |
---|
806 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
807 | for field in PRE_OMIT_PDF_FIELDS: |
---|
808 | form_fields = form_fields.omit(field) |
---|
809 | elif self.target is not None and self.target.startswith('ak'): # uniben |
---|
810 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
811 | for field in AFFIL_OMIT_PDF_FIELDS: |
---|
812 | form_fields = form_fields.omit(field) |
---|
813 | elif self.target is not None and self.target.startswith('ase'): # was putme |
---|
814 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
815 | if self._reduced_slip(): |
---|
816 | for field in PUTME_OMIT_RESULT_SLIP_FIELDS: |
---|
817 | form_fields = form_fields.omit(field) |
---|
818 | else: |
---|
819 | for field in PUTME_OMIT_PDF_FIELDS: |
---|
820 | form_fields = form_fields.omit(field) |
---|
821 | elif self.target is not None and self.target.startswith('pt'): |
---|
822 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
823 | if self._reduced_slip(): |
---|
824 | for field in PT_OMIT_RESULT_SLIP_FIELDS: |
---|
825 | form_fields = form_fields.omit(field) |
---|
826 | else: |
---|
827 | for field in PT_OMIT_PDF_FIELDS: |
---|
828 | form_fields = form_fields.omit(field) |
---|
829 | elif self.target is not None and self.target.startswith('pude'): |
---|
830 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
831 | if self._reduced_slip(): |
---|
832 | for field in PUDE_OMIT_RESULT_SLIP_FIELDS: |
---|
833 | form_fields = form_fields.omit(field) |
---|
834 | else: |
---|
835 | for field in PUDE_OMIT_PDF_FIELDS: |
---|
836 | form_fields = form_fields.omit(field) |
---|
837 | elif self.target is not None and self.target == 'flc': |
---|
838 | form_fields = grok.AutoFields(IFrenchApplicant) |
---|
839 | for field in REGISTRATION_OMIT_PDF_FIELDS: |
---|
840 | form_fields = form_fields.omit(field) |
---|
841 | elif self.target is not None and self.target == 'afrimal': |
---|
842 | form_fields = grok.AutoFields(IAfrimalApplicant) |
---|
843 | for field in REGISTRATION_OMIT_PDF_FIELDS: |
---|
844 | form_fields = form_fields.omit(field) |
---|
845 | else: |
---|
846 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
847 | for field in UG_OMIT_PDF_FIELDS: |
---|
848 | form_fields = form_fields.omit(field) |
---|
849 | if not getattr(self.context, 'student_id'): |
---|
850 | form_fields = form_fields.omit('student_id') |
---|
851 | if not getattr(self.context, 'screening_score'): |
---|
852 | form_fields = form_fields.omit('screening_score') |
---|
853 | if not getattr(self.context, 'screening_venue'): |
---|
854 | form_fields = form_fields.omit('screening_venue') |
---|
855 | if not getattr(self.context, 'screening_date'): |
---|
856 | form_fields = form_fields.omit('screening_date') |
---|
857 | return form_fields |
---|
858 | |
---|
859 | @property |
---|
860 | def title(self): |
---|
861 | container_title = self.context.__parent__.title |
---|
862 | portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE |
---|
863 | ar_translation = translate(_('Application Record'), |
---|
864 | 'waeup.kofa', target_language=portal_language) |
---|
865 | if self.target == 'ictwk': |
---|
866 | return '%s - Registration Record %s' % (container_title, |
---|
867 | self.context.application_number) |
---|
868 | elif self.target.startswith('ab'): |
---|
869 | return 'Federal College of Education (Technical) Asaba - %s %s %s' % ( |
---|
870 | container_title, ar_translation, |
---|
871 | self.context.application_number) |
---|
872 | elif self.target.startswith('ak'): |
---|
873 | return 'Federal College of Education (Technical) Akoka - %s - %s %s' % ( |
---|
874 | container_title, ar_translation, |
---|
875 | self.context.application_number) |
---|
876 | elif self.target == 'pgn': |
---|
877 | return 'National Institute for Legislative Studies (NILS) - %s %s %s' % ( |
---|
878 | container_title, ar_translation, |
---|
879 | self.context.application_number) |
---|
880 | return '%s - %s %s' % (container_title, |
---|
881 | ar_translation, self.context.application_number) |
---|
882 | |
---|
883 | class CustomApplicantBaseDisplayFormPage(ApplicantBaseDisplayFormPage): |
---|
884 | |
---|
885 | @property |
---|
886 | def form_fields(self): |
---|
887 | target = getattr(self.context.__parent__, 'prefix', None) |
---|
888 | if target.startswith('tsc'): |
---|
889 | form_fields = grok.AutoFields(ICustomApplicant).select( |
---|
890 | 'applicant_id', 'email', 'dispatch_address') |
---|
891 | else: |
---|
892 | form_fields = grok.AutoFields(ICustomApplicant).select( |
---|
893 | 'applicant_id', 'reg_number', 'email', 'course1') |
---|
894 | if self.context.__parent__.prefix in ('special',): |
---|
895 | form_fields['reg_number'].field.title = u'Identification Number' |
---|
896 | return form_fields |
---|
897 | return form_fields |
---|
898 | |
---|
899 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
900 | """Deliver a PDF slip of the context. |
---|
901 | """ |
---|
902 | |
---|
903 | @property |
---|
904 | def omit_fields(self): |
---|
905 | target = getattr(self.context.__parent__.__parent__, 'prefix', None) |
---|
906 | if target.startswith('tsc'): |
---|
907 | return ('date_of_birth', 'course1') |
---|
908 | return () |
---|
909 | |
---|
910 | @property |
---|
911 | def note(self): |
---|
912 | return |
---|
913 | |
---|
914 | def render(self): |
---|
915 | if self.payment_slip_download_warning: |
---|
916 | self.flash(self.payment_slip_download_warning, type='danger') |
---|
917 | self.redirect(self.url(self.context)) |
---|
918 | return |
---|
919 | applicantview = CustomApplicantBaseDisplayFormPage(self.context.__parent__, |
---|
920 | self.request) |
---|
921 | students_utils = getUtility(IStudentsUtils) |
---|
922 | return students_utils.renderPDF(self,'payment_slip.pdf', |
---|
923 | self.context.__parent__, applicantview, |
---|
924 | note=self.note, omit_fields=self.omit_fields) |
---|
925 | |
---|
926 | class ExportScreeningInvitationSlip(UtilityView, grok.View): |
---|
927 | """Deliver a PDF slip of the context. |
---|
928 | """ |
---|
929 | grok.context(ICustomApplicant) |
---|
930 | grok.name('screening_invitation_slip.pdf') |
---|
931 | grok.require('waeup.viewApplication') |
---|
932 | form_fields = None |
---|
933 | label = u'Invitation Letter for Pre-Admission Screening' |
---|
934 | |
---|
935 | |
---|
936 | @property |
---|
937 | def note(self): |
---|
938 | notice = getattr(self.context.__parent__, 'application_slip_notice') |
---|
939 | if notice is None: |
---|
940 | notice = '' |
---|
941 | if self.context.screening_date: |
---|
942 | return """ |
---|
943 | <br /><br /><br /><br /><font size='12'> |
---|
944 | Dear %s, |
---|
945 | <br /><br /><br /> |
---|
946 | You are invited for your Uniben Admission Screening Exercise on: |
---|
947 | <br /><br /> |
---|
948 | <strong>%s</strong>. |
---|
949 | <br /><br /> |
---|
950 | Please bring along this letter of invitation to the |
---|
951 | <br /><br /> |
---|
952 | <strong>%s</strong> |
---|
953 | <br /><br /> |
---|
954 | on your screening date. |
---|
955 | <br /><br /><br /> |
---|
956 | Signed, |
---|
957 | <br /><br /> |
---|
958 | The Registrar<br /> |
---|
959 | <br /><br /> |
---|
960 | <br /><br /> |
---|
961 | %s |
---|
962 | </font> |
---|
963 | |
---|
964 | """ % (self.context.display_fullname, self.context.screening_date, |
---|
965 | self.context.screening_venue, notice) |
---|
966 | return |
---|
967 | |
---|
968 | def update(self): |
---|
969 | if not self.context.screening_date: |
---|
970 | self.flash(_('Forbidden'), type="warning") |
---|
971 | self.redirect(self.url(self.context)) |
---|
972 | |
---|
973 | def render(self): |
---|
974 | applicantview = ApplicantBaseDisplayFormPage(self.context, self.request) |
---|
975 | students_utils = getUtility(IStudentsUtils) |
---|
976 | return students_utils.renderPDF(self,'screening_invitation_slip.pdf', |
---|
977 | self.context, applicantview, note=self.note) |
---|
978 | |
---|
979 | class CustomCheckTranscriptStatus(CheckTranscriptStatus): |
---|
980 | """A display page for checking transcript processing status. |
---|
981 | """ |
---|
982 | grok.template('checktranscriptstatus') |
---|
983 | |
---|
984 | websites = (('Uniben Alumni Portal', 'https://alumni.uniben.edu/'), |
---|
985 | ('Uniben Student Portal', 'https://waeup.uniben.edu/'),) |
---|
986 | appl_url1 = 'https://alumni.uniben.edu/applicants/tscf1/register' |
---|
987 | appl_url2 = 'https://alumni.uniben.edu/applicants/tscs1/register' |
---|
988 | |
---|
989 | class CreateGraduatedPage(UtilityView, grok.View): |
---|
990 | """Create a student object from transcript application data. |
---|
991 | """ |
---|
992 | grok.context(ICustomApplicant) |
---|
993 | grok.name('creategraduated') |
---|
994 | grok.require('waeup.createStudents') |
---|
995 | |
---|
996 | def update(self): |
---|
997 | success, msg = self.context.createStudent(view=self, graduated=True) |
---|
998 | if success: |
---|
999 | self.flash(msg) |
---|
1000 | else: |
---|
1001 | self.flash(msg, type='warning') |
---|
1002 | self.redirect(self.url(self.context)) |
---|
1003 | return |
---|
1004 | |
---|
1005 | def render(self): |
---|
1006 | return |
---|
1007 | |
---|
1008 | class ResultStatement(AdditionalFile): |
---|
1009 | grok.name('res_stat') |
---|
1010 | |
---|
1011 | class EligibilityForm(AdditionalFile): |
---|
1012 | grok.name('eligibility') |
---|