1 | ## $Id: interfaces.py 15469 2019-06-20 16:43:59Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2012 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 | from zope import schema |
---|
19 | from zope.interface import Attribute, invariant, Invalid |
---|
20 | from waeup.kofa.schema import TextLineChoice |
---|
21 | from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab |
---|
22 | from waeup.kofa.schema import FormattedDate, PhoneNumber |
---|
23 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
24 | from waeup.kofa.students.vocabularies import nats_vocab, StudyLevelSource |
---|
25 | from waeup.kofa.students.interfaces import ( |
---|
26 | IStudentBase, IUGStudentClearance, IPGStudentClearance, |
---|
27 | IStudentPersonal, IStudentNavigation, IStudentStudyLevel, |
---|
28 | IStudentStudyCourse, ICourseTicket |
---|
29 | ) |
---|
30 | from waeup.kofa.students.vocabularies import ( |
---|
31 | nats_vocab, contextual_reg_num_source) |
---|
32 | from kofacustom.nigeria.interfaces import ( |
---|
33 | high_qual, high_grade, exam_types, LGASource) |
---|
34 | from kofacustom.nigeria.interfaces import MessageFactory as _ |
---|
35 | from kofacustom.nigeria.payments.interfaces import INigeriaOnlinePayment |
---|
36 | |
---|
37 | |
---|
38 | class INigeriaStudentBase(IStudentBase): |
---|
39 | """Representation of student base data. |
---|
40 | |
---|
41 | """ |
---|
42 | |
---|
43 | reg_number = TextLineChoice( |
---|
44 | title = _(u'Registration Number'), |
---|
45 | required = False, |
---|
46 | readonly = False, |
---|
47 | source = contextual_reg_num_source, |
---|
48 | ) |
---|
49 | |
---|
50 | is_staff = schema.Bool( |
---|
51 | title = _(u'Staff Member'), |
---|
52 | required = False, |
---|
53 | readonly = False, |
---|
54 | default = False, |
---|
55 | ) |
---|
56 | |
---|
57 | financially_cleared_by = schema.TextLine( |
---|
58 | title = _(u'Financially Cleared by'), |
---|
59 | default = None, |
---|
60 | required = False, |
---|
61 | ) |
---|
62 | |
---|
63 | financial_clearance_date = schema.Datetime( |
---|
64 | title = _(u'Financial Clearance Date'), |
---|
65 | required = False, |
---|
66 | readonly = False, |
---|
67 | ) |
---|
68 | |
---|
69 | provisionally_cleared = schema.Bool( |
---|
70 | title = _(u'Provisionally Cleared'), |
---|
71 | default = False, |
---|
72 | required = False, |
---|
73 | description = u'Student will be able to edit clearance data if set.', |
---|
74 | ) |
---|
75 | |
---|
76 | INigeriaStudentBase['reg_number'].order = IStudentBase[ |
---|
77 | 'reg_number'].order |
---|
78 | |
---|
79 | |
---|
80 | class INigeriaUGStudentClearance(IUGStudentClearance): |
---|
81 | """Representation of ug student clearance data. |
---|
82 | |
---|
83 | """ |
---|
84 | officer_comment = schema.Text( |
---|
85 | title = _(u"Officer's Comment"), |
---|
86 | required = False, |
---|
87 | ) |
---|
88 | |
---|
89 | physical_clearance_date = schema.TextLine( |
---|
90 | title = _(u"Physical Clearance Date"), |
---|
91 | required = False, |
---|
92 | ) |
---|
93 | |
---|
94 | clr_code = schema.TextLine( |
---|
95 | title = _(u'CLR Activation Code'), |
---|
96 | required = False, |
---|
97 | readonly = False, |
---|
98 | ) |
---|
99 | |
---|
100 | date_of_birth = FormattedDate( |
---|
101 | title = _(u'Date of Birth'), |
---|
102 | required = False, |
---|
103 | show_year = True, |
---|
104 | ) |
---|
105 | |
---|
106 | nationality = schema.Choice( |
---|
107 | source = nats_vocab, |
---|
108 | title = _(u'Nationality'), |
---|
109 | required = True, |
---|
110 | ) |
---|
111 | |
---|
112 | lga = schema.Choice( |
---|
113 | source = LGASource(), |
---|
114 | title = _(u'State / LGA'), |
---|
115 | required = False, |
---|
116 | ) |
---|
117 | |
---|
118 | def_adm = schema.Bool( |
---|
119 | title = _(u'Deferment of Admission'), |
---|
120 | required = False, |
---|
121 | readonly = False, |
---|
122 | default = False, |
---|
123 | ) |
---|
124 | |
---|
125 | fst_sit_fname = schema.TextLine( |
---|
126 | title = _(u'Full Name'), |
---|
127 | required = False, |
---|
128 | readonly = False, |
---|
129 | ) |
---|
130 | fst_sit_no = schema.TextLine( |
---|
131 | title = _(u'Exam Number'), |
---|
132 | required = False, |
---|
133 | readonly = False, |
---|
134 | ) |
---|
135 | |
---|
136 | fst_sit_date = FormattedDate( |
---|
137 | title = _(u'Exam Date'), |
---|
138 | required = False, |
---|
139 | readonly = False, |
---|
140 | show_year = True, |
---|
141 | ) |
---|
142 | |
---|
143 | fst_sit_type = schema.Choice( |
---|
144 | title = _(u'Exam Type'), |
---|
145 | required = False, |
---|
146 | readonly = False, |
---|
147 | vocabulary = exam_types, |
---|
148 | ) |
---|
149 | |
---|
150 | fst_sit_results = schema.List( |
---|
151 | title = _(u'Exam Results'), |
---|
152 | value_type = ResultEntryField(), |
---|
153 | required = False, |
---|
154 | readonly = False, |
---|
155 | defaultFactory=list, |
---|
156 | ) |
---|
157 | |
---|
158 | scd_sit_fname = schema.TextLine( |
---|
159 | title = _(u'Full Name'), |
---|
160 | required = False, |
---|
161 | readonly = False, |
---|
162 | ) |
---|
163 | scd_sit_no = schema.TextLine( |
---|
164 | title = _(u'Exam Number'), |
---|
165 | required = False, |
---|
166 | readonly = False, |
---|
167 | ) |
---|
168 | |
---|
169 | scd_sit_date = FormattedDate( |
---|
170 | title = _(u'Exam Date'), |
---|
171 | required = False, |
---|
172 | readonly = False, |
---|
173 | show_year = True, |
---|
174 | ) |
---|
175 | |
---|
176 | scd_sit_type = schema.Choice( |
---|
177 | title = _(u'Exam Type'), |
---|
178 | required = False, |
---|
179 | readonly = False, |
---|
180 | vocabulary = exam_types, |
---|
181 | ) |
---|
182 | |
---|
183 | scd_sit_results = schema.List( |
---|
184 | title = _(u'Exam Results'), |
---|
185 | value_type = ResultEntryField(), |
---|
186 | required = False, |
---|
187 | readonly = False, |
---|
188 | defaultFactory=list, |
---|
189 | ) |
---|
190 | |
---|
191 | alr_fname = schema.TextLine( |
---|
192 | title = _(u'Full Name'), |
---|
193 | required = False, |
---|
194 | readonly = False, |
---|
195 | ) |
---|
196 | alr_no = schema.TextLine( |
---|
197 | title = _(u'Exam Number'), |
---|
198 | required = False, |
---|
199 | readonly = False, |
---|
200 | ) |
---|
201 | |
---|
202 | alr_date = FormattedDate( |
---|
203 | title = _(u'Exam Date'), |
---|
204 | required = False, |
---|
205 | readonly = False, |
---|
206 | show_year = True, |
---|
207 | ) |
---|
208 | |
---|
209 | alr_results = schema.List( |
---|
210 | title = _(u'Exam Results'), |
---|
211 | value_type = ResultEntryField(), |
---|
212 | required = False, |
---|
213 | readonly = False, |
---|
214 | defaultFactory=list, |
---|
215 | ) |
---|
216 | |
---|
217 | hq_type = schema.Choice( |
---|
218 | title = _(u'Qualification Obtained'), |
---|
219 | required = False, |
---|
220 | readonly = False, |
---|
221 | vocabulary = high_qual, |
---|
222 | ) |
---|
223 | |
---|
224 | hq_fname = schema.TextLine( |
---|
225 | title = _(u'Full Name'), |
---|
226 | required = False, |
---|
227 | readonly = False, |
---|
228 | ) |
---|
229 | |
---|
230 | hq_matric_no = schema.TextLine( |
---|
231 | title = _(u'Former Matric Number'), |
---|
232 | required = False, |
---|
233 | readonly = False, |
---|
234 | ) |
---|
235 | |
---|
236 | hq_degree = schema.Choice( |
---|
237 | title = _(u'Class of Degree'), |
---|
238 | required = False, |
---|
239 | readonly = False, |
---|
240 | vocabulary = high_grade, |
---|
241 | ) |
---|
242 | |
---|
243 | hq_school = schema.TextLine( |
---|
244 | title = _(u'Institution Attended'), |
---|
245 | required = False, |
---|
246 | readonly = False, |
---|
247 | ) |
---|
248 | |
---|
249 | hq_session = schema.TextLine( |
---|
250 | title = _(u'Years Attended'), |
---|
251 | required = False, |
---|
252 | readonly = False, |
---|
253 | ) |
---|
254 | |
---|
255 | hq_disc = schema.TextLine( |
---|
256 | title = _(u'Discipline'), |
---|
257 | required = False, |
---|
258 | readonly = False, |
---|
259 | ) |
---|
260 | |
---|
261 | @invariant |
---|
262 | def check_lga_nationality(student): |
---|
263 | if student.nationality != 'NG' and student.lga not in ('foreigner', None): |
---|
264 | raise Invalid(_('Nationalty and LGA are contradictory.')) |
---|
265 | if student.nationality == 'NG' and student.lga == 'foreigner': |
---|
266 | raise Invalid(_('Nationalty and LGA are contradictory.')) |
---|
267 | |
---|
268 | |
---|
269 | class INigeriaPGStudentClearance(INigeriaUGStudentClearance): |
---|
270 | """Representation of pg student clearance data. |
---|
271 | |
---|
272 | """ |
---|
273 | |
---|
274 | hq2_type = schema.Choice( |
---|
275 | title = _(u'Qualification Obtained'), |
---|
276 | required = False, |
---|
277 | readonly = False, |
---|
278 | vocabulary = high_qual, |
---|
279 | ) |
---|
280 | |
---|
281 | hq2_matric_no = schema.TextLine( |
---|
282 | title = _(u'Former Matric Number'), |
---|
283 | required = False, |
---|
284 | readonly = False, |
---|
285 | ) |
---|
286 | |
---|
287 | hq2_degree = schema.Choice( |
---|
288 | title = _(u'Class of Degree'), |
---|
289 | required = False, |
---|
290 | readonly = False, |
---|
291 | vocabulary = high_grade, |
---|
292 | ) |
---|
293 | |
---|
294 | hq2_school = schema.TextLine( |
---|
295 | title = _(u'Institution Attended'), |
---|
296 | required = False, |
---|
297 | readonly = False, |
---|
298 | ) |
---|
299 | |
---|
300 | hq2_session = schema.TextLine( |
---|
301 | title = _(u'Years Attended'), |
---|
302 | required = False, |
---|
303 | readonly = False, |
---|
304 | ) |
---|
305 | |
---|
306 | hq2_disc = schema.TextLine( |
---|
307 | title = _(u'Discipline'), |
---|
308 | required = False, |
---|
309 | readonly = False, |
---|
310 | ) |
---|
311 | |
---|
312 | nysc_year = schema.Int( |
---|
313 | title = _(u'Nysc Year'), |
---|
314 | required = False, |
---|
315 | readonly = False, |
---|
316 | ) |
---|
317 | |
---|
318 | nysc_location = schema.TextLine( |
---|
319 | title = _(u'Nysc Location'), |
---|
320 | required = False, |
---|
321 | ) |
---|
322 | |
---|
323 | nysc_lga = schema.Choice( |
---|
324 | source = LGASource(), |
---|
325 | title = _(u'Nysc LGA'), |
---|
326 | required = False, |
---|
327 | ) |
---|
328 | |
---|
329 | employer = schema.TextLine( |
---|
330 | title = _(u'Employer'), |
---|
331 | required = False, |
---|
332 | readonly = False, |
---|
333 | ) |
---|
334 | |
---|
335 | emp_position = schema.TextLine( |
---|
336 | title = _(u'Employer Position'), |
---|
337 | required = False, |
---|
338 | readonly = False, |
---|
339 | ) |
---|
340 | |
---|
341 | emp_start = FormattedDate( |
---|
342 | title = _(u'Start Date'), |
---|
343 | required = False, |
---|
344 | readonly = False, |
---|
345 | show_year = True, |
---|
346 | ) |
---|
347 | |
---|
348 | emp_end = FormattedDate( |
---|
349 | title = _(u'End Date'), |
---|
350 | required = False, |
---|
351 | readonly = False, |
---|
352 | show_year = True, |
---|
353 | ) |
---|
354 | |
---|
355 | emp_reason = schema.TextLine( |
---|
356 | title = _(u'Reason for Leaving'), |
---|
357 | required = False, |
---|
358 | readonly = False, |
---|
359 | ) |
---|
360 | |
---|
361 | employer2 = schema.TextLine( |
---|
362 | title = _(u'2nd Employer'), |
---|
363 | required = False, |
---|
364 | readonly = False, |
---|
365 | ) |
---|
366 | |
---|
367 | emp2_position = schema.TextLine( |
---|
368 | title = _(u'2nd Employer Position'), |
---|
369 | required = False, |
---|
370 | readonly = False, |
---|
371 | ) |
---|
372 | |
---|
373 | emp2_start = FormattedDate( |
---|
374 | title = _(u'Start Date'), |
---|
375 | required = False, |
---|
376 | readonly = False, |
---|
377 | show_year = True, |
---|
378 | ) |
---|
379 | emp2_end = FormattedDate( |
---|
380 | title = _(u'End Date'), |
---|
381 | required = False, |
---|
382 | readonly = False, |
---|
383 | show_year = True, |
---|
384 | ) |
---|
385 | |
---|
386 | emp2_reason = schema.TextLine( |
---|
387 | title = _(u'Reason for Leaving'), |
---|
388 | required = False, |
---|
389 | readonly = False, |
---|
390 | ) |
---|
391 | |
---|
392 | former_matric = schema.TextLine( |
---|
393 | title = _(u'If yes, matric number'), |
---|
394 | required = False, |
---|
395 | readonly = False, |
---|
396 | ) |
---|
397 | |
---|
398 | class INigeriaStudentPersonal(IStudentPersonal): |
---|
399 | """Student personal data. |
---|
400 | |
---|
401 | """ |
---|
402 | |
---|
403 | is_foreigner = Attribute('True if student is non-Nigerian') |
---|
404 | |
---|
405 | next_kin_name = schema.TextLine( |
---|
406 | title = _(u'Next of Kin Name'), |
---|
407 | required = False, |
---|
408 | readonly = False, |
---|
409 | ) |
---|
410 | |
---|
411 | next_kin_relation = schema.TextLine( |
---|
412 | title = _(u'Next of Kin Relationship'), |
---|
413 | required = False, |
---|
414 | readonly = False, |
---|
415 | ) |
---|
416 | |
---|
417 | next_kin_address = schema.Text( |
---|
418 | title = _(u'Next of Kin Address'), |
---|
419 | required = False, |
---|
420 | readonly = False, |
---|
421 | ) |
---|
422 | |
---|
423 | next_kin_phone = PhoneNumber( |
---|
424 | title = _(u'Next of Kin Phone'), |
---|
425 | description = u'', |
---|
426 | required = False, |
---|
427 | readonly = False, |
---|
428 | ) |
---|
429 | |
---|
430 | marit_stat = schema.Choice( |
---|
431 | title = u'Marital Status', |
---|
432 | default = 'unmarried', |
---|
433 | required = False, |
---|
434 | vocabulary = SimpleKofaVocabulary( |
---|
435 | (_('Unmarried'), 'unmarried'), |
---|
436 | (_('Married'), 'married'),) |
---|
437 | ) |
---|
438 | |
---|
439 | religion = schema.Choice( |
---|
440 | title = u'Religion', |
---|
441 | default = 'no_say', |
---|
442 | required = False, |
---|
443 | vocabulary = SimpleKofaVocabulary( |
---|
444 | (_('Muslim'), 'muslim'), |
---|
445 | (_('Christian'), 'christian'), |
---|
446 | (_('Others'), 'others'), |
---|
447 | (_('Prefer not to say'), 'no_say'),) |
---|
448 | ) |
---|
449 | |
---|
450 | disabled = schema.Bool( |
---|
451 | title = u'Disabled', |
---|
452 | default = False, |
---|
453 | required = False, |
---|
454 | ) |
---|
455 | |
---|
456 | |
---|
457 | class INigeriaStudent(INigeriaStudentBase,INigeriaUGStudentClearance, |
---|
458 | INigeriaPGStudentClearance,INigeriaStudentPersonal): |
---|
459 | """Representation of a student. |
---|
460 | |
---|
461 | """ |
---|
462 | |
---|
463 | class INigeriaStudentPersonalEdit(INigeriaStudentPersonal): |
---|
464 | """Interface for editing personal data by students. |
---|
465 | |
---|
466 | Here we can repeat the fields from IStudentPersonal and set the |
---|
467 | `required` if necessary. |
---|
468 | """ |
---|
469 | |
---|
470 | perm_address = schema.Text( |
---|
471 | title = _(u'Permanent Address'), |
---|
472 | required = True, |
---|
473 | ) |
---|
474 | |
---|
475 | next_kin_name = schema.TextLine( |
---|
476 | title = _(u'Next of Kin Name'), |
---|
477 | required = True, |
---|
478 | readonly = False, |
---|
479 | ) |
---|
480 | |
---|
481 | next_kin_relation = schema.TextLine( |
---|
482 | title = _(u'Next of Kin Relationship'), |
---|
483 | required = True, |
---|
484 | readonly = False, |
---|
485 | ) |
---|
486 | |
---|
487 | next_kin_address = schema.Text( |
---|
488 | title = _(u'Next of Kin Address'), |
---|
489 | required = True, |
---|
490 | readonly = False, |
---|
491 | ) |
---|
492 | |
---|
493 | next_kin_phone = PhoneNumber( |
---|
494 | title = _(u'Next of Kin Phone'), |
---|
495 | description = u'', |
---|
496 | required = True, |
---|
497 | readonly = False, |
---|
498 | ) |
---|
499 | |
---|
500 | INigeriaStudentPersonalEdit['perm_address'].order = INigeriaStudentPersonal[ |
---|
501 | 'perm_address'].order |
---|
502 | INigeriaStudentPersonalEdit['next_kin_name'].order = INigeriaStudentPersonal[ |
---|
503 | 'next_kin_name'].order |
---|
504 | INigeriaStudentPersonalEdit['next_kin_relation'].order = INigeriaStudentPersonal[ |
---|
505 | 'next_kin_relation'].order |
---|
506 | INigeriaStudentPersonalEdit['next_kin_address'].order = INigeriaStudentPersonal[ |
---|
507 | 'next_kin_address'].order |
---|
508 | INigeriaStudentPersonalEdit['next_kin_phone'].order = INigeriaStudentPersonal[ |
---|
509 | 'next_kin_phone'].order |
---|
510 | |
---|
511 | class INigeriaStudentStudyCourse(IStudentStudyCourse): |
---|
512 | """A container for student study levels. |
---|
513 | |
---|
514 | """ |
---|
515 | |
---|
516 | class INigeriaStudentStudyLevel(IStudentStudyLevel): |
---|
517 | """A container for course tickets. |
---|
518 | |
---|
519 | """ |
---|
520 | |
---|
521 | class INigeriaStudentOnlinePayment(INigeriaOnlinePayment): |
---|
522 | """A student payment via payment gateways. |
---|
523 | |
---|
524 | This Interface does not inherit from IStudentOnlinePayment. |
---|
525 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
526 | """ |
---|
527 | |
---|
528 | formatted_p_date = Attribute("Formatted pyment date") |
---|
529 | |
---|
530 | p_current = schema.Bool( |
---|
531 | title = _(u'Current Session Payment'), |
---|
532 | default = True, |
---|
533 | required = False, |
---|
534 | ) |
---|
535 | |
---|
536 | p_level = schema.Choice( |
---|
537 | title = _(u'Payment Level'), |
---|
538 | source = StudyLevelSource(), |
---|
539 | required = False, |
---|
540 | ) |
---|
541 | |
---|
542 | p_split_data = schema.Text( |
---|
543 | title = _(u'Split Payment Data'), |
---|
544 | required = False, |
---|
545 | readonly = False, |
---|
546 | ) |
---|
547 | |
---|
548 | INigeriaStudentOnlinePayment['p_level'].order = INigeriaStudentOnlinePayment[ |
---|
549 | 'p_session'].order |
---|
550 | |
---|
551 | class INigeriaCourseTicket(ICourseTicket): |
---|
552 | """A course ticket. |
---|
553 | |
---|
554 | """ |
---|
555 | |
---|
556 | class INigeriaStudentUpdateByRegNo(INigeriaStudent): |
---|
557 | """Representation of a student. Skip regular reg_number validation. |
---|
558 | |
---|
559 | """ |
---|
560 | reg_number = schema.TextLine( |
---|
561 | title = _(u'Registration Number'), |
---|
562 | required = False, |
---|
563 | ) |
---|
564 | |
---|
565 | class INigeriaStudentUpdateByMatricNo(INigeriaStudent): |
---|
566 | """Representation of a student. Skip regular matric_number validation. |
---|
567 | |
---|
568 | """ |
---|
569 | matric_number = schema.TextLine( |
---|
570 | title = _(u'Matriculation Number'), |
---|
571 | required = False, |
---|
572 | ) |
---|