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

Last change on this file since 14677 was 14318, checked in by Henrik Bettermann, 8 years ago

Remove readonly flag.

  • Property svn:keywords set to Id
File size: 16.1 KB
RevLine 
[7505]1## $Id: interfaces.py 14318 2016-12-06 21:59:12Z 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,
[7505]38    )
[8867]39from waeup.aaue.payments.interfaces import ICustomOnlinePayment
[8444]40from waeup.aaue.interfaces import MessageFactory as _
[7505]41
[8867]42class ICustomStudentBase(INigeriaStudentBase):
[7618]43    """Representation of student base data.
[7505]44
45    """
[7618]46
[13795]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
[8867]67class ICustomStudentPersonal(INigeriaStudentPersonal):
[7618]68    """Student personal data.
69
70    """
71
[13351]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'',
[13573]123        required = False,
[13351]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
[14250]219class ICustomUGStudentClearance(IUGStudentClearance):
[7995]220    """Representation of ug student clearance data.
[7505]221
222    """
223
[14250]224    officer_comment = schema.Text(
225        title = _(u"Officer's Comment"),
226        required = False,
227        )
[13362]228
[14250]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
[13362]252    lga = schema.Choice(
253        source = LGASource(),
254        title = _(u'State / LGA'),
255        required = True,
256        )
257
[14250]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'),
[14297]267        required = False,
[14250]268        readonly = False,
269        )
270    fst_sit_no = schema.TextLine(
271        title = _(u'Exam Number'),
[14297]272        required = False,
[14250]273        readonly = False,
274        )
275
[14107]276    fst_sit_sc_pin = schema.TextLine(
[14084]277        title = _(u'Scratch Card Pin'),
[14297]278        required = False,
[14084]279        readonly = False,
280        )
281
[14107]282    fst_sit_sc_serial_number = schema.TextLine(
[14084]283        title = _(u'Scratch Card Serial Number'),
[14297]284        required = False,
[14250]285        readonly = False,
286        )
287
288    fst_sit_date = FormattedDate(
289        title = _(u'Exam Date'),
[14297]290        required = False,
[14250]291        readonly = False,
292        show_year = True,
293        )
294
295    fst_sit_type = schema.Choice(
296        title = _(u'Exam Type'),
[14297]297        required = False,
[14250]298        readonly = False,
299        vocabulary = exam_types,
300        )
301
302    fst_sit_results = schema.List(
303        title = _(u'Exam Results'),
304        value_type = ResultEntryField(),
[14297]305        required = False,
[14250]306        readonly = False,
307        defaultFactory=list,
308        )
309
310    scd_sit_fname = schema.TextLine(
311        title = _(u'Full Name'),
[14084]312        required = False,
313        readonly = False,
314        )
[14250]315    scd_sit_no = schema.TextLine(
316        title = _(u'Exam Number'),
317        required = False,
318        readonly = False,
319        )
[14084]320
[14107]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
[14250]333    scd_sit_date = FormattedDate(
334        title = _(u'Exam Date'),
335        required = False,
336        readonly = False,
337        show_year = True,
338        )
[13362]339
[14250]340    scd_sit_type = schema.Choice(
341        title = _(u'Exam Type'),
342        required = False,
343        readonly = False,
344        vocabulary = exam_types,
345        )
[13362]346
[14250]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
[14298]433class ICustomUGStudentClearanceEdit(ICustomUGStudentClearance):
434    """Representation of ug student clearance data.
[14250]435
[14298]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
[8867]499class ICustomPGStudentClearance(INigeriaPGStudentClearance):
[7995]500    """Representation of pg student clearance data.
[7505]501
502    """
503
[8101]504
[8204]505class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
506    ICustomPGStudentClearance,ICustomStudentPersonal):
[7995]507    """Representation of a student.
[7505]508
509    """
[8247]510
[8867]511class ICustomStudentStudyCourse(INigeriaStudentStudyCourse):
[8326]512    """A container for student study levels.
513
514    """
515
[14206]516    imported_cgpa = schema.Float(
517        title = _(u'Imported Cumulative GPA'),
518        required = False,
519        )
520
[8867]521class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
[8326]522    """A container for course tickets.
523
524    """
525
[9914]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
[10102]536    total_credits = schema.Int(
537        title = _(u'Total Units'),
538        required = False,
539        )
540
[14206]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
[8247]552class ICustomStudentOnlinePayment(ICustomOnlinePayment):
553    """A student payment via payment gateways.
554
[8270]555    This Interface does not inherit from IStudentOnlinePayment.
556    Thus all fields from IStudentOnlinePayment have to be repeated here.
557    """
558
[9154]559    p_current = schema.Bool(
560        title = _(u'Current Session Payment'),
561        default = True,
562        required = False,
563        )
564
[13735]565    p_level = schema.Choice(
[8270]566        title = _(u'Payment Level'),
[13735]567        source = StudyLevelSource(),
[8270]568        required = False,
569        )
[8430]570
[8270]571ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[
[8326]572    'p_session'].order
573
[8867]574class ICustomCourseTicket(INigeriaCourseTicket):
[8326]575    """A course ticket.
576
[8583]577    """
578
[14113]579    score = schema.Int(
580        title = _(u'Score'),
581        required = False,
582        readonly = False,
[14299]583        max = 100,
[14113]584        )
585
[13770]586    ca = schema.Int(
[13834]587        title = _(u'CA'),
[13770]588        default = None,
589        required = False,
590        missing_value = None,
[14113]591        max = 30,
[13770]592        )
593
[13865]594class ICustomCourseTicketImport(ICustomCourseTicket):
595    """An interface for importing course results and nothing more.
596    """
597    score = schema.Int(
598        title = _(u'Score'),
599        required = False,
600        readonly = False,
[14271]601        max = 100,
[13865]602        )
603
604    ca = schema.Int(
605        title = _(u'CA'),
606        required = False,
607        readonly = False,
[14113]608        max = 30,
[13865]609        )
610
611    level_session = schema.Choice(
612        title = _(u'Level Session'),
613        source = academic_sessions_vocab,
614        required = False,
615        readonly = False,
616        )
617
[13834]618ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order
[13770]619
[8867]620class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
[8583]621    """Representation of a student. Skip regular reg_number validation.
622
623    """
624
[8867]625class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo):
[8583]626    """Representation of a student. Skip regular matric_number validation.
627
[8867]628    """
Note: See TracBrowser for help on using the repository browser.