1 | ## $Id: browser.py 16786 2022-02-08 21:35: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 | import os |
---|
22 | from zope.component import getUtility, getAdapter |
---|
23 | from zope.i18n import translate |
---|
24 | from zope.catalog.interfaces import ICatalog |
---|
25 | from hurry.workflow.interfaces import IWorkflowState |
---|
26 | from waeup.kofa.interfaces import ( |
---|
27 | IExtFileStore, IFileStoreNameChooser, IKofaUtils) |
---|
28 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
29 | from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget |
---|
30 | from waeup.kofa.utils.helpers import string_from_bytes, file_size |
---|
31 | from waeup.kofa.applicants.browser import ( |
---|
32 | ApplicantCheckStatusPage, |
---|
33 | AdditionalFile, |
---|
34 | RefereeReportAddFormPage, |
---|
35 | RefereeReportDisplayFormPage, |
---|
36 | ExportPDFReportSlipPage, |
---|
37 | ExportPDFReportSlipPage2) |
---|
38 | from waeup.kofa.applicants.workflow import STARTED, PAID |
---|
39 | from waeup.kofa.applicants.viewlets import PDFActionButton |
---|
40 | from waeup.kofa.applicants.interfaces import IApplicantRegisterUpdate |
---|
41 | from waeup.kofa.browser.layout import UtilityView, action |
---|
42 | from waeup.kofa.students.interfaces import IStudentsUtils |
---|
43 | from waeup.kofa.interfaces import IPDF |
---|
44 | from waeup.kofa.browser.viewlets import ManageActionButton |
---|
45 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
46 | from kofacustom.nigeria.applicants.browser import ( |
---|
47 | NigeriaApplicantDisplayFormPage, |
---|
48 | NigeriaApplicantManageFormPage, |
---|
49 | NigeriaApplicantEditFormPage, |
---|
50 | NigeriaPDFApplicationSlip, |
---|
51 | NigeriaApplicantRegistrationPage, |
---|
52 | NigeriaExportPDFPaymentSlipPage, |
---|
53 | ) |
---|
54 | from kofacustom.nigeria.applicants.interfaces import OMIT_DISPLAY_FIELDS |
---|
55 | from waeup.aaue.applicants.interfaces import ( |
---|
56 | ICustomUGApplicant, |
---|
57 | ICustomPGApplicant, |
---|
58 | ICustomUGApplicantEdit, |
---|
59 | ICustomPGApplicantEdit, |
---|
60 | ITranscriptApplicant, |
---|
61 | ICertificateRequest, |
---|
62 | ICustomApplicant, |
---|
63 | IVerificationRequest, |
---|
64 | ISendByEmailRequest, |
---|
65 | IFedexRequest, |
---|
66 | IRecruitment, |
---|
67 | ICustomApplicantOnlinePayment, |
---|
68 | ICustomApplicantRefereeReport, |
---|
69 | ) |
---|
70 | |
---|
71 | UG_OMIT_FIELDS = ( |
---|
72 | 'hq_type', 'hq_fname', 'hq_matric_no', |
---|
73 | 'hq_degree', 'hq_school', 'hq_session', 'hq_disc', |
---|
74 | 'hq_type2', 'hq_fname2', 'hq_matric_no2', |
---|
75 | 'hq_degree2', 'hq_school2', 'hq_session2', 'hq_disc2', |
---|
76 | 'hq_type3', 'hq_fname3', 'hq_matric_no3', |
---|
77 | 'hq_degree3', 'hq_school3', 'hq_session3', 'hq_disc3', |
---|
78 | 'nysc_year', |
---|
79 | 'nysc_location', |
---|
80 | 'nysc_lga', |
---|
81 | 'employer', |
---|
82 | 'emp_position', |
---|
83 | 'emp_start', |
---|
84 | 'emp_end', |
---|
85 | 'emp_reason', |
---|
86 | 'employer2', |
---|
87 | 'emp2_position', |
---|
88 | 'emp2_start', |
---|
89 | 'emp2_end', |
---|
90 | 'emp2_reason', |
---|
91 | 'former_matric', |
---|
92 | ) |
---|
93 | UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
94 | 'jamb_subjects_list', 'master_sheet_number') + UG_OMIT_FIELDS |
---|
95 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + UG_OMIT_FIELDS + ( |
---|
96 | 'alr_fname', 'alr_no', 'alr_date', |
---|
97 | 'alr_results', 'notice') |
---|
98 | UG_OMIT_MANAGE_FIELDS = ( |
---|
99 | 'special_application','jamb_subjects_list',) + UG_OMIT_FIELDS |
---|
100 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
101 | 'student_id', |
---|
102 | 'notice', |
---|
103 | 'jamb_age', |
---|
104 | 'jamb_subjects', |
---|
105 | 'jamb_score', |
---|
106 | 'jamb_reg_number', |
---|
107 | 'aggregate', |
---|
108 | 'master_sheet_number', |
---|
109 | 'screening_venue', |
---|
110 | 'screening_score', |
---|
111 | 'screening_date' |
---|
112 | ) |
---|
113 | |
---|
114 | UDE_OMIT_FIELDS = ( |
---|
115 | 'nysc_year', |
---|
116 | 'nysc_location', |
---|
117 | 'nysc_lga', |
---|
118 | 'employer', |
---|
119 | 'emp_position', |
---|
120 | 'emp_start', |
---|
121 | 'emp_end', |
---|
122 | 'emp_reason', |
---|
123 | 'employer2', |
---|
124 | 'emp2_position', |
---|
125 | 'emp2_start', |
---|
126 | 'emp2_end', |
---|
127 | 'emp2_reason', |
---|
128 | 'former_matric', |
---|
129 | ) |
---|
130 | UDE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
131 | 'jamb_subjects_list', 'master_sheet_number') + UDE_OMIT_FIELDS |
---|
132 | UDE_OMIT_PDF_FIELDS = UDE_OMIT_DISPLAY_FIELDS + UDE_OMIT_FIELDS + ( |
---|
133 | #'alr_fname', 'alr_no', 'alr_date', 'alr_results', |
---|
134 | 'hq_type2', 'hq_fname2', 'hq_matric_no2', |
---|
135 | 'hq_degree2', 'hq_school2', 'hq_session2', 'hq_disc2', |
---|
136 | 'hq_type3', 'hq_fname3', 'hq_matric_no3', |
---|
137 | 'hq_degree3', 'hq_school3', 'hq_session3', 'hq_disc3', |
---|
138 | 'notice') |
---|
139 | UDE_OMIT_MANAGE_FIELDS = ( |
---|
140 | 'special_application','jamb_subjects_list',) + UDE_OMIT_FIELDS |
---|
141 | UDE_OMIT_EDIT_FIELDS = UDE_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
142 | 'student_id', |
---|
143 | 'notice', |
---|
144 | 'jamb_age', |
---|
145 | 'jamb_subjects', |
---|
146 | 'jamb_score', |
---|
147 | 'jamb_reg_number', |
---|
148 | 'aggregate', |
---|
149 | 'master_sheet_number', |
---|
150 | 'screening_venue', |
---|
151 | 'screening_score', |
---|
152 | 'screening_date' |
---|
153 | ) |
---|
154 | |
---|
155 | #UG_OMIT_PDF_FIELDS = tuple([ |
---|
156 | # element for element in UG_OMIT_PDF_FIELDS if not element == 'phone']) |
---|
157 | |
---|
158 | #UG_OMIT_PDF_FIELDS += ( |
---|
159 | # 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
160 | # 'alr_results', 'notice' |
---|
161 | # ) |
---|
162 | |
---|
163 | PG_OMIT_FIELDS = ( |
---|
164 | |
---|
165 | ) |
---|
166 | PG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
167 | ) + PG_OMIT_FIELDS |
---|
168 | PG_OMIT_PDF_FIELDS = PG_OMIT_DISPLAY_FIELDS + PG_OMIT_FIELDS + ( |
---|
169 | ) |
---|
170 | PG_OMIT_MANAGE_FIELDS = ( |
---|
171 | ) + PG_OMIT_FIELDS |
---|
172 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
173 | ) |
---|
174 | |
---|
175 | PTEE_OMIT_FIELDS = ( |
---|
176 | 'jamb_age', |
---|
177 | 'jamb_subjects', |
---|
178 | 'jamb_score', |
---|
179 | 'jamb_reg_number', |
---|
180 | 'aggregate' |
---|
181 | ) |
---|
182 | PTEE_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ( |
---|
183 | 'jamb_subjects_list',) + PTEE_OMIT_FIELDS |
---|
184 | PTEE_OMIT_PDF_FIELDS = PTEE_OMIT_DISPLAY_FIELDS + PTEE_OMIT_FIELDS + ( |
---|
185 | 'reg_number','alr_fname', 'alr_no', 'alr_date', |
---|
186 | 'alr_results', 'notice', |
---|
187 | 'nysc_year', |
---|
188 | 'nysc_location', |
---|
189 | 'nysc_lga', |
---|
190 | 'employer', |
---|
191 | 'emp_position', |
---|
192 | 'emp_start', |
---|
193 | 'emp_end', |
---|
194 | 'emp_reason', |
---|
195 | 'employer2', |
---|
196 | 'emp2_position', |
---|
197 | 'emp2_start', |
---|
198 | 'emp2_end', |
---|
199 | 'emp2_reason', |
---|
200 | 'former_matric', |
---|
201 | ) |
---|
202 | PTEE_OMIT_MANAGE_FIELDS = ( |
---|
203 | 'special_application','jamb_subjects_list',) + PTEE_OMIT_FIELDS |
---|
204 | PTEE_OMIT_EDIT_FIELDS = PTEE_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
205 | 'student_id', |
---|
206 | 'notice', |
---|
207 | ) |
---|
208 | |
---|
209 | UPDATE_OMIT_FIELDS = ( |
---|
210 | 'firstname', |
---|
211 | 'middlename', |
---|
212 | 'lastname', |
---|
213 | 'sex', |
---|
214 | 'lga', |
---|
215 | 'course1', |
---|
216 | ) |
---|
217 | |
---|
218 | MAX_FILE_UPLOAD_SIZE = 1024 * 500 |
---|
219 | |
---|
220 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
221 | """A display view for applicant data. |
---|
222 | """ |
---|
223 | |
---|
224 | @property |
---|
225 | def form_fields(self): |
---|
226 | if self.target is not None and self.target == 'trans': |
---|
227 | form_fields = grok.AutoFields(ITranscriptApplicant).omit( |
---|
228 | 'locked', 'suspended') |
---|
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 == 'ver': |
---|
233 | form_fields = grok.AutoFields(IVerificationRequest).omit( |
---|
234 | 'locked', 'suspended') |
---|
235 | form_fields['body_address'].custom_widget = BytesDisplayWidget |
---|
236 | return form_fields |
---|
237 | if self.target is not None and self.target == 'fedex': |
---|
238 | form_fields = grok.AutoFields(IFedexRequest).omit( |
---|
239 | 'locked', 'suspended') |
---|
240 | return form_fields |
---|
241 | if self.target is not None and self.target == 'rec': |
---|
242 | form_fields = grok.AutoFields(IRecruitment).omit( |
---|
243 | 'locked', 'suspended') |
---|
244 | form_fields['address'].custom_widget = BytesDisplayWidget |
---|
245 | form_fields['position'].custom_widget = BytesDisplayWidget |
---|
246 | return form_fields |
---|
247 | if self.target is not None and self.target == 'send': |
---|
248 | form_fields = grok.AutoFields(ISendByEmailRequest).omit( |
---|
249 | 'locked', 'suspended') |
---|
250 | form_fields['body_address'].custom_widget = BytesDisplayWidget |
---|
251 | return form_fields |
---|
252 | if self.target is not None and self.target == 'cert': |
---|
253 | form_fields = grok.AutoFields(ICertificateRequest).omit( |
---|
254 | 'locked', 'suspended') |
---|
255 | return form_fields |
---|
256 | if self.target is not None and self.target in ('ptee','dsh',): |
---|
257 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
258 | for field in PTEE_OMIT_DISPLAY_FIELDS: |
---|
259 | form_fields = form_fields.omit(field) |
---|
260 | elif self.target is not None and self.target in ('bridge', 'ude',): |
---|
261 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
262 | for field in UDE_OMIT_DISPLAY_FIELDS: |
---|
263 | form_fields = form_fields.omit(field) |
---|
264 | elif self.target is not None and self.target.startswith('pg'): |
---|
265 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
266 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
267 | form_fields = form_fields.omit(field) |
---|
268 | else: |
---|
269 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
270 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
271 | form_fields = form_fields.omit(field) |
---|
272 | if not getattr(self.context, 'student_id'): |
---|
273 | form_fields = form_fields.omit('student_id') |
---|
274 | if not getattr(self.context, 'screening_score'): |
---|
275 | form_fields = form_fields.omit('screening_score') |
---|
276 | if not getattr(self.context, 'screening_venue') or \ |
---|
277 | self.context.state not in ('submitted', 'admitted', 'created'): |
---|
278 | form_fields = form_fields.omit('screening_venue') |
---|
279 | if not getattr(self.context, 'screening_date') or \ |
---|
280 | self.context.state not in ('submitted', 'admitted', 'created'): |
---|
281 | form_fields = form_fields.omit('screening_date') |
---|
282 | return form_fields |
---|
283 | |
---|
284 | def getCourseAdmitted(self): |
---|
285 | """Return link, title and code in html format to the certificate |
---|
286 | admitted. |
---|
287 | """ |
---|
288 | if self.layout.isApplicant(): |
---|
289 | return '' |
---|
290 | course_admitted = self.context.course_admitted |
---|
291 | if getattr(course_admitted, '__parent__',None): |
---|
292 | url = self.url(course_admitted) |
---|
293 | title = course_admitted.title |
---|
294 | code = course_admitted.code |
---|
295 | return '<a href="%s">%s - %s</a>' %(url,code,title) |
---|
296 | return '' |
---|
297 | |
---|
298 | class CustomPDFActionButton(PDFActionButton): |
---|
299 | |
---|
300 | @property |
---|
301 | def target_url(self): |
---|
302 | if self.context.state in ('initialized', 'started', 'paid'): |
---|
303 | # or self.context.special or self.view.target in ('trans', 'cert'): |
---|
304 | return |
---|
305 | return self.view.url(self.view.context, self.target) |
---|
306 | |
---|
307 | |
---|
308 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
309 | |
---|
310 | column_two_fields = ('applicant_id', 'reg_number', |
---|
311 | 'firstname', 'middlename', 'lastname', 'sex', 'date_of_birth') |
---|
312 | #two_columns_design_fields = [ |
---|
313 | # 'fst_sit_fname', 'fst_sit_no', 'fst_sit_date', |
---|
314 | # 'fst_sit_type', 'fst_sit_results', |
---|
315 | # 'scd_sit_fname', 'scd_sit_no', 'scd_sit_date', |
---|
316 | # 'scd_sit_type', 'scd_sit_results'] |
---|
317 | |
---|
318 | def _getCourseAdmittedLink(self, view): |
---|
319 | return None |
---|
320 | |
---|
321 | def _getDeptAndFaculty(self): |
---|
322 | return [None, None] |
---|
323 | |
---|
324 | @property |
---|
325 | def note(self): |
---|
326 | note = getattr(self.context.__parent__, 'application_slip_notice', None) |
---|
327 | if note: |
---|
328 | return '<br /><br />' + note |
---|
329 | if self.target is not None and self.target in ( |
---|
330 | 'trans', 'cert', 'ver', 'send', 'fedex'): |
---|
331 | return |
---|
332 | if self.context.sex == 'm': |
---|
333 | pronoun = 'he' |
---|
334 | else: |
---|
335 | pronoun = 'she' |
---|
336 | return ''' |
---|
337 | The applicant has acknowledged that, if discovered at any time that %s does not possess |
---|
338 | any of the qualifications which %s claims %s has obtained, %s will be expelled from the |
---|
339 | University not be re-admitted for the same or any other programme, even if %s has |
---|
340 | upgraded previous qualifications or possess additional qualifications. |
---|
341 | |
---|
342 | ''' % ( |
---|
343 | pronoun, pronoun, pronoun, pronoun, pronoun) |
---|
344 | |
---|
345 | @property |
---|
346 | def form_fields(self): |
---|
347 | # AAUE is using the same interface for all regular applications. |
---|
348 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
349 | if self.target is not None and self.target.startswith('pg'): |
---|
350 | for field in PG_OMIT_PDF_FIELDS: |
---|
351 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
352 | form_fields = form_fields.omit(field) |
---|
353 | elif self.target is not None and self.target in ('ptee', 'dsh',): |
---|
354 | for field in PTEE_OMIT_PDF_FIELDS: |
---|
355 | form_fields = form_fields.omit(field) |
---|
356 | elif self.target is not None and self.target in ('bridge', 'ude',): |
---|
357 | for field in UDE_OMIT_PDF_FIELDS: |
---|
358 | form_fields = form_fields.omit(field) |
---|
359 | elif self.target is not None and self.target == 'trans': |
---|
360 | form_fields = grok.AutoFields(ITranscriptApplicant).omit( |
---|
361 | 'locked', 'suspended') |
---|
362 | elif self.target is not None and self.target == 'ver': |
---|
363 | form_fields = grok.AutoFields(IVerificationRequest).omit( |
---|
364 | 'locked', 'suspended') |
---|
365 | elif self.target is not None and self.target == 'send': |
---|
366 | form_fields = grok.AutoFields(ISendByEmailRequest).omit( |
---|
367 | 'locked', 'suspended') |
---|
368 | elif self.target is not None and self.target == 'cert': |
---|
369 | form_fields = grok.AutoFields(ICertificateRequest).omit( |
---|
370 | 'locked', 'suspended') |
---|
371 | elif self.target is not None and self.target == 'fedex': |
---|
372 | form_fields = grok.AutoFields(IFedexRequest).omit( |
---|
373 | 'locked', 'suspended') |
---|
374 | else: |
---|
375 | for field in UG_OMIT_PDF_FIELDS: |
---|
376 | form_fields = form_fields.omit(field) |
---|
377 | if not getattr(self.context, 'student_id'): |
---|
378 | form_fields = form_fields.omit('student_id') |
---|
379 | if not getattr(self.context, 'screening_score'): |
---|
380 | form_fields = form_fields.omit('screening_score') |
---|
381 | if not getattr(self.context, 'screening_venue'): |
---|
382 | form_fields = form_fields.omit('screening_venue') |
---|
383 | if not getattr(self.context, 'screening_date'): |
---|
384 | form_fields = form_fields.omit('screening_date') |
---|
385 | hqfields = ('hq_type', 'hq_fname', 'hq_matric_no', |
---|
386 | 'hq_degree', 'hq_school', 'hq_session', 'hq_disc') |
---|
387 | if not getattr(self.context, 'hq_type'): |
---|
388 | for hq in hqfields: |
---|
389 | form_fields = form_fields.omit(hq) |
---|
390 | if not getattr(self.context, 'hq_type2'): |
---|
391 | for hq in hqfields: |
---|
392 | form_fields = form_fields.omit(hq + '2') |
---|
393 | if not getattr(self.context, 'hq_type3'): |
---|
394 | for hq in hqfields: |
---|
395 | form_fields = form_fields.omit(hq + '3') |
---|
396 | if not getattr(self.context, 'hq_type4'): |
---|
397 | for hq in hqfields: |
---|
398 | form_fields = form_fields.omit(hq + '4') |
---|
399 | return form_fields |
---|
400 | |
---|
401 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
402 | """A full edit view for applicant data. |
---|
403 | """ |
---|
404 | |
---|
405 | def display_fileupload(self, filename): |
---|
406 | if filename[1] == 'stateresult': |
---|
407 | if self.target in ('trans', 'cert'): |
---|
408 | return True |
---|
409 | if filename[1] == 'verificationdoc': |
---|
410 | if self.target in ('ver', 'send'): |
---|
411 | return True |
---|
412 | return False |
---|
413 | |
---|
414 | @property |
---|
415 | def form_fields(self): |
---|
416 | if self.target is not None and self.target == 'trans': |
---|
417 | form_fields = grok.AutoFields(ITranscriptApplicant) |
---|
418 | form_fields['applicant_id'].for_display = True |
---|
419 | return form_fields |
---|
420 | if self.target is not None and self.target == 'cert': |
---|
421 | form_fields = grok.AutoFields(ICertificateRequest) |
---|
422 | form_fields['applicant_id'].for_display = True |
---|
423 | return form_fields |
---|
424 | if self.target is not None and self.target == 'ver': |
---|
425 | form_fields = grok.AutoFields(IVerificationRequest) |
---|
426 | form_fields['applicant_id'].for_display = True |
---|
427 | return form_fields |
---|
428 | if self.target is not None and self.target == 'send': |
---|
429 | form_fields = grok.AutoFields(ISendByEmailRequest) |
---|
430 | form_fields['applicant_id'].for_display = True |
---|
431 | return form_fields |
---|
432 | if self.target is not None and self.target == 'fedex': |
---|
433 | form_fields = grok.AutoFields(IFedexRequest) |
---|
434 | form_fields['applicant_id'].for_display = True |
---|
435 | return form_fields |
---|
436 | if self.target is not None and self.target == 'rec': |
---|
437 | form_fields = grok.AutoFields(IRecruitment) |
---|
438 | form_fields['applicant_id'].for_display = True |
---|
439 | return form_fields |
---|
440 | # AAUE is using the same interface for all regular applications. |
---|
441 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
442 | if self.target is not None and self.target.startswith('pg'): |
---|
443 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
444 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
445 | form_fields = form_fields.omit(field) |
---|
446 | elif self.target is not None and self.target in ('ptee', 'dsh',): |
---|
447 | for field in PTEE_OMIT_MANAGE_FIELDS: |
---|
448 | form_fields = form_fields.omit(field) |
---|
449 | elif self.target is not None and self.target in ('bridge', 'ude',): |
---|
450 | for field in UDE_OMIT_MANAGE_FIELDS: |
---|
451 | form_fields = form_fields.omit(field) |
---|
452 | else: |
---|
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 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
460 | """An applicant-centered edit view for applicant data. |
---|
461 | """ |
---|
462 | |
---|
463 | def display_fileupload(self, filename): |
---|
464 | if filename[1] == 'stateresult': |
---|
465 | if self.target in ('trans', 'cert'): |
---|
466 | return True |
---|
467 | if filename[1] == 'verificationdoc': |
---|
468 | if self.target in ('ver', 'send'): |
---|
469 | return True |
---|
470 | return False |
---|
471 | |
---|
472 | def unremovable(self, ticket): |
---|
473 | return True |
---|
474 | |
---|
475 | def dataNotComplete(self, data): |
---|
476 | store = getUtility(IExtFileStore) |
---|
477 | # Temporarily enable passport upload also for cert and trans |
---|
478 | # applications. |
---|
479 | if self.context.__parent__.with_picture: |
---|
480 | if not store.getFileByContext(self.context, attr=u'passport.jpg'): |
---|
481 | return _('No passport picture uploaded.') |
---|
482 | if not self.target in ('cert', 'trans') and \ |
---|
483 | not self.request.form.get('confirm_passport', False): |
---|
484 | return _('Passport picture confirmation box not ticked.') |
---|
485 | if self.target in ('trans', 'cert') and \ |
---|
486 | not store.getFileByContext(self.context, attr=u'stateresult'): |
---|
487 | return _('No statement of result pdf file uploaded.') |
---|
488 | if self.target in ('ver',) and \ |
---|
489 | not store.getFileByContext(self.context, attr=u'verificationdoc'): |
---|
490 | return _('No pdf file uploaded.') |
---|
491 | if self.target == 'fedex': |
---|
492 | cat = getUtility(ICatalog, name='applicants_catalog') |
---|
493 | results = list(cat.searchResults( |
---|
494 | applicant_id=(data['trans_id'], data['trans_id']))) |
---|
495 | if not results: |
---|
496 | return _('The transcript application id does not exist.') |
---|
497 | return False |
---|
498 | |
---|
499 | # AAUE applicants never see the 'Remove Selected Tickets' button. |
---|
500 | @property |
---|
501 | def display_actions(self): |
---|
502 | # If the form is unlocked, applicants are allowed to save the form |
---|
503 | # and remove unused tickets. |
---|
504 | actions = [[_('Save')], []] |
---|
505 | # Only in state started they can also add tickets. |
---|
506 | if self.context.state == STARTED: |
---|
507 | actions = [[_('Save')], |
---|
508 | [_('Add online payment ticket')]] |
---|
509 | # In state paid, they can submit the data and further add tickets |
---|
510 | # if the application is special. |
---|
511 | elif self.context.special and self.context.state == PAID: |
---|
512 | actions = [[_('Save'), _('Finally Submit')], |
---|
513 | [_('Add online payment ticket')]] |
---|
514 | elif self.context.state == PAID: |
---|
515 | actions = [[_('Save'), _('Finally Submit')], []] |
---|
516 | return actions |
---|
517 | |
---|
518 | @property |
---|
519 | def form_fields(self): |
---|
520 | if self.target is not None and self.target == 'trans': |
---|
521 | form_fields = grok.AutoFields(ITranscriptApplicant).omit( |
---|
522 | 'locked', 'suspended') |
---|
523 | form_fields['applicant_id'].for_display = True |
---|
524 | form_fields['reg_number'].for_display = True |
---|
525 | form_fields['place_of_birth'].field.required = True |
---|
526 | form_fields['date_of_birth'].field.required = True |
---|
527 | form_fields['nationality'].field.required = True |
---|
528 | form_fields['email'].field.required = True |
---|
529 | form_fields['phone'].field.required = True |
---|
530 | form_fields['perm_address'].field.required = True |
---|
531 | form_fields['dispatch_address'].field.required = True |
---|
532 | form_fields['entry_mode'].field.required = True |
---|
533 | form_fields['entry_session'].field.required = True |
---|
534 | form_fields['end_session'].field.required = True |
---|
535 | form_fields['course_studied'].field.required = True |
---|
536 | return form_fields |
---|
537 | if self.target is not None and self.target == 'cert': |
---|
538 | form_fields = grok.AutoFields(ICertificateRequest).omit( |
---|
539 | 'locked', 'suspended') |
---|
540 | form_fields['applicant_id'].for_display = True |
---|
541 | form_fields['reg_number'].for_display = True |
---|
542 | form_fields['place_of_birth'].field.required = True |
---|
543 | form_fields['date_of_birth'].field.required = True |
---|
544 | form_fields['nationality'].field.required = True |
---|
545 | form_fields['email'].field.required = True |
---|
546 | form_fields['phone'].field.required = True |
---|
547 | form_fields['entry_session'].field.required = True |
---|
548 | form_fields['end_session'].field.required = True |
---|
549 | form_fields['course_studied'].field.required = True |
---|
550 | form_fields['certificate_type'].field.required = True |
---|
551 | # Additional omissions |
---|
552 | if self.context.__parent__.code == 'cert5': |
---|
553 | for field in ('firstname', 'middlename', 'lastname'): |
---|
554 | form_fields[field].for_display = True |
---|
555 | return form_fields |
---|
556 | if self.target is not None and self.target == 'ver': |
---|
557 | form_fields = grok.AutoFields(IVerificationRequest).omit( |
---|
558 | 'locked', 'suspended') |
---|
559 | form_fields['applicant_id'].for_display = True |
---|
560 | return form_fields |
---|
561 | if self.target is not None and self.target == 'send': |
---|
562 | form_fields = grok.AutoFields(ISendByEmailRequest).omit( |
---|
563 | 'locked', 'suspended') |
---|
564 | form_fields['applicant_id'].for_display = True |
---|
565 | return form_fields |
---|
566 | if self.target is not None and self.target == 'fedex': |
---|
567 | form_fields = grok.AutoFields(IFedexRequest).omit( |
---|
568 | 'locked', 'suspended') |
---|
569 | form_fields['applicant_id'].for_display = True |
---|
570 | return form_fields |
---|
571 | if self.target is not None and self.target == 'rec': |
---|
572 | form_fields = grok.AutoFields(IRecruitment).omit( |
---|
573 | 'locked', 'suspended') |
---|
574 | form_fields['applicant_id'].for_display = True |
---|
575 | return form_fields |
---|
576 | # AAUE is using the same interface for all regular applications. |
---|
577 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
578 | if self.target is not None and self.target.startswith('pg'): |
---|
579 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
580 | for field in PG_OMIT_EDIT_FIELDS: |
---|
581 | form_fields = form_fields.omit(field) |
---|
582 | form_fields['screening_venue'].for_display = True |
---|
583 | form_fields['screening_date'].for_display = True |
---|
584 | form_fields['screening_score'].for_display = True |
---|
585 | form_fields['student_id'].for_display = True |
---|
586 | form_fields['notice'].for_display = True |
---|
587 | elif self.target is not None and self.target in ('ptee','dsh',): |
---|
588 | for field in PTEE_OMIT_EDIT_FIELDS: |
---|
589 | form_fields = form_fields.omit(field) |
---|
590 | elif self.target is not None and self.target in ('bridge', 'ude',): |
---|
591 | for field in UDE_OMIT_EDIT_FIELDS: |
---|
592 | form_fields = form_fields.omit(field) |
---|
593 | else: |
---|
594 | for field in UG_OMIT_EDIT_FIELDS: |
---|
595 | form_fields = form_fields.omit(field) |
---|
596 | # Additional omissions |
---|
597 | if self.target is not None and self.target in ('ude', 'utme'): |
---|
598 | for field in UPDATE_OMIT_FIELDS: |
---|
599 | form_fields[field].for_display = True |
---|
600 | form_fields['applicant_id'].for_display = True |
---|
601 | form_fields['reg_number'].for_display = True |
---|
602 | return form_fields |
---|
603 | |
---|
604 | def update(self): |
---|
605 | if self.context.locked or ( |
---|
606 | self.context.__parent__.expired and |
---|
607 | self.context.__parent__.strict_deadline): |
---|
608 | self.emit_lock_message() |
---|
609 | return |
---|
610 | if getattr( |
---|
611 | self.context.course1, 'code', 'nocourse') == self.request.form.get( |
---|
612 | 'form.course2', None): |
---|
613 | self.flash(_('2nd choice course must differ from 1st choice course.'), |
---|
614 | type='danger') |
---|
615 | self.redirect(self.url(self.context)) |
---|
616 | return |
---|
617 | if getattr( |
---|
618 | self.context.course1, 'code', 'nocourse') == self.request.form.get( |
---|
619 | 'form.course3', None): |
---|
620 | self.flash(_('3rd choice course must differ from 1st choice course.'), |
---|
621 | type='danger') |
---|
622 | self.redirect(self.url(self.context)) |
---|
623 | return |
---|
624 | super(CustomApplicantEditFormPage, self).update() |
---|
625 | return |
---|
626 | |
---|
627 | class CustomApplicantRegistrationPage(NigeriaApplicantRegistrationPage): |
---|
628 | """Captcha'd registration page for applicants. |
---|
629 | """ |
---|
630 | |
---|
631 | @property |
---|
632 | def form_fields(self): |
---|
633 | form_fields = None |
---|
634 | if self.context.mode == 'update': |
---|
635 | form_fields = grok.AutoFields(IApplicantRegisterUpdate).select( |
---|
636 | 'lastname','reg_number','email') |
---|
637 | target = getattr(self.context, 'prefix', None) |
---|
638 | if target in ('trans', 'cert'): |
---|
639 | form_fields.get('reg_number').field.title = u'Matriculation Number' |
---|
640 | else: #if self.context.mode == 'create': |
---|
641 | form_fields = grok.AutoFields(ICustomUGApplicantEdit).select( |
---|
642 | 'firstname', 'middlename', 'lastname', 'email', 'phone') |
---|
643 | return form_fields |
---|
644 | |
---|
645 | def _redirect(self, email, password, applicant_id): |
---|
646 | # Forward email and credentials to landing page. |
---|
647 | self.redirect(self.url(self.context, 'registration_complete', |
---|
648 | data = dict(email=email, password=password, |
---|
649 | applicant_id=applicant_id))) |
---|
650 | return |
---|
651 | |
---|
652 | @property |
---|
653 | def _postfix(self): |
---|
654 | """Alumni records have to be imported into several containers. |
---|
655 | Therefore a string must be added to their registration number |
---|
656 | to make it unique. |
---|
657 | """ |
---|
658 | if self.context.prefix in ('trans', 'cert'): |
---|
659 | return self.context.code |
---|
660 | return '' |
---|
661 | |
---|
662 | class ApplicantBaseDisplayFormPage(CustomApplicantDisplayFormPage): |
---|
663 | grok.context(ICustomApplicant) |
---|
664 | grok.name('base') |
---|
665 | |
---|
666 | @property |
---|
667 | def form_fields(self): |
---|
668 | if self.context.__parent__.prefix in ('fedex',): |
---|
669 | form_fields = grok.AutoFields(IFedexRequest).select( |
---|
670 | 'applicant_id', 'trans_id', 'email',) |
---|
671 | else: |
---|
672 | form_fields = grok.AutoFields(ICustomApplicant).select( |
---|
673 | 'applicant_id', 'reg_number', 'email', 'course1') |
---|
674 | if self.context.__parent__.prefix in ('special',): |
---|
675 | form_fields['reg_number'].field.title = u'Identification Number' |
---|
676 | return form_fields |
---|
677 | return form_fields |
---|
678 | |
---|
679 | class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage): |
---|
680 | |
---|
681 | form_fields = grok.AutoFields(ICustomApplicantOnlinePayment).omit( |
---|
682 | 'ac', 'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item', |
---|
683 | 'p_split_data') |
---|
684 | form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
685 | form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
686 | |
---|
687 | @property |
---|
688 | def payment_slip_download_warning(self): |
---|
689 | return '' |
---|
690 | |
---|
691 | def render(self): |
---|
692 | if self.payment_slip_download_warning: |
---|
693 | self.flash(self.payment_slip_download_warning, type='danger') |
---|
694 | self.redirect(self.url(self.context)) |
---|
695 | return |
---|
696 | applicantview = ApplicantBaseDisplayFormPage(self.context.__parent__, |
---|
697 | self.request) |
---|
698 | students_utils = getUtility(IStudentsUtils) |
---|
699 | return students_utils.renderPDF(self,'payment_slip.pdf', |
---|
700 | self.context.__parent__, applicantview, note=self.note) |
---|
701 | |
---|
702 | class CustomApplicantCheckStatusPage(ApplicantCheckStatusPage): |
---|
703 | """Captcha'd status checking page for applicants. |
---|
704 | """ |
---|
705 | grok.template('applicantcheckstatus') |
---|
706 | |
---|
707 | class ScreeningInvitationActionButton(ManageActionButton): |
---|
708 | grok.order(8) # This button should always be the last one. |
---|
709 | grok.context(ICustomApplicant) |
---|
710 | grok.view(CustomApplicantDisplayFormPage) |
---|
711 | grok.require('waeup.viewApplication') |
---|
712 | icon = 'actionicon_pdf.png' |
---|
713 | text = _('Download screening invitation letter') |
---|
714 | target = 'screening_invitation.pdf' |
---|
715 | |
---|
716 | @property |
---|
717 | def target_url(self): |
---|
718 | if not self.context.screening_date or not self.context.state in ( |
---|
719 | 'submitted', 'admitted', 'created'): |
---|
720 | return '' |
---|
721 | return self.view.url(self.view.context, self.target) |
---|
722 | |
---|
723 | class ExportScreeningInvitationLetter(UtilityView, grok.View): |
---|
724 | """Deliver a slip with only screening data. |
---|
725 | This form page is available only in AAUE. |
---|
726 | """ |
---|
727 | grok.context(ICustomApplicant) |
---|
728 | grok.name('screening_invitation.pdf') |
---|
729 | grok.require('waeup.viewApplication') |
---|
730 | prefix = 'form' |
---|
731 | |
---|
732 | label = u'Screening Invitation Letter' |
---|
733 | |
---|
734 | form_fields = [] |
---|
735 | |
---|
736 | @property |
---|
737 | def note(self): |
---|
738 | if self.context.screening_date: |
---|
739 | year = self.context.__parent__.year |
---|
740 | session = '%s/%s' % (year, year + 1) |
---|
741 | sdate = self.context.screening_date |
---|
742 | stime = '' |
---|
743 | if '@' in self.context.screening_date: |
---|
744 | sdate = self.context.screening_date.split('@')[0].strip() |
---|
745 | stime = self.context.screening_date.split('@')[1].strip() |
---|
746 | return """ |
---|
747 | <br /><br /><br /><br /><font size='12'> |
---|
748 | Dear %s, |
---|
749 | <br /><br /> |
---|
750 | You are invited to the Ambrose Alli University %s Admissions Screening Exercise. |
---|
751 | <br /><br /> |
---|
752 | <strong>Date: %s |
---|
753 | <br /><br /> |
---|
754 | Time: %s |
---|
755 | <br /><br /> |
---|
756 | Venue: %s |
---|
757 | </strong> |
---|
758 | <br /><br /> |
---|
759 | Please bring this letter of invitation and the downloaded application form along with you on your screening date. |
---|
760 | <br /><br /> |
---|
761 | You are expected to be available 30 minutes before the commencement of your Screening. |
---|
762 | </font> |
---|
763 | |
---|
764 | """ % ( |
---|
765 | self.context.display_fullname, |
---|
766 | session, |
---|
767 | sdate, |
---|
768 | stime, |
---|
769 | self.context.screening_venue) |
---|
770 | return |
---|
771 | |
---|
772 | @property |
---|
773 | def title(self): |
---|
774 | return None |
---|
775 | |
---|
776 | def update(self): |
---|
777 | if not self.context.screening_date or not self.context.state in ( |
---|
778 | 'submitted', 'admitted', 'created'): |
---|
779 | self.flash(_('Forbidden'), type="warning") |
---|
780 | self.redirect(self.url(self.context)) |
---|
781 | |
---|
782 | def render(self): |
---|
783 | applicantview = ApplicantBaseDisplayFormPage(self.context, self.request) |
---|
784 | students_utils = getUtility(IStudentsUtils) |
---|
785 | return students_utils.renderPDF(self,'screening_data.pdf', |
---|
786 | self.context, applicantview, note=self.note) |
---|
787 | |
---|
788 | class CustomRefereeReportAddFormPage(RefereeReportAddFormPage): |
---|
789 | """Add-form to add an referee report. This form |
---|
790 | is protected by a mandate. |
---|
791 | """ |
---|
792 | form_fields = grok.AutoFields( |
---|
793 | ICustomApplicantRefereeReport).omit('creation_date') |
---|
794 | |
---|
795 | class CustomRefereeReportDisplayFormPage(RefereeReportDisplayFormPage): |
---|
796 | """A display view for referee reports. |
---|
797 | """ |
---|
798 | form_fields = grok.AutoFields(ICustomApplicantRefereeReport) |
---|
799 | form_fields[ |
---|
800 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
801 | |
---|
802 | class CustomExportPDFReportSlipPage(ExportPDFReportSlipPage): |
---|
803 | form_fields = grok.AutoFields(ICustomApplicantRefereeReport) |
---|
804 | form_fields[ |
---|
805 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
806 | |
---|
807 | class CustomExportPDFReportSlipPage2(ExportPDFReportSlipPage2): |
---|
808 | form_fields = grok.AutoFields(ICustomApplicantRefereeReport) |
---|
809 | form_fields[ |
---|
810 | 'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') |
---|
811 | |
---|
812 | class StateResult(AdditionalFile): |
---|
813 | """Renders the pdf form extension for applicants. |
---|
814 | """ |
---|
815 | grok.name('stateresult') |
---|
816 | |
---|
817 | class VerificationDoc(AdditionalFile): |
---|
818 | """Renders the pdf form extension for applicants. |
---|
819 | """ |
---|
820 | grok.name('verificationdoc') |
---|