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