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

Last change on this file since 16965 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
RevLine 
[7505]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##
[8867]18
[7505]19from zope import schema
[14250]20from zope.interface import Attribute, invariant
[9496]21from zc.sourcefactory.contextual import BasicContextualSourceFactory
22from zope.catalog.interfaces import ICatalog
23from zope.component import getUtility
[14250]24from waeup.kofa.schoolgrades import ResultEntryField
[13865]25from waeup.kofa.interfaces import (IKofaObject, academic_sessions_vocab)
[13795]26from waeup.kofa.students.vocabularies import (
[14250]27    StudyLevelSource, contextual_reg_num_source, nats_vocab,
[13795]28    )
[14250]29from waeup.kofa.students.interfaces import IUGStudentClearance
[13795]30from waeup.kofa.schema import PhoneNumber, FormattedDate, TextLineChoice
[14250]31from kofacustom.nigeria.interfaces import (
32    LGASource, exam_types, high_qual, high_grade)
[8867]33from kofacustom.nigeria.students.interfaces import (
34    INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance,
35    INigeriaStudentPersonal, INigeriaStudentStudyLevel,
36    INigeriaStudentStudyCourse, INigeriaCourseTicket,
37    INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo,
[15471]38    INigeriaStudentOnlinePayment,
[7505]39    )
[8867]40from waeup.aaue.payments.interfaces import ICustomOnlinePayment
[8444]41from waeup.aaue.interfaces import MessageFactory as _
[7505]42
[8867]43class ICustomStudentBase(INigeriaStudentBase):
[7618]44    """Representation of student base data.
[7505]45
46    """
[7618]47
[13795]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
[8867]68class ICustomStudentPersonal(INigeriaStudentPersonal):
[7618]69    """Student personal data.
70
71    """
72
[13351]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'',
[13573]124        required = False,
[13351]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
[14250]220class ICustomUGStudentClearance(IUGStudentClearance):
[7995]221    """Representation of ug student clearance data.
[7505]222
223    """
224
[14250]225    officer_comment = schema.Text(
226        title = _(u"Officer's Comment"),
227        required = False,
228        )
[13362]229
[14250]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
[13362]253    lga = schema.Choice(
254        source = LGASource(),
255        title = _(u'State / LGA'),
256        required = True,
257        )
258
[14250]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'),
[14297]268        required = False,
[14250]269        readonly = False,
270        )
271    fst_sit_no = schema.TextLine(
272        title = _(u'Exam Number'),
[14297]273        required = False,
[14250]274        readonly = False,
275        )
276
[14107]277    fst_sit_sc_pin = schema.TextLine(
[14084]278        title = _(u'Scratch Card Pin'),
[14297]279        required = False,
[14084]280        readonly = False,
281        )
282
[14107]283    fst_sit_sc_serial_number = schema.TextLine(
[14084]284        title = _(u'Scratch Card Serial Number'),
[14297]285        required = False,
[14250]286        readonly = False,
287        )
288
289    fst_sit_date = FormattedDate(
290        title = _(u'Exam Date'),
[14297]291        required = False,
[14250]292        readonly = False,
293        show_year = True,
294        )
295
296    fst_sit_type = schema.Choice(
297        title = _(u'Exam Type'),
[14297]298        required = False,
[14250]299        readonly = False,
300        vocabulary = exam_types,
301        )
302
303    fst_sit_results = schema.List(
304        title = _(u'Exam Results'),
305        value_type = ResultEntryField(),
[14297]306        required = False,
[14250]307        readonly = False,
308        defaultFactory=list,
309        )
310
311    scd_sit_fname = schema.TextLine(
312        title = _(u'Full Name'),
[14084]313        required = False,
314        readonly = False,
315        )
[14250]316    scd_sit_no = schema.TextLine(
317        title = _(u'Exam Number'),
318        required = False,
319        readonly = False,
320        )
[14084]321
[14107]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
[14250]334    scd_sit_date = FormattedDate(
335        title = _(u'Exam Date'),
336        required = False,
337        readonly = False,
338        show_year = True,
339        )
[13362]340
[14250]341    scd_sit_type = schema.Choice(
342        title = _(u'Exam Type'),
343        required = False,
344        readonly = False,
345        vocabulary = exam_types,
346        )
[13362]347
[14250]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
[14298]434class ICustomUGStudentClearanceEdit(ICustomUGStudentClearance):
435    """Representation of ug student clearance data.
[14250]436
[14298]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
[8867]500class ICustomPGStudentClearance(INigeriaPGStudentClearance):
[7995]501    """Representation of pg student clearance data.
[7505]502
503    """
504
[8101]505
[8204]506class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
507    ICustomPGStudentClearance,ICustomStudentPersonal):
[7995]508    """Representation of a student.
[7505]509
510    """
[8247]511
[8867]512class ICustomStudentStudyCourse(INigeriaStudentStudyCourse):
[8326]513    """A container for student study levels.
514
515    """
516
[14206]517    imported_cgpa = schema.Float(
518        title = _(u'Imported Cumulative GPA'),
519        required = False,
520        )
521
[8867]522class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
[8326]523    """A container for course tickets.
524
525    """
526
[9914]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
[10102]537    total_credits = schema.Int(
538        title = _(u'Total Units'),
539        required = False,
540        )
541
[14206]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
[15471]553class ICustomStudentOnlinePayment(INigeriaStudentOnlinePayment):
[8247]554    """A student payment via payment gateways.
555
[8270]556    """
557
[9154]558
[8867]559class ICustomCourseTicket(INigeriaCourseTicket):
[8326]560    """A course ticket.
561
[8583]562    """
563
[14113]564    score = schema.Int(
565        title = _(u'Score'),
566        required = False,
567        readonly = False,
[14299]568        max = 100,
[14113]569        )
570
[13770]571    ca = schema.Int(
[13834]572        title = _(u'CA'),
[13770]573        default = None,
574        required = False,
575        missing_value = None,
[15230]576        max = 90,
[13770]577        )
578
[15226]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
[13865]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,
[14271]594        max = 100,
[13865]595        )
596
597    ca = schema.Int(
598        title = _(u'CA'),
599        required = False,
600        readonly = False,
[15252]601        max = 90,
[13865]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
[13834]611ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order
[13770]612
[8867]613class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
[8583]614    """Representation of a student. Skip regular reg_number validation.
615
616    """
617
[8867]618class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo):
[8583]619    """Representation of a student. Skip regular matric_number validation.
620
[8867]621    """
Note: See TracBrowser for help on using the repository browser.