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