1 | # -*- coding: utf-8 -*- |
---|
2 | ## $Id: interfaces.py 18014 2025-02-12 01:22:42Z henrik $ |
---|
3 | ## |
---|
4 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
5 | ## This program is free software; you can redistribute it and/or modify |
---|
6 | ## it under the terms of the GNU General Public License as published by |
---|
7 | ## the Free Software Foundation; either version 2 of the License, or |
---|
8 | ## (at your option) any later version. |
---|
9 | ## |
---|
10 | ## This program is distributed in the hope that it will be useful, |
---|
11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | ## GNU General Public License for more details. |
---|
14 | ## |
---|
15 | ## You should have received a copy of the GNU General Public License |
---|
16 | ## along with this program; if not, write to the Free Software |
---|
17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
18 | ## |
---|
19 | """Customized interfaces of the university application package. |
---|
20 | """ |
---|
21 | |
---|
22 | #from grok import getSite |
---|
23 | import re |
---|
24 | from zope import schema |
---|
25 | from zope.interface import invariant, Invalid |
---|
26 | from zope.component import getUtility |
---|
27 | from zope.catalog.interfaces import ICatalog |
---|
28 | from zc.sourcefactory.basic import BasicSourceFactory |
---|
29 | from waeup.kofa.applicants.interfaces import ( |
---|
30 | IApplicantBaseData, |
---|
31 | AppCatCertificateSource, CertificateSource) |
---|
32 | from waeup.kofa.university.vocabularies import StudyModeSource |
---|
33 | from waeup.kofa.students.vocabularies import ( |
---|
34 | nats_vocab, GenderSource, StudyLevelSource) |
---|
35 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
36 | from waeup.kofa.interfaces import ( |
---|
37 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email, |
---|
38 | IKofaObject, ContextualDictSourceFactoryBase) |
---|
39 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
40 | from waeup.kofa.students.vocabularies import ( |
---|
41 | nats_vocab, GenderSource) |
---|
42 | from waeup.kofa.refereeentries import RefereeEntryField |
---|
43 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
44 | from kofacustom.nigeria.interfaces import DisabilitiesSource |
---|
45 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
46 | LGASource, high_qual, high_grade, exam_types, |
---|
47 | programme_types_vocab, jambsubjects, |
---|
48 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
49 | INigeriaApplicantOnlinePayment, |
---|
50 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
51 | INigeriaApplicantUpdateByRegNo, |
---|
52 | IPUTMEApplicantEdit, |
---|
53 | IBankAccount, |
---|
54 | ) |
---|
55 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
56 | from waeup.uniben.payments.interfaces import ICustomOnlinePayment |
---|
57 | |
---|
58 | |
---|
59 | # Define a validation method for JAMB reg numbers |
---|
60 | class NotMatricRegNumber(schema.ValidationError): |
---|
61 | __doc__ = u"Invalid matriculation number" |
---|
62 | |
---|
63 | #: Regular expression to check matric_number formats. |
---|
64 | check_matric_number = re.compile(r"^[^0-9\s][^\s]*$").match |
---|
65 | |
---|
66 | def validate_matric_number(value): |
---|
67 | if not check_matric_number(value): |
---|
68 | raise NotMatricRegNumber(value) |
---|
69 | return True |
---|
70 | |
---|
71 | class TranscriptCertificateSource(CertificateSource): |
---|
72 | """Include Department and Faculty in Title. |
---|
73 | """ |
---|
74 | def getValues(self, context): |
---|
75 | catalog = getUtility(ICatalog, name='certificates_catalog') |
---|
76 | resultset = catalog.searchResults(code=(None, None)) |
---|
77 | resultlist = sorted(resultset, key=lambda |
---|
78 | value: value.__parent__.__parent__.__parent__.code + |
---|
79 | value.__parent__.__parent__.code + |
---|
80 | value.code) |
---|
81 | return resultlist |
---|
82 | |
---|
83 | def getTitle(self, context, value): |
---|
84 | """ |
---|
85 | """ |
---|
86 | try: title = "%s / %s / %s (%s)" % ( |
---|
87 | value.__parent__.__parent__.__parent__.title, |
---|
88 | value.__parent__.__parent__.title, |
---|
89 | value.title, value.code) |
---|
90 | except AttributeError: |
---|
91 | title = "NA / %s (%s)" % (value.title, value.code) |
---|
92 | return title |
---|
93 | |
---|
94 | REGISTRATION_CATS = { |
---|
95 | 'corporate': ('Corporate Registration', 250000, 1), |
---|
96 | 'group': ('Group Registration', 200000, 2), |
---|
97 | 'individual': ('Individual Registration', 45000, 3), |
---|
98 | 'student': ('Student Registration', 5000, 4), |
---|
99 | 'fullpage': ('Full Page Advert', 250000, 5), |
---|
100 | 'halfpage': ('Half Page Advert', 150000, 6), |
---|
101 | 'quarterpage': ('Quarter Page Advert', 100000, 7), |
---|
102 | } |
---|
103 | |
---|
104 | class RegTypesSource(BasicSourceFactory): |
---|
105 | """A source that delivers all kinds of registrations. |
---|
106 | """ |
---|
107 | def getValues(self): |
---|
108 | sorted_items = sorted(REGISTRATION_CATS.items(), |
---|
109 | key=lambda element: element[1][2]) |
---|
110 | return [item[0] for item in sorted_items] |
---|
111 | |
---|
112 | def getTitle(self, value): |
---|
113 | return u"%s @ ₦ %s" % ( |
---|
114 | REGISTRATION_CATS[value][0], |
---|
115 | REGISTRATION_CATS[value][1]) |
---|
116 | |
---|
117 | DESTINATION_COST = { |
---|
118 | #'none': ('To the moon', 1000000000.0, 1), |
---|
119 | 'nigeria': ('Within Nigeria (deprecated)', 20000.0, 1), |
---|
120 | 'africa': ('Within Africa (deprecated)', 30000.0, 2), |
---|
121 | 'inter': ('International (deprecated)', 35000.0, 3), |
---|
122 | 'cert_nigeria': ('Certified Copy - Within Nigeria (deprecated)', 13000.0, 4), |
---|
123 | 'cert_africa': ('Certified Copy - Within Africa (deprecated)', 23000.0, 5), |
---|
124 | 'cert_inter': ('Certified Copy - International (deprecated)', 28000.0, 6), |
---|
125 | 'nigeria2': ('Local (Within Nigeria)', 25000.0, 1), |
---|
126 | 'inter2': ('International', 35000.0, 3), |
---|
127 | } |
---|
128 | |
---|
129 | class DestinationCostSource(BasicSourceFactory): |
---|
130 | """A source that delivers continents and shipment costs. |
---|
131 | """ |
---|
132 | def getValues(self): |
---|
133 | sorted_items = sorted(DESTINATION_COST.items(), |
---|
134 | key=lambda element: element[1][2]) |
---|
135 | return [item[0] for item in sorted_items] |
---|
136 | |
---|
137 | def getToken(self, value): |
---|
138 | return value |
---|
139 | |
---|
140 | def getTitle(self, value): |
---|
141 | return u"%s (₦ %s)" % ( |
---|
142 | DESTINATION_COST[value][0], |
---|
143 | DESTINATION_COST[value][1]) |
---|
144 | |
---|
145 | class OrderSource(BasicSourceFactory): |
---|
146 | """ |
---|
147 | """ |
---|
148 | def getValues(self): |
---|
149 | return ['o', 'c'] |
---|
150 | |
---|
151 | def getToken(self, value): |
---|
152 | return value |
---|
153 | |
---|
154 | def getTitle(self, value): |
---|
155 | if value == 'o': |
---|
156 | return _('Original') |
---|
157 | if value == 'c': |
---|
158 | return _('Certified True Copy') |
---|
159 | |
---|
160 | class ProficiencySource(BasicSourceFactory): |
---|
161 | """ |
---|
162 | """ |
---|
163 | def getValues(self): |
---|
164 | return ['n', 'c', 'p'] |
---|
165 | |
---|
166 | def getToken(self, value): |
---|
167 | return value |
---|
168 | |
---|
169 | def getTitle(self, value): |
---|
170 | if value == 'n': |
---|
171 | return _('none') |
---|
172 | if value == 'c': |
---|
173 | return _('conversational') |
---|
174 | if value == 'p': |
---|
175 | return _('professional') |
---|
176 | |
---|
177 | class PreferredSessionSource(BasicSourceFactory): |
---|
178 | """ |
---|
179 | """ |
---|
180 | def getValues(self): |
---|
181 | return ['m', 'e', 'w'] |
---|
182 | |
---|
183 | def getToken(self, value): |
---|
184 | return value |
---|
185 | |
---|
186 | def getTitle(self, value): |
---|
187 | if value == 'm': |
---|
188 | return _('morning') |
---|
189 | if value == 'e': |
---|
190 | return _('evening') |
---|
191 | if value == 'w': |
---|
192 | return _('weekend') |
---|
193 | |
---|
194 | class IUnibenRegistration(IKofaObject): |
---|
195 | """A Uniben registrant. |
---|
196 | """ |
---|
197 | |
---|
198 | suspended = schema.Bool( |
---|
199 | title = _(u'Account suspended'), |
---|
200 | default = False, |
---|
201 | required = False, |
---|
202 | ) |
---|
203 | |
---|
204 | locked = schema.Bool( |
---|
205 | title = _(u'Form locked'), |
---|
206 | default = False, |
---|
207 | required = False, |
---|
208 | ) |
---|
209 | |
---|
210 | applicant_id = schema.TextLine( |
---|
211 | title = _(u'Registrant Id'), |
---|
212 | required = False, |
---|
213 | readonly = False, |
---|
214 | ) |
---|
215 | |
---|
216 | firstname = schema.TextLine( |
---|
217 | title = _(u'First Name'), |
---|
218 | required = True, |
---|
219 | ) |
---|
220 | |
---|
221 | middlename = schema.TextLine( |
---|
222 | title = _(u'Middle Name'), |
---|
223 | required = False, |
---|
224 | ) |
---|
225 | |
---|
226 | lastname = schema.TextLine( |
---|
227 | title = _(u'Last Name (Surname)'), |
---|
228 | required = True, |
---|
229 | ) |
---|
230 | |
---|
231 | sex = schema.Choice( |
---|
232 | title = _(u'Sex'), |
---|
233 | source = GenderSource(), |
---|
234 | required = True, |
---|
235 | ) |
---|
236 | |
---|
237 | nationality = schema.Choice( |
---|
238 | vocabulary = nats_vocab, |
---|
239 | title = _(u'Nationality'), |
---|
240 | required = False, |
---|
241 | ) |
---|
242 | |
---|
243 | email = schema.ASCIILine( |
---|
244 | title = _(u'Email Address'), |
---|
245 | required = True, |
---|
246 | constraint=validate_email, |
---|
247 | ) |
---|
248 | |
---|
249 | phone = PhoneNumber( |
---|
250 | title = _(u'Phone'), |
---|
251 | description = u'', |
---|
252 | required = False, |
---|
253 | ) |
---|
254 | |
---|
255 | #perm_address = schema.Text( |
---|
256 | # title = _(u'Current Local Address'), |
---|
257 | # required = False, |
---|
258 | # readonly = False, |
---|
259 | # ) |
---|
260 | |
---|
261 | institution = schema.TextLine( |
---|
262 | title = _(u'Institution/Organisation'), |
---|
263 | required = False, |
---|
264 | readonly = False, |
---|
265 | ) |
---|
266 | |
---|
267 | city = schema.TextLine( |
---|
268 | title = _(u'City'), |
---|
269 | required = False, |
---|
270 | readonly = False, |
---|
271 | ) |
---|
272 | |
---|
273 | lga = schema.Choice( |
---|
274 | source = LGASource(), |
---|
275 | title = _(u'State/LGA'), |
---|
276 | required = False, |
---|
277 | ) |
---|
278 | |
---|
279 | matric_number = schema.TextLine( |
---|
280 | title = _(u'Uniben Matriculation Number'), |
---|
281 | required = False, |
---|
282 | readonly = False, |
---|
283 | ) |
---|
284 | |
---|
285 | registration_cats = schema.List( |
---|
286 | title = _(u'Registration Categories'), |
---|
287 | value_type = schema.Choice(source=RegTypesSource()), |
---|
288 | required = True, |
---|
289 | defaultFactory=list, |
---|
290 | ) |
---|
291 | |
---|
292 | # @invariant |
---|
293 | # def matric_number_exists(applicant): |
---|
294 | # if applicant.matric_number: |
---|
295 | # catalog = getUtility(ICatalog, name='students_catalog') |
---|
296 | # accommodation_session = getSite()['hostels'].accommodation_session |
---|
297 | # student = catalog.searchResults(matric_number=( |
---|
298 | # applicant.matric_number, applicant.matric_number)) |
---|
299 | # if len(student) != 1: |
---|
300 | # raise Invalid(_("Matriculation number not found.")) |
---|
301 | |
---|
302 | class ITranscriptApplicant(IKofaObject): |
---|
303 | """A transcript applicant. |
---|
304 | """ |
---|
305 | |
---|
306 | suspended = schema.Bool( |
---|
307 | title = _(u'Account suspended'), |
---|
308 | default = False, |
---|
309 | required = False, |
---|
310 | ) |
---|
311 | |
---|
312 | locked = schema.Bool( |
---|
313 | title = _(u'Form locked'), |
---|
314 | default = False, |
---|
315 | required = False, |
---|
316 | ) |
---|
317 | |
---|
318 | applicant_id = schema.TextLine( |
---|
319 | title = _(u'Transcript Application Id'), |
---|
320 | required = False, |
---|
321 | readonly = False, |
---|
322 | ) |
---|
323 | |
---|
324 | student_id = schema.TextLine( |
---|
325 | title = _(u'Kofa Student Id'), |
---|
326 | required = False, |
---|
327 | readonly = False, |
---|
328 | ) |
---|
329 | |
---|
330 | matric_number = schema.TextLine( |
---|
331 | title = _(u'Matriculation Number'), |
---|
332 | readonly = False, |
---|
333 | required = True, |
---|
334 | constraint = validate_matric_number, |
---|
335 | ) |
---|
336 | |
---|
337 | firstname = schema.TextLine( |
---|
338 | title = _(u'First Name in School'), |
---|
339 | required = True, |
---|
340 | ) |
---|
341 | |
---|
342 | middlename = schema.TextLine( |
---|
343 | title = _(u'Middle Name in School'), |
---|
344 | required = False, |
---|
345 | ) |
---|
346 | |
---|
347 | lastname = schema.TextLine( |
---|
348 | title = _(u'Surname in School'), |
---|
349 | required = True, |
---|
350 | ) |
---|
351 | |
---|
352 | date_of_birth = FormattedDate( |
---|
353 | title = _(u'Date of Birth'), |
---|
354 | required = False, |
---|
355 | #date_format = u'%d/%m/%Y', # Use grok-instance-wide default |
---|
356 | show_year = True, |
---|
357 | ) |
---|
358 | |
---|
359 | sex = schema.Choice( |
---|
360 | title = _(u'Gender'), |
---|
361 | source = GenderSource(), |
---|
362 | required = True, |
---|
363 | ) |
---|
364 | |
---|
365 | #nationality = schema.Choice( |
---|
366 | # vocabulary = nats_vocab, |
---|
367 | # title = _(u'Nationality'), |
---|
368 | # required = False, |
---|
369 | # ) |
---|
370 | |
---|
371 | email = schema.ASCIILine( |
---|
372 | title = _(u'Email Address'), |
---|
373 | required = True, |
---|
374 | constraint=validate_email, |
---|
375 | ) |
---|
376 | |
---|
377 | phone = PhoneNumber( |
---|
378 | title = _(u'Phone'), |
---|
379 | description = u'', |
---|
380 | required = False, |
---|
381 | ) |
---|
382 | |
---|
383 | #perm_address = schema.Text( |
---|
384 | # title = _(u'Current Local Address'), |
---|
385 | # required = False, |
---|
386 | # readonly = False, |
---|
387 | # ) |
---|
388 | |
---|
389 | collected = schema.Bool( |
---|
390 | title = _(u'Have you collected transcript before?'), |
---|
391 | default = False, |
---|
392 | required = False, |
---|
393 | ) |
---|
394 | |
---|
395 | entry_session = schema.Choice( |
---|
396 | title = _(u'Academic Session of Entry'), |
---|
397 | source = academic_sessions_vocab, |
---|
398 | required = False, |
---|
399 | readonly = False, |
---|
400 | ) |
---|
401 | |
---|
402 | end_session = schema.Choice( |
---|
403 | title = _(u'Academic Session of Graduation'), |
---|
404 | source = academic_sessions_vocab, |
---|
405 | required = False, |
---|
406 | readonly = False, |
---|
407 | ) |
---|
408 | |
---|
409 | entry_mode = schema.Choice( |
---|
410 | title = _(u'Mode of Entry'), |
---|
411 | source = StudyModeSource(), |
---|
412 | required = False, |
---|
413 | readonly = False, |
---|
414 | ) |
---|
415 | |
---|
416 | course_studied = schema.Choice( |
---|
417 | title = _(u'Course of Study'), |
---|
418 | source = TranscriptCertificateSource(), |
---|
419 | description = u'Faculty / Department / Course', |
---|
420 | required = True, |
---|
421 | readonly = False, |
---|
422 | ) |
---|
423 | |
---|
424 | course_changed = schema.Choice( |
---|
425 | title = _(u'Change of Study Course / Transfer'), |
---|
426 | description = u'If yes, select previous course of study.', |
---|
427 | source = TranscriptCertificateSource(), |
---|
428 | readonly = False, |
---|
429 | required = False, |
---|
430 | ) |
---|
431 | |
---|
432 | spillover_level = schema.Choice( |
---|
433 | title = _(u'Spill-over'), |
---|
434 | description = u'Any spill-over? If yes, select session of spill-over.', |
---|
435 | source = academic_sessions_vocab, |
---|
436 | required = False, |
---|
437 | readonly = False, |
---|
438 | ) |
---|
439 | |
---|
440 | purpose = schema.TextLine( |
---|
441 | title = _(u'Transcript Purpose'), |
---|
442 | required = False, |
---|
443 | ) |
---|
444 | |
---|
445 | order = schema.Choice( |
---|
446 | source = OrderSource(), |
---|
447 | title = _(u'Type of Order'), |
---|
448 | required = False, |
---|
449 | ) |
---|
450 | |
---|
451 | dispatch_address = schema.Text( |
---|
452 | title = _(u'Recipient Body'), |
---|
453 | description = u'Addresses to which transcripts should be posted. ' |
---|
454 | 'All addresses must involve same courier charges.', |
---|
455 | required = True, |
---|
456 | readonly = False, |
---|
457 | ) |
---|
458 | |
---|
459 | dispatch_email = schema.ASCIILine( |
---|
460 | title = _(u'Recipient Email Address'), |
---|
461 | required = False, |
---|
462 | constraint=validate_email, |
---|
463 | ) |
---|
464 | |
---|
465 | dispatch_phone = PhoneNumber( |
---|
466 | title = _(u'Recipient Phone'), |
---|
467 | description = u'', |
---|
468 | required = False, |
---|
469 | ) |
---|
470 | |
---|
471 | charge = schema.Choice( |
---|
472 | title = _(u'Transcript Charge'), |
---|
473 | source = DestinationCostSource(), |
---|
474 | required = False, |
---|
475 | readonly = False, |
---|
476 | ) |
---|
477 | |
---|
478 | no_copies = schema.Choice( |
---|
479 | title = _(u'Number of Copies'), |
---|
480 | description = u'Must correspond with the number of dispatch addresses above.', |
---|
481 | values=[1, 2, 3, 4], |
---|
482 | required = False, |
---|
483 | readonly = False, |
---|
484 | default = 1, |
---|
485 | ) |
---|
486 | |
---|
487 | courier_tno = schema.TextLine( |
---|
488 | title = _(u'Courier Tracking Number'), |
---|
489 | required = False, |
---|
490 | ) |
---|
491 | |
---|
492 | proc_date = FormattedDate( |
---|
493 | title = _(u'Processing Date'), |
---|
494 | required = False, |
---|
495 | #date_format = u'%d/%m/%Y', # Use grok-instance-wide default |
---|
496 | show_year = True, |
---|
497 | ) |
---|
498 | |
---|
499 | @invariant |
---|
500 | def type_of_order(applicant): |
---|
501 | if not applicant.collected and applicant.order != 'o': |
---|
502 | raise Invalid(_("If you haven't collected transcript before, type of order must be 'original'.")) |
---|
503 | if applicant.order == 'o' and applicant.charge.startswith('cert_'): |
---|
504 | raise Invalid(_("You've selected the wrong transcript charge.")) |
---|
505 | if applicant.order == 'c' and not applicant.charge.startswith('cert_'): |
---|
506 | raise Invalid(_("You've selected the wrong transcript charge.")) |
---|
507 | |
---|
508 | class IFrenchApplicant(IKofaObject): |
---|
509 | """A transcript applicant. |
---|
510 | """ |
---|
511 | |
---|
512 | suspended = schema.Bool( |
---|
513 | title = _(u'Account suspended'), |
---|
514 | default = False, |
---|
515 | required = False, |
---|
516 | ) |
---|
517 | |
---|
518 | locked = schema.Bool( |
---|
519 | title = _(u'Form locked'), |
---|
520 | default = False, |
---|
521 | required = False, |
---|
522 | ) |
---|
523 | |
---|
524 | applicant_id = schema.TextLine( |
---|
525 | title = _(u'Applicant Id'), |
---|
526 | required = False, |
---|
527 | readonly = False, |
---|
528 | ) |
---|
529 | |
---|
530 | firstname = schema.TextLine( |
---|
531 | title = _(u'First Name'), |
---|
532 | required = True, |
---|
533 | ) |
---|
534 | |
---|
535 | middlename = schema.TextLine( |
---|
536 | title = _(u'Middle Name'), |
---|
537 | required = False, |
---|
538 | ) |
---|
539 | |
---|
540 | lastname = schema.TextLine( |
---|
541 | title = _(u'Surname'), |
---|
542 | required = True, |
---|
543 | ) |
---|
544 | |
---|
545 | date_of_birth = FormattedDate( |
---|
546 | title = _(u'Date of Birth'), |
---|
547 | required = False, |
---|
548 | #date_format = u'%d/%m/%Y', # Use grok-instance-wide default |
---|
549 | show_year = True, |
---|
550 | ) |
---|
551 | |
---|
552 | sex = schema.Choice( |
---|
553 | title = _(u'Gender'), |
---|
554 | source = GenderSource(), |
---|
555 | required = True, |
---|
556 | ) |
---|
557 | |
---|
558 | nationality = schema.Choice( |
---|
559 | vocabulary = nats_vocab, |
---|
560 | title = _(u'Nationality'), |
---|
561 | required = False, |
---|
562 | ) |
---|
563 | |
---|
564 | email = schema.ASCIILine( |
---|
565 | title = _(u'Email Address'), |
---|
566 | required = True, |
---|
567 | constraint=validate_email, |
---|
568 | ) |
---|
569 | |
---|
570 | phone = PhoneNumber( |
---|
571 | title = _(u'Phone'), |
---|
572 | description = u'', |
---|
573 | required = False, |
---|
574 | ) |
---|
575 | |
---|
576 | work = schema.TextLine( |
---|
577 | title = _(u'Place of Work'), |
---|
578 | required = False, |
---|
579 | ) |
---|
580 | |
---|
581 | hq_obtained = schema.Choice( |
---|
582 | title = _(u'Highest Qualification Obtained'), |
---|
583 | required = False, |
---|
584 | readonly = False, |
---|
585 | vocabulary = high_qual, |
---|
586 | ) |
---|
587 | |
---|
588 | hq_date = FormattedDate( |
---|
589 | title = _(u'Highest Qualification Date'), |
---|
590 | required = False, |
---|
591 | readonly = False, |
---|
592 | show_year = True, |
---|
593 | ) |
---|
594 | |
---|
595 | pref_session = schema.Choice( |
---|
596 | source = PreferredSessionSource(), |
---|
597 | title = _(u'Preferred Session'), |
---|
598 | required = False, |
---|
599 | ) |
---|
600 | |
---|
601 | proficiency = schema.Choice( |
---|
602 | source = ProficiencySource(), |
---|
603 | title = _(u'Level of Proficiency'), |
---|
604 | required = False, |
---|
605 | ) |
---|
606 | |
---|
607 | guarantor = schema.TextLine( |
---|
608 | title = _(u'Name of Guarantor'), |
---|
609 | required = False, |
---|
610 | ) |
---|
611 | |
---|
612 | course_admitted = schema.Choice( |
---|
613 | title = _(u'Admitted Course of Study'), |
---|
614 | source = CertificateSource(), |
---|
615 | required = False, |
---|
616 | ) |
---|
617 | |
---|
618 | class IAfrimalApplicant(IKofaObject): |
---|
619 | """An AFRIMAL applicant. |
---|
620 | """ |
---|
621 | |
---|
622 | suspended = schema.Bool( |
---|
623 | title = _(u'Account suspended'), |
---|
624 | default = False, |
---|
625 | required = False, |
---|
626 | ) |
---|
627 | |
---|
628 | locked = schema.Bool( |
---|
629 | title = _(u'Form locked'), |
---|
630 | default = False, |
---|
631 | required = False, |
---|
632 | ) |
---|
633 | |
---|
634 | applicant_id = schema.TextLine( |
---|
635 | title = _(u'Applicant Id'), |
---|
636 | required = False, |
---|
637 | readonly = False, |
---|
638 | ) |
---|
639 | |
---|
640 | firstname = schema.TextLine( |
---|
641 | title = _(u'First Name'), |
---|
642 | required = True, |
---|
643 | ) |
---|
644 | |
---|
645 | middlename = schema.TextLine( |
---|
646 | title = _(u'Middle Name'), |
---|
647 | required = False, |
---|
648 | ) |
---|
649 | |
---|
650 | lastname = schema.TextLine( |
---|
651 | title = _(u'Surname'), |
---|
652 | required = True, |
---|
653 | ) |
---|
654 | |
---|
655 | date_of_birth = FormattedDate( |
---|
656 | title = _(u'Date of Birth'), |
---|
657 | required = False, |
---|
658 | #date_format = u'%d/%m/%Y', # Use grok-instance-wide default |
---|
659 | show_year = True, |
---|
660 | ) |
---|
661 | |
---|
662 | sex = schema.Choice( |
---|
663 | title = _(u'Gender'), |
---|
664 | source = GenderSource(), |
---|
665 | required = True, |
---|
666 | ) |
---|
667 | |
---|
668 | nationality = schema.Choice( |
---|
669 | vocabulary = nats_vocab, |
---|
670 | title = _(u'Nationality'), |
---|
671 | required = False, |
---|
672 | ) |
---|
673 | |
---|
674 | email = schema.ASCIILine( |
---|
675 | title = _(u'Email Address'), |
---|
676 | required = True, |
---|
677 | constraint=validate_email, |
---|
678 | ) |
---|
679 | |
---|
680 | phone = PhoneNumber( |
---|
681 | title = _(u'Phone'), |
---|
682 | description = u'', |
---|
683 | required = False, |
---|
684 | ) |
---|
685 | |
---|
686 | hq_obtained = schema.Choice( |
---|
687 | title = _(u'Highest Qualification Obtained'), |
---|
688 | required = False, |
---|
689 | readonly = False, |
---|
690 | vocabulary = high_qual, |
---|
691 | ) |
---|
692 | |
---|
693 | current_employer = schema.TextLine( |
---|
694 | title = _(u'Current Employer'), |
---|
695 | required = False, |
---|
696 | ) |
---|
697 | |
---|
698 | course1 = schema.Choice( |
---|
699 | title = _(u'Course of Study'), |
---|
700 | source = AppCatCertificateSource(), |
---|
701 | required = True, |
---|
702 | ) |
---|
703 | |
---|
704 | course_admitted = schema.Choice( |
---|
705 | title = _(u'Admitted Course of Study'), |
---|
706 | source = CertificateSource(), |
---|
707 | required = False, |
---|
708 | ) |
---|
709 | |
---|
710 | class ICustomUGApplicant(IApplicantBaseData, IBankAccount): |
---|
711 | """An undergraduate applicant. |
---|
712 | |
---|
713 | This interface defines the least common multiple of all fields |
---|
714 | in ug application forms. In customized forms, fields can be excluded by |
---|
715 | adding them to the UG_OMIT* tuples. |
---|
716 | """ |
---|
717 | |
---|
718 | disabilities = schema.Choice( |
---|
719 | title = _(u'Disabilities'), |
---|
720 | source = DisabilitiesSource(), |
---|
721 | required = False, |
---|
722 | ) |
---|
723 | nationality = schema.Choice( |
---|
724 | source = nats_vocab, |
---|
725 | title = _(u'Nationality'), |
---|
726 | required = False, |
---|
727 | ) |
---|
728 | lga = schema.Choice( |
---|
729 | source = LGASource(), |
---|
730 | title = _(u'State/LGA (Nigerians only)'), |
---|
731 | required = False, |
---|
732 | ) |
---|
733 | #perm_address = schema.Text( |
---|
734 | # title = _(u'Permanent Address'), |
---|
735 | # required = False, |
---|
736 | # ) |
---|
737 | course1 = schema.Choice( |
---|
738 | title = _(u'1st Choice Course of Study'), |
---|
739 | source = AppCatCertificateSource(), |
---|
740 | required = True, |
---|
741 | ) |
---|
742 | course2 = schema.Choice( |
---|
743 | title = _(u'2nd Choice Course of Study'), |
---|
744 | source = AppCatCertificateSource(), |
---|
745 | required = False, |
---|
746 | ) |
---|
747 | |
---|
748 | programme_type = schema.Choice( |
---|
749 | title = _(u'Programme Type'), |
---|
750 | vocabulary = programme_types_vocab, |
---|
751 | required = False, |
---|
752 | ) |
---|
753 | |
---|
754 | hq_type = schema.Choice( |
---|
755 | title = _(u'Qualification Obtained'), |
---|
756 | required = False, |
---|
757 | readonly = False, |
---|
758 | vocabulary = high_qual, |
---|
759 | ) |
---|
760 | hq_matric_no = schema.TextLine( |
---|
761 | title = _(u'Former Matric Number'), |
---|
762 | required = False, |
---|
763 | readonly = False, |
---|
764 | ) |
---|
765 | hq_degree = schema.Choice( |
---|
766 | title = _(u'Class of Degree'), |
---|
767 | required = False, |
---|
768 | readonly = False, |
---|
769 | vocabulary = high_grade, |
---|
770 | ) |
---|
771 | hq_school = schema.TextLine( |
---|
772 | title = _(u'Institution Attended'), |
---|
773 | required = False, |
---|
774 | readonly = False, |
---|
775 | ) |
---|
776 | hq_session = schema.TextLine( |
---|
777 | title = _(u'Years Attended'), |
---|
778 | required = False, |
---|
779 | readonly = False, |
---|
780 | ) |
---|
781 | hq_disc = schema.TextLine( |
---|
782 | title = _(u'Discipline'), |
---|
783 | required = False, |
---|
784 | readonly = False, |
---|
785 | ) |
---|
786 | fst_sit_fname = schema.TextLine( |
---|
787 | title = _(u'Full Name'), |
---|
788 | required = False, |
---|
789 | readonly = False, |
---|
790 | ) |
---|
791 | fst_sit_no = schema.TextLine( |
---|
792 | title = _(u'Exam Number'), |
---|
793 | required = False, |
---|
794 | readonly = False, |
---|
795 | ) |
---|
796 | fst_sit_date = FormattedDate( |
---|
797 | title = _(u'Exam Date'), |
---|
798 | required = False, |
---|
799 | readonly = False, |
---|
800 | show_year = True, |
---|
801 | ) |
---|
802 | fst_sit_type = schema.Choice( |
---|
803 | title = _(u'Exam Type'), |
---|
804 | required = False, |
---|
805 | readonly = False, |
---|
806 | vocabulary = exam_types, |
---|
807 | ) |
---|
808 | fst_sit_results = schema.List( |
---|
809 | title = _(u'Exam Results'), |
---|
810 | value_type = ResultEntryField(), |
---|
811 | required = False, |
---|
812 | readonly = False, |
---|
813 | defaultFactory=list, |
---|
814 | ) |
---|
815 | scd_sit_fname = schema.TextLine( |
---|
816 | title = _(u'Full Name'), |
---|
817 | required = False, |
---|
818 | readonly = False, |
---|
819 | ) |
---|
820 | scd_sit_no = schema.TextLine( |
---|
821 | title = _(u'Exam Number'), |
---|
822 | required = False, |
---|
823 | readonly = False, |
---|
824 | ) |
---|
825 | scd_sit_date = FormattedDate( |
---|
826 | title = _(u'Exam Date'), |
---|
827 | required = False, |
---|
828 | readonly = False, |
---|
829 | show_year = True, |
---|
830 | ) |
---|
831 | scd_sit_type = schema.Choice( |
---|
832 | title = _(u'Exam Type'), |
---|
833 | required = False, |
---|
834 | readonly = False, |
---|
835 | vocabulary = exam_types, |
---|
836 | ) |
---|
837 | scd_sit_results = schema.List( |
---|
838 | title = _(u'Exam Results'), |
---|
839 | value_type = ResultEntryField(), |
---|
840 | required = False, |
---|
841 | readonly = False, |
---|
842 | defaultFactory=list, |
---|
843 | ) |
---|
844 | jamb_reg_number = schema.TextLine( |
---|
845 | title = _(u'JAMB Registration Number'), |
---|
846 | required = False, |
---|
847 | ) |
---|
848 | jamb_subjects = schema.Text( |
---|
849 | title = _(u'Subjects and Scores'), |
---|
850 | required = False, |
---|
851 | ) |
---|
852 | jamb_subjects_list = schema.List( |
---|
853 | title = _(u'JAMB Subjects'), |
---|
854 | required = False, |
---|
855 | defaultFactory=list, |
---|
856 | value_type = schema.Choice( |
---|
857 | vocabulary = jambsubjects |
---|
858 | #source = JAMBSubjectSource(), |
---|
859 | ), |
---|
860 | ) |
---|
861 | jamb_score = schema.Float( |
---|
862 | title = _(u'Total JAMB Score'), |
---|
863 | required = False, |
---|
864 | ) |
---|
865 | #jamb_age = schema.Int( |
---|
866 | # title = _(u'Age (provided by JAMB)'), |
---|
867 | # required = False, |
---|
868 | # ) |
---|
869 | course_admitted = schema.Choice( |
---|
870 | title = _(u'Admitted Course of Study'), |
---|
871 | source = CertificateSource(), |
---|
872 | required = False, |
---|
873 | ) |
---|
874 | notice = schema.Text( |
---|
875 | title = _(u'Notice'), |
---|
876 | required = False, |
---|
877 | ) |
---|
878 | screening_venue = schema.TextLine( |
---|
879 | title = _(u'Screening Venue'), |
---|
880 | required = False, |
---|
881 | ) |
---|
882 | screening_date = schema.TextLine( |
---|
883 | title = _(u'Screening Date'), |
---|
884 | required = False, |
---|
885 | ) |
---|
886 | screening_score = schema.Float( |
---|
887 | title = _(u'Screening Score (%)'), |
---|
888 | required = False, |
---|
889 | ) |
---|
890 | aggregate = schema.Float( |
---|
891 | title = _(u'Aggregate Score (%)'), |
---|
892 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
893 | required = False, |
---|
894 | ) |
---|
895 | result_uploaded = schema.Bool( |
---|
896 | title = _(u'Result uploaded'), |
---|
897 | default = False, |
---|
898 | required = False, |
---|
899 | ) |
---|
900 | student_id = schema.TextLine( |
---|
901 | title = _(u'Student Id'), |
---|
902 | required = False, |
---|
903 | readonly = False, |
---|
904 | ) |
---|
905 | locked = schema.Bool( |
---|
906 | title = _(u'Form locked'), |
---|
907 | default = False, |
---|
908 | required = False, |
---|
909 | ) |
---|
910 | |
---|
911 | ICustomUGApplicant[ |
---|
912 | 'locked'].order = IApplicantBaseData['suspended'].order |
---|
913 | ICustomUGApplicant[ |
---|
914 | 'result_uploaded'].order = ICustomUGApplicant['suspended'].order |
---|
915 | |
---|
916 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
917 | """A postgraduate applicant. |
---|
918 | |
---|
919 | This interface defines the least common multiple of all fields |
---|
920 | in pg application forms. In customized forms, fields can be excluded by |
---|
921 | adding them to the PG_OMIT* tuples. |
---|
922 | """ |
---|
923 | |
---|
924 | referees = schema.List( |
---|
925 | title = _(u'Referees'), |
---|
926 | value_type = RefereeEntryField(), |
---|
927 | required = False, |
---|
928 | defaultFactory=list, |
---|
929 | ) |
---|
930 | |
---|
931 | ICustomPGApplicant[ |
---|
932 | 'referees'].order = INigeriaPGApplicant['emp2_reason'].order |
---|
933 | |
---|
934 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant, |
---|
935 | IUnibenRegistration, ITranscriptApplicant, IFrenchApplicant, |
---|
936 | IAfrimalApplicant): |
---|
937 | """An interface for both types of applicants. |
---|
938 | |
---|
939 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
940 | by ICustomPGApplicant field settings. If a field is defined |
---|
941 | in both interfaces zope.schema validates only against the |
---|
942 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
943 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
944 | """ |
---|
945 | |
---|
946 | def writeLogMessage(view, comment): |
---|
947 | """Adds an INFO message to the log file |
---|
948 | """ |
---|
949 | |
---|
950 | def createStudent(): |
---|
951 | """Create a student object from applicant data |
---|
952 | and copy applicant object. |
---|
953 | """ |
---|
954 | |
---|
955 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
956 | """An undergraduate applicant interface for edit forms. |
---|
957 | |
---|
958 | Here we can repeat the fields from base data and set the |
---|
959 | `required` and `readonly` attributes to True to further restrict |
---|
960 | the data access. Or we can allow only certain certificates to be |
---|
961 | selected by choosing the appropriate source. |
---|
962 | |
---|
963 | We cannot omit fields here. This has to be done in the |
---|
964 | respective form page. |
---|
965 | """ |
---|
966 | |
---|
967 | email = schema.ASCIILine( |
---|
968 | title = _(u'Email Address'), |
---|
969 | required = True, |
---|
970 | constraint=validate_email, |
---|
971 | ) |
---|
972 | date_of_birth = FormattedDate( |
---|
973 | title = _(u'Date of Birth'), |
---|
974 | required = True, |
---|
975 | show_year = True, |
---|
976 | ) |
---|
977 | |
---|
978 | ICustomUGApplicantEdit[ |
---|
979 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
980 | ICustomUGApplicantEdit[ |
---|
981 | 'email'].order = ICustomUGApplicant['email'].order |
---|
982 | |
---|
983 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
984 | """A postgraduate applicant interface for editing. |
---|
985 | |
---|
986 | Here we can repeat the fields from base data and set the |
---|
987 | `required` and `readonly` attributes to True to further restrict |
---|
988 | the data access. Or we can allow only certain certificates to be |
---|
989 | selected by choosing the appropriate source. |
---|
990 | |
---|
991 | We cannot omit fields here. This has to be done in the |
---|
992 | respective form page. |
---|
993 | """ |
---|
994 | |
---|
995 | referees = schema.List( |
---|
996 | title = _(u'Referees'), |
---|
997 | value_type = RefereeEntryField(), |
---|
998 | required = False, |
---|
999 | defaultFactory=list, |
---|
1000 | ) |
---|
1001 | |
---|
1002 | ICustomPGApplicantEdit[ |
---|
1003 | 'referees'].order = INigeriaPGApplicantEdit['emp2_reason'].order |
---|
1004 | |
---|
1005 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
1006 | """An applicant payment via payment gateways. |
---|
1007 | |
---|
1008 | """ |
---|
1009 | |
---|
1010 | class IPUTMEApplicantEdit(ICustomUGApplicant): |
---|
1011 | """An undergraduate applicant interface for editing. |
---|
1012 | |
---|
1013 | Here we can repeat the fields from base data and set the |
---|
1014 | `required` and `readonly` attributes to True to further restrict |
---|
1015 | the data access. Or we can allow only certain certificates to be |
---|
1016 | selected by choosing the appropriate source. |
---|
1017 | |
---|
1018 | We cannot omit fields here. This has to be done in the |
---|
1019 | respective form page. |
---|
1020 | """ |
---|
1021 | |
---|
1022 | email = schema.ASCIILine( |
---|
1023 | title = _(u'Email Address'), |
---|
1024 | required = True, |
---|
1025 | constraint=validate_email, |
---|
1026 | ) |
---|
1027 | date_of_birth = FormattedDate( |
---|
1028 | title = _(u'Date of Birth'), |
---|
1029 | required = True, |
---|
1030 | show_year = True, |
---|
1031 | ) |
---|
1032 | nationality = schema.Choice( |
---|
1033 | source = nats_vocab, |
---|
1034 | title = _(u'Nationality'), |
---|
1035 | required = True, |
---|
1036 | ) |
---|
1037 | |
---|
1038 | IPUTMEApplicantEdit[ |
---|
1039 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
1040 | IPUTMEApplicantEdit[ |
---|
1041 | 'email'].order = ICustomUGApplicant['email'].order |
---|
1042 | IPUTMEApplicantEdit[ |
---|
1043 | 'nationality'].order = ICustomUGApplicant['nationality'].order |
---|
1044 | |
---|
1045 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
1046 | """Representation of an applicant. |
---|
1047 | |
---|
1048 | Skip regular reg_number validation if reg_number is used for finding |
---|
1049 | the applicant object. |
---|
1050 | """ |
---|