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

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

Remove required condition from first sitting data.

  • Property svn:keywords set to Id
File size: 14.3 KB
Line 
1## $Id: interfaces.py 14297 2016-11-29 06:31:40Z 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
433
434class ICustomPGStudentClearance(INigeriaPGStudentClearance):
435    """Representation of pg student clearance data.
436
437    """
438
439
440class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
441    ICustomPGStudentClearance,ICustomStudentPersonal):
442    """Representation of a student.
443
444    """
445
446class ICustomStudentStudyCourse(INigeriaStudentStudyCourse):
447    """A container for student study levels.
448
449    """
450
451    imported_cgpa = schema.Float(
452        title = _(u'Imported Cumulative GPA'),
453        required = False,
454        readonly = True,
455        )
456
457class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
458    """A container for course tickets.
459
460    """
461
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
474    total_credits = schema.Int(
475        title = _(u'Total Units'),
476        required = False,
477        readonly = True,
478        )
479
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
493class ICustomStudentOnlinePayment(ICustomOnlinePayment):
494    """A student payment via payment gateways.
495
496    This Interface does not inherit from IStudentOnlinePayment.
497    Thus all fields from IStudentOnlinePayment have to be repeated here.
498    """
499
500    p_current = schema.Bool(
501        title = _(u'Current Session Payment'),
502        default = True,
503        required = False,
504        )
505
506    p_level = schema.Choice(
507        title = _(u'Payment Level'),
508        source = StudyLevelSource(),
509        required = False,
510        )
511
512ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[
513    'p_session'].order
514
515class ICustomCourseTicket(INigeriaCourseTicket):
516    """A course ticket.
517
518    """
519
520    score = schema.Int(
521        title = _(u'Score'),
522        required = False,
523        readonly = False,
524        max = 70,
525        )
526
527    ca = schema.Int(
528        title = _(u'CA'),
529        default = None,
530        required = False,
531        missing_value = None,
532        max = 30,
533        )
534
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,
542        max = 100,
543        )
544
545    ca = schema.Int(
546        title = _(u'CA'),
547        required = False,
548        readonly = False,
549        max = 30,
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
559ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order
560
561class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
562    """Representation of a student. Skip regular reg_number validation.
563
564    """
565
566class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo):
567    """Representation of a student. Skip regular matric_number validation.
568
569    """
Note: See TracBrowser for help on using the repository browser.