source: main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py @ 15369

Last change on this file since 15369 was 15252, checked in by Henrik Bettermann, 6 years ago

Increase max ca also for import.

  • Property svn:keywords set to Id
File size: 16.3 KB
Line 
1## $Id: interfaces.py 15252 2018-11-23 11:53:16Z 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
19from zope import schema
20from zope.interface import Attribute, invariant
21from zc.sourcefactory.contextual import BasicContextualSourceFactory
22from zope.catalog.interfaces import ICatalog
23from zope.component import getUtility
24from waeup.kofa.schoolgrades import ResultEntryField
25from waeup.kofa.interfaces import (IKofaObject, academic_sessions_vocab)
26from waeup.kofa.students.vocabularies import (
27    StudyLevelSource, contextual_reg_num_source, nats_vocab,
28    )
29from waeup.kofa.students.interfaces import IUGStudentClearance
30from waeup.kofa.schema import PhoneNumber, FormattedDate, TextLineChoice
31from kofacustom.nigeria.interfaces import (
32    LGASource, exam_types, high_qual, high_grade)
33from kofacustom.nigeria.students.interfaces import (
34    INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance,
35    INigeriaStudentPersonal, INigeriaStudentStudyLevel,
36    INigeriaStudentStudyCourse, INigeriaCourseTicket,
37    INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo,
38    )
39from waeup.aaue.payments.interfaces import ICustomOnlinePayment
40from waeup.aaue.interfaces import MessageFactory as _
41
42class ICustomStudentBase(INigeriaStudentBase):
43    """Representation of student base data.
44
45    """
46
47    reg_number = TextLineChoice(
48        title = _(u'JAMB Registration Number'),
49        required = False,
50        readonly = False,
51        source = contextual_reg_num_source,
52        )
53
54    application_number = schema.TextLine(
55        title = _(u'Application Number'),
56        required = False,
57        readonly = False,
58        )
59
60ICustomStudentBase['reg_number'].order = INigeriaStudentBase[
61    'reg_number'].order
62
63ICustomStudentBase['application_number'].order = ICustomStudentBase[
64    'reg_number'].order
65
66
67class ICustomStudentPersonal(INigeriaStudentPersonal):
68    """Student personal data.
69
70    """
71
72    father_name = schema.TextLine(
73        title = _(u'Father\'s Name'),
74        required = False,
75        readonly = False,
76        )
77
78    father_address = schema.Text(
79        title = _(u'Father\'s Permanent Address'),
80        required = False,
81        readonly = False,
82        )
83
84    father_work = schema.TextLine(
85        title = _(u'Father\'s Place of Work'),
86        required = False,
87        readonly = False,
88        )
89
90    father_phone = PhoneNumber(
91        title = _(u'Father\'s Phone'),
92        required = False,
93        readonly = False,
94        )
95
96    mother_name = schema.TextLine(
97        title = _(u'Mother\'s Name'),
98        required = False,
99        readonly = False,
100        )
101
102    mother_address = schema.Text(
103        title = _(u'Mother\'s Permanent Address'),
104        required = False,
105        readonly = False,
106        )
107
108    mother_work = schema.TextLine(
109        title = _(u'Mother\'s Place of Work'),
110        required = False,
111        readonly = False,
112        )
113
114    mother_phone = PhoneNumber(
115        title = _(u'Mother\'s Phone'),
116        required = False,
117        readonly = False,
118        )
119
120    phone_personal = PhoneNumber(
121        title = _(u'Student\'s Personal Phone'),
122        description = u'',
123        required = False,
124        readonly = False,
125        )
126
127class ICustomStudentPersonalEdit(ICustomStudentPersonal):
128    """Interface for editing personal data by students.
129
130    Here we can repeat the fields from IStudentPersonal and set the
131    `required` if necessary.
132    """
133
134    perm_address = schema.Text(
135        title = _(u'Permanent Address'),
136        required = True,
137        )
138
139    next_kin_name = schema.TextLine(
140        title = _(u'Next of Kin Name'),
141        required = True,
142        readonly = False,
143        )
144
145    next_kin_relation = schema.TextLine(
146        title = _(u'Next of Kin Relationship'),
147        required = True,
148        readonly = False,
149        )
150
151    next_kin_address = schema.Text(
152        title = _(u'Next of Kin Address'),
153        required = True,
154        readonly = False,
155        )
156
157    next_kin_phone = PhoneNumber(
158        title = _(u'Next of Kin Phone'),
159        description = u'',
160        required = True,
161        readonly = False,
162        )
163
164    father_name = schema.TextLine(
165        title = _(u'Father\'s Name'),
166        required = True,
167        readonly = False,
168        )
169
170    father_address = schema.Text(
171        title = _(u'Father\'s Permanent Address'),
172        required = True,
173        readonly = False,
174        )
175
176    father_work = schema.TextLine(
177        title = _(u'Father\'s Place of Work'),
178        required = True,
179        readonly = False,
180        )
181
182    father_phone = PhoneNumber(
183        title = _(u'Father\'s Phone'),
184        required = True,
185        readonly = False,
186        )
187
188    mother_name = schema.TextLine(
189        title = _(u'Mother\'s Name'),
190        required = True,
191        readonly = False,
192        )
193
194    mother_address = schema.Text(
195        title = _(u'Mother\'s Permanent Address'),
196        required = True,
197        readonly = False,
198        )
199
200    mother_work = schema.TextLine(
201        title = _(u'Mother\'s Place of Work'),
202        required = True,
203        readonly = False,
204        )
205
206    mother_phone = PhoneNumber(
207        title = _(u'Mother\'s Phone'),
208        required = True,
209        readonly = False,
210        )
211
212    phone_personal = PhoneNumber(
213        title = _(u'Student\'s Personal Phone'),
214        description = u'',
215        required = True,
216        readonly = False,
217        )
218
219class ICustomUGStudentClearance(IUGStudentClearance):
220    """Representation of ug student clearance data.
221
222    """
223
224    officer_comment = schema.Text(
225        title = _(u"Officer's Comment"),
226        required = False,
227        )
228
229    physical_clearance_date = schema.TextLine(
230        title = _(u"Physical Clearance Date"),
231        required = False,
232        )
233
234    clr_code = schema.TextLine(
235        title = _(u'CLR Activation Code'),
236        required = False,
237        readonly = False,
238        )
239
240    date_of_birth = FormattedDate(
241        title = _(u'Date of Birth'),
242        required = False,
243        show_year = True,
244        )
245
246    nationality = schema.Choice(
247        source = nats_vocab,
248        title = _(u'Nationality'),
249        required = True,
250        )
251
252    lga = schema.Choice(
253        source = LGASource(),
254        title = _(u'State / LGA'),
255        required = True,
256        )
257
258    def_adm = schema.Bool(
259        title = _(u'Deferment of Admission'),
260        required = False,
261        readonly = False,
262        default = False,
263        )
264
265    fst_sit_fname = schema.TextLine(
266        title = _(u'Full Name'),
267        required = False,
268        readonly = False,
269        )
270    fst_sit_no = schema.TextLine(
271        title = _(u'Exam Number'),
272        required = False,
273        readonly = False,
274        )
275
276    fst_sit_sc_pin = schema.TextLine(
277        title = _(u'Scratch Card Pin'),
278        required = False,
279        readonly = False,
280        )
281
282    fst_sit_sc_serial_number = schema.TextLine(
283        title = _(u'Scratch Card Serial Number'),
284        required = False,
285        readonly = False,
286        )
287
288    fst_sit_date = FormattedDate(
289        title = _(u'Exam Date'),
290        required = False,
291        readonly = False,
292        show_year = True,
293        )
294
295    fst_sit_type = schema.Choice(
296        title = _(u'Exam Type'),
297        required = False,
298        readonly = False,
299        vocabulary = exam_types,
300        )
301
302    fst_sit_results = schema.List(
303        title = _(u'Exam Results'),
304        value_type = ResultEntryField(),
305        required = False,
306        readonly = False,
307        defaultFactory=list,
308        )
309
310    scd_sit_fname = schema.TextLine(
311        title = _(u'Full Name'),
312        required = False,
313        readonly = False,
314        )
315    scd_sit_no = schema.TextLine(
316        title = _(u'Exam Number'),
317        required = False,
318        readonly = False,
319        )
320
321    scd_sit_sc_pin = schema.TextLine(
322        title = _(u'Scratch Card Pin'),
323        required = False,
324        readonly = False,
325        )
326
327    scd_sit_sc_serial_number = schema.TextLine(
328        title = _(u'Scratch Card Serial Number'),
329        required = False,
330        readonly = False,
331        )
332
333    scd_sit_date = FormattedDate(
334        title = _(u'Exam Date'),
335        required = False,
336        readonly = False,
337        show_year = True,
338        )
339
340    scd_sit_type = schema.Choice(
341        title = _(u'Exam Type'),
342        required = False,
343        readonly = False,
344        vocabulary = exam_types,
345        )
346
347    scd_sit_results = schema.List(
348        title = _(u'Exam Results'),
349        value_type = ResultEntryField(),
350        required = False,
351        readonly = False,
352        defaultFactory=list,
353        )
354
355
356    alr_fname = schema.TextLine(
357        title = _(u'Full Name'),
358        required = False,
359        readonly = False,
360        )
361    alr_no = schema.TextLine(
362        title = _(u'Exam Number'),
363        required = False,
364        readonly = False,
365        )
366
367    alr_date = FormattedDate(
368        title = _(u'Exam Date'),
369        required = False,
370        readonly = False,
371        show_year = True,
372        )
373
374    alr_results = schema.List(
375        title = _(u'Exam Results'),
376        value_type = ResultEntryField(),
377        required = False,
378        readonly = False,
379        defaultFactory=list,
380        )
381
382    hq_type = schema.Choice(
383        title = _(u'Qualification Obtained'),
384        required = False,
385        readonly = False,
386        vocabulary = high_qual,
387        )
388
389    hq_fname = schema.TextLine(
390        title = _(u'Full Name'),
391        required = False,
392        readonly = False,
393        )
394
395    hq_matric_no = schema.TextLine(
396        title = _(u'Former Matric Number'),
397        required = False,
398        readonly = False,
399        )
400
401    hq_degree = schema.Choice(
402        title = _(u'Class of Degree'),
403        required = False,
404        readonly = False,
405        vocabulary = high_grade,
406        )
407
408    hq_school = schema.TextLine(
409        title = _(u'Institution Attended'),
410        required = False,
411        readonly = False,
412        )
413
414    hq_session = schema.TextLine(
415        title = _(u'Years Attended'),
416        required = False,
417        readonly = False,
418        )
419
420    hq_disc = schema.TextLine(
421        title = _(u'Discipline'),
422        required = False,
423        readonly = False,
424        )
425
426    @invariant
427    def check_lga_nationality(student):
428        if student.nationality != 'NG' and student.lga not in ('foreigner', None):
429            raise Invalid(_('Nationalty and LGA are contradictory.'))
430        if student.nationality == 'NG' and student.lga == 'foreigner':
431            raise Invalid(_('Nationalty and LGA are contradictory.'))
432
433class ICustomUGStudentClearanceEdit(ICustomUGStudentClearance):
434    """Representation of ug student clearance data.
435
436    """
437
438    fst_sit_fname = schema.TextLine(
439        title = _(u'Full Name'),
440        required = True,
441        readonly = False,
442        )
443    fst_sit_no = schema.TextLine(
444        title = _(u'Exam Number'),
445        required = True,
446        readonly = False,
447        )
448
449    fst_sit_sc_pin = schema.TextLine(
450        title = _(u'Scratch Card Pin'),
451        required = True,
452        readonly = False,
453        )
454
455    fst_sit_sc_serial_number = schema.TextLine(
456        title = _(u'Scratch Card Serial Number'),
457        required = True,
458        readonly = False,
459        )
460
461    fst_sit_date = FormattedDate(
462        title = _(u'Exam Date'),
463        required = True,
464        readonly = False,
465        show_year = True,
466        )
467
468    fst_sit_type = schema.Choice(
469        title = _(u'Exam Type'),
470        required = True,
471        readonly = False,
472        vocabulary = exam_types,
473        )
474
475    fst_sit_results = schema.List(
476        title = _(u'Exam Results'),
477        value_type = ResultEntryField(),
478        required = True,
479        readonly = False,
480        defaultFactory=list,
481        )
482
483
484ICustomUGStudentClearanceEdit['fst_sit_fname'].order = ICustomUGStudentClearance[
485    'fst_sit_fname'].order
486ICustomUGStudentClearanceEdit['fst_sit_no'].order = ICustomUGStudentClearance[
487    'fst_sit_no'].order
488ICustomUGStudentClearanceEdit['fst_sit_sc_pin'].order = ICustomUGStudentClearance[
489    'fst_sit_sc_pin'].order
490ICustomUGStudentClearanceEdit['fst_sit_sc_serial_number'].order = ICustomUGStudentClearance[
491    'fst_sit_sc_serial_number'].order
492ICustomUGStudentClearanceEdit['fst_sit_date'].order = ICustomUGStudentClearance[
493    'fst_sit_date'].order
494ICustomUGStudentClearanceEdit['fst_sit_type'].order = ICustomUGStudentClearance[
495    'fst_sit_type'].order
496ICustomUGStudentClearanceEdit['fst_sit_results'].order = ICustomUGStudentClearance[
497    'fst_sit_results'].order
498
499class ICustomPGStudentClearance(INigeriaPGStudentClearance):
500    """Representation of pg student clearance data.
501
502    """
503
504
505class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
506    ICustomPGStudentClearance,ICustomStudentPersonal):
507    """Representation of a student.
508
509    """
510
511class ICustomStudentStudyCourse(INigeriaStudentStudyCourse):
512    """A container for student study levels.
513
514    """
515
516    imported_cgpa = schema.Float(
517        title = _(u'Imported Cumulative GPA'),
518        required = False,
519        )
520
521class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
522    """A container for course tickets.
523
524    """
525
526    total_credits_s1 = schema.Int(
527        title = _(u'1st Semester Units'),
528        required = False,
529        )
530
531    total_credits_s2 = schema.Int(
532        title = _(u'2nd Semester Units'),
533        required = False,
534        )
535
536    total_credits = schema.Int(
537        title = _(u'Total Units'),
538        required = False,
539        )
540
541    imported_gpa = schema.Float(
542        title = _(u'Imported Level GPA'),
543        required = False,
544        )
545
546    imported_cgpa = schema.Float(
547        title = _(u'Imported Cumulative GPA'),
548        required = False,
549        )
550
551
552class ICustomStudentOnlinePayment(ICustomOnlinePayment):
553    """A student payment via payment gateways.
554
555    This Interface does not inherit from IStudentOnlinePayment.
556    Thus all fields from IStudentOnlinePayment have to be repeated here.
557    """
558
559    p_current = schema.Bool(
560        title = _(u'Current Session Payment'),
561        default = True,
562        required = False,
563        )
564
565    p_level = schema.Choice(
566        title = _(u'Payment Level'),
567        source = StudyLevelSource(),
568        required = False,
569        )
570
571ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[
572    'p_session'].order
573
574class ICustomCourseTicket(INigeriaCourseTicket):
575    """A course ticket.
576
577    """
578
579    score = schema.Int(
580        title = _(u'Score'),
581        required = False,
582        readonly = False,
583        max = 100,
584        )
585
586    ca = schema.Int(
587        title = _(u'CA'),
588        default = None,
589        required = False,
590        missing_value = None,
591        max = 90,
592        )
593
594    imported_ts = schema.Int(
595        title = _(u'Imported Total Score'),
596        default = None,
597        required = False,
598        missing_value = None,
599        max = 100,
600        )
601
602class ICustomCourseTicketImport(ICustomCourseTicket):
603    """An interface for importing course results and nothing more.
604    """
605    score = schema.Int(
606        title = _(u'Score'),
607        required = False,
608        readonly = False,
609        max = 100,
610        )
611
612    ca = schema.Int(
613        title = _(u'CA'),
614        required = False,
615        readonly = False,
616        max = 90,
617        )
618
619    level_session = schema.Choice(
620        title = _(u'Level Session'),
621        source = academic_sessions_vocab,
622        required = False,
623        readonly = False,
624        )
625
626ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order
627
628class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
629    """Representation of a student. Skip regular reg_number validation.
630
631    """
632
633class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo):
634    """Representation of a student. Skip regular matric_number validation.
635
636    """
Note: See TracBrowser for help on using the repository browser.