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

Last change on this file since 16782 was 15471, checked in by Henrik Bettermann, 5 years ago

Store xml split data in payment ticket.

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