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

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

Customize IUGStudentClearance instead of INigeriaUGStudentClearance. Some IUGStudentClearance fields must be required.

  • Property svn:keywords set to Id
File size: 14.3 KB
RevLine 
[7505]1## $Id: interfaces.py 14250 2016-11-02 14:42:04Z 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'),
267        required = True,
268        readonly = False,
269        )
270    fst_sit_no = schema.TextLine(
271        title = _(u'Exam Number'),
272        required = True,
273        readonly = False,
274        )
275
[14107]276    fst_sit_sc_pin = schema.TextLine(
[14084]277        title = _(u'Scratch Card Pin'),
[14250]278        required = True,
[14084]279        readonly = False,
280        )
281
[14107]282    fst_sit_sc_serial_number = schema.TextLine(
[14084]283        title = _(u'Scratch Card Serial Number'),
[14250]284        required = True,
285        readonly = False,
286        )
287
288    fst_sit_date = FormattedDate(
289        title = _(u'Exam Date'),
290        required = True,
291        readonly = False,
292        show_year = True,
293        )
294
295    fst_sit_type = schema.Choice(
296        title = _(u'Exam Type'),
297        required = True,
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 = True,
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
433
[8867]434class ICustomPGStudentClearance(INigeriaPGStudentClearance):
[7995]435    """Representation of pg student clearance data.
[7505]436
437    """
438
[8101]439
[8204]440class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
441    ICustomPGStudentClearance,ICustomStudentPersonal):
[7995]442    """Representation of a student.
[7505]443
444    """
[8247]445
[8867]446class ICustomStudentStudyCourse(INigeriaStudentStudyCourse):
[8326]447    """A container for student study levels.
448
449    """
450
[14206]451    imported_cgpa = schema.Float(
452        title = _(u'Imported Cumulative GPA'),
453        required = False,
454        readonly = True,
455        )
456
[8867]457class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
[8326]458    """A container for course tickets.
459
460    """
461
[9914]462    total_credits_s1 = schema.Int(
463        title = _(u'1st Semester Units'),
464        required = False,
465        readonly = True,
466        )
467
468    total_credits_s2 = schema.Int(
469        title = _(u'2nd Semester Units'),
470        required = False,
471        readonly = True,
472        )
473
[10102]474    total_credits = schema.Int(
475        title = _(u'Total Units'),
476        required = False,
477        readonly = True,
478        )
479
[14206]480    imported_gpa = schema.Float(
481        title = _(u'Imported Level GPA'),
482        required = False,
483        readonly = True,
484        )
485
486    imported_cgpa = schema.Float(
487        title = _(u'Imported Cumulative GPA'),
488        required = False,
489        readonly = True,
490        )
491
492
[8247]493class ICustomStudentOnlinePayment(ICustomOnlinePayment):
494    """A student payment via payment gateways.
495
[8270]496    This Interface does not inherit from IStudentOnlinePayment.
497    Thus all fields from IStudentOnlinePayment have to be repeated here.
498    """
499
[9154]500    p_current = schema.Bool(
501        title = _(u'Current Session Payment'),
502        default = True,
503        required = False,
504        )
505
[13735]506    p_level = schema.Choice(
[8270]507        title = _(u'Payment Level'),
[13735]508        source = StudyLevelSource(),
[8270]509        required = False,
510        )
[8430]511
[8270]512ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[
[8326]513    'p_session'].order
514
[8867]515class ICustomCourseTicket(INigeriaCourseTicket):
[8326]516    """A course ticket.
517
[8583]518    """
519
[14113]520    score = schema.Int(
521        title = _(u'Score'),
522        required = False,
523        readonly = False,
524        max = 70,
525        )
526
[13770]527    ca = schema.Int(
[13834]528        title = _(u'CA'),
[13770]529        default = None,
530        required = False,
531        missing_value = None,
[14113]532        max = 30,
[13770]533        )
534
[13865]535class ICustomCourseTicketImport(ICustomCourseTicket):
536    """An interface for importing course results and nothing more.
537    """
538    score = schema.Int(
539        title = _(u'Score'),
540        required = False,
541        readonly = False,
[14113]542        max = 70,
[13865]543        )
544
545    ca = schema.Int(
546        title = _(u'CA'),
547        required = False,
548        readonly = False,
[14113]549        max = 30,
[13865]550        )
551
552    level_session = schema.Choice(
553        title = _(u'Level Session'),
554        source = academic_sessions_vocab,
555        required = False,
556        readonly = False,
557        )
558
[13834]559ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order
[13770]560
[8867]561class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
[8583]562    """Representation of a student. Skip regular reg_number validation.
563
564    """
565
[8867]566class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo):
[8583]567    """Representation of a student. Skip regular matric_number validation.
568
[8867]569    """
Note: See TracBrowser for help on using the repository browser.