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