source: main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/interfaces.py @ 12777

Last change on this file since 12777 was 12503, checked in by Henrik Bettermann, 10 years ago

Ensure that lga and nationality are not contradictory.

  • Property svn:keywords set to Id
File size: 14.0 KB
RevLine 
[8862]1## $Id: interfaces.py 12503 2015-01-21 10:55:14Z 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##
18from zope import schema
[12503]19from zope.interface import Attribute, invariant, Invalid
[8862]20from waeup.kofa.schema import TextLineChoice
21from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab
[9567]22from waeup.kofa.schema import FormattedDate, PhoneNumber
[8862]23from waeup.kofa.schoolgrades import ResultEntryField
24from waeup.kofa.students.vocabularies import nats_vocab
25from waeup.kofa.students.interfaces import (
26    IStudentBase, IUGStudentClearance, IPGStudentClearance,
27    IStudentPersonal, IStudentNavigation, IStudentStudyLevel,
28    IStudentStudyCourse, ICourseTicket
29    )
30from waeup.kofa.students.vocabularies import (
31    nats_vocab, contextual_reg_num_source)
32from kofacustom.nigeria.interfaces import (
33    high_qual, high_grade, exam_types, LGASource)
34from kofacustom.nigeria.interfaces import MessageFactory as _
[8863]35from kofacustom.nigeria.payments.interfaces import INigeriaOnlinePayment
[8862]36
37
[8863]38class INigeriaStudentBase(IStudentBase):
[8862]39    """Representation of student base data.
40
41    """
42
43    reg_number = TextLineChoice(
44        title = _(u'Registration Number'),
45        required = False,
46        readonly = False,
47        source = contextual_reg_num_source,
48        )
49
[8966]50    is_staff = schema.Bool(
51        title = _(u'Staff Member'),
52        required = False,
53        readonly = False,
54        default = False,
55        )
56
[8949]57INigeriaStudentBase['reg_number'].order = IStudentBase[
58    'reg_number'].order
59
[8862]60
[8863]61class INigeriaUGStudentClearance(IUGStudentClearance):
[8862]62    """Representation of ug student clearance data.
63
64    """
[9535]65    officer_comment = schema.Text(
66        title = _(u"Officer's Comment"),
67        required = False,
68        )
69
[12392]70    physical_clearance_date = schema.TextLine(
[12120]71        title = _(u"Physical Clearance Date"),
[12107]72        required = False,
73        )
74
[9535]75    clearance_locked = schema.Bool(
76        title = _(u'Clearance form locked'),
77        default = False,
78        required = False,
79        )
80
81    clr_code = schema.TextLine(
82        title = _(u'CLR Activation Code'),
83        required = False,
84        readonly = False,
85        )
86
[8862]87    date_of_birth = FormattedDate(
88        title = _(u'Date of Birth'),
89        required = False,
90        show_year = True,
91        )
92
93    nationality = schema.Choice(
94        source = nats_vocab,
95        title = _(u'Nationality'),
[9036]96        required = True,
[8862]97        )
98
99    lga = schema.Choice(
100        source = LGASource(),
[10690]101        title = _(u'State / LGA'),
[8862]102        required = False,
103        )
104
105    def_adm = schema.Bool(
106        title = _(u'Deferent of Admission'),
107        required = False,
108        readonly = False,
[12416]109        default = False,
[8862]110        )
111
112    fst_sit_fname = schema.TextLine(
113        title = _(u'Full Name'),
114        required = False,
115        readonly = False,
116        )
117    fst_sit_no = schema.TextLine(
118        title = _(u'Exam Number'),
119        required = False,
120        readonly = False,
121        )
122
123    fst_sit_date = FormattedDate(
124        title = _(u'Exam Date'),
125        required = False,
126        readonly = False,
127        show_year = True,
128        )
129
130    fst_sit_type = schema.Choice(
131        title = _(u'Exam Type'),
132        required = False,
133        readonly = False,
134        vocabulary = exam_types,
135        )
136
137    fst_sit_results = schema.List(
138        title = _(u'Exam Results'),
139        value_type = ResultEntryField(),
140        required = False,
141        readonly = False,
142        default = [],
143        )
144
145    scd_sit_fname = schema.TextLine(
146        title = _(u'Full Name'),
147        required = False,
148        readonly = False,
149        )
150    scd_sit_no = schema.TextLine(
151        title = _(u'Exam Number'),
152        required = False,
153        readonly = False,
154        )
155
156    scd_sit_date = FormattedDate(
157        title = _(u'Exam Date'),
158        required = False,
159        readonly = False,
160        show_year = True,
161        )
162
163    scd_sit_type = schema.Choice(
164        title = _(u'Exam Type'),
165        required = False,
166        readonly = False,
167        vocabulary = exam_types,
168        )
169
170    scd_sit_results = schema.List(
171        title = _(u'Exam Results'),
172        value_type = ResultEntryField(),
173        required = False,
174        readonly = False,
175        default = [],
176        )
177
178    alr_fname = schema.TextLine(
179        title = _(u'Full Name'),
180        required = False,
181        readonly = False,
182        )
183    alr_no = schema.TextLine(
184        title = _(u'Exam Number'),
185        required = False,
186        readonly = False,
187        )
188
189    alr_date = FormattedDate(
190        title = _(u'Exam Date'),
191        required = False,
192        readonly = False,
193        show_year = True,
194        )
195
196    alr_results = schema.List(
197        title = _(u'Exam Results'),
198        value_type = ResultEntryField(),
199        required = False,
200        readonly = False,
201        default = [],
202        )
203
204    hq_type = schema.Choice(
205        title = _(u'Qualification Obtained'),
206        required = False,
207        readonly = False,
208        vocabulary = high_qual,
209        )
210
[9552]211    hq_fname = schema.TextLine(
212        title = _(u'Full Name'),
213        required = False,
214        readonly = False,
215        )
216
[8862]217    hq_matric_no = schema.TextLine(
218        title = _(u'Former Matric Number'),
219        required = False,
220        readonly = False,
221        )
222
223    hq_degree = schema.Choice(
224        title = _(u'Class of Degree'),
225        required = False,
226        readonly = False,
227        vocabulary = high_grade,
228        )
229
230    hq_school = schema.TextLine(
231        title = _(u'Institution Attended'),
232        required = False,
233        readonly = False,
234        )
235
236    hq_session = schema.TextLine(
237        title = _(u'Years Attended'),
238        required = False,
239        readonly = False,
240        )
241
242    hq_disc = schema.TextLine(
243        title = _(u'Discipline'),
244        required = False,
245        readonly = False,
246        )
247
[12503]248    @invariant
249    def check_lga_nationality(student):
250        if student.nationality != 'NG' and student.lga not in ('foreigner', None):
251            raise Invalid(_('Nationalty and LGA are contradictory.'))
252        if student.nationality == 'NG' and student.lga == 'foreigner':
253            raise Invalid(_('Nationalty and LGA are contradictory.'))
[8862]254
[12503]255
[8863]256class INigeriaPGStudentClearance(INigeriaUGStudentClearance):
[8862]257    """Representation of pg student clearance data.
258
259    """
260
261    hq2_type = schema.Choice(
262        title = _(u'Qualification Obtained'),
263        required = False,
264        readonly = False,
265        vocabulary = high_qual,
266        )
267
268    hq2_matric_no = schema.TextLine(
269        title = _(u'Former Matric Number'),
270        required = False,
271        readonly = False,
272        )
273
274    hq2_degree = schema.Choice(
275        title = _(u'Class of Degree'),
276        required = False,
277        readonly = False,
278        vocabulary = high_grade,
279        )
280
281    hq2_school = schema.TextLine(
282        title = _(u'Institution Attended'),
283        required = False,
284        readonly = False,
285        )
286
287    hq2_session = schema.TextLine(
288        title = _(u'Years Attended'),
289        required = False,
290        readonly = False,
291        )
292
293    hq2_disc = schema.TextLine(
294        title = _(u'Discipline'),
295        required = False,
296        readonly = False,
297        )
298
299    nysc_year = schema.Int(
300        title = _(u'Nysc Year'),
301        required = False,
302        readonly = False,
303        )
304
[8946]305    nysc_location = schema.TextLine(
306        title = _(u'Nysc Location'),
307        required = False,
308        )
309
[8862]310    nysc_lga = schema.Choice(
311        source = LGASource(),
[8946]312        title = _(u'Nysc LGA'),
[8862]313        required = False,
314        )
315
316    employer = schema.TextLine(
317        title = _(u'Employer'),
318        required = False,
319        readonly = False,
320        )
321
322    emp_position = schema.TextLine(
323        title = _(u'Employer Position'),
324        required = False,
325        readonly = False,
326        )
327
328    emp_start = FormattedDate(
329        title = _(u'Start Date'),
330        required = False,
331        readonly = False,
332        show_year = True,
333        )
334
335    emp_end = FormattedDate(
336        title = _(u'End Date'),
337        required = False,
338        readonly = False,
339        show_year = True,
340        )
341
342    emp_reason = schema.TextLine(
343        title = _(u'Reason for Leaving'),
344        required = False,
345        readonly = False,
346        )
347
348    employer2 = schema.TextLine(
349        title = _(u'2nd Employer'),
350        required = False,
351        readonly = False,
352        )
353
354    emp2_position = schema.TextLine(
355        title = _(u'2nd Employer Position'),
356        required = False,
357        readonly = False,
358        )
359
360    emp2_start = FormattedDate(
361        title = _(u'Start Date'),
362        required = False,
363        readonly = False,
364        show_year = True,
365        )
366    emp2_end = FormattedDate(
367        title = _(u'End Date'),
368        required = False,
369        readonly = False,
370        show_year = True,
371        )
372
373    emp2_reason = schema.TextLine(
374        title = _(u'Reason for Leaving'),
375        required = False,
376        readonly = False,
377        )
378
379    former_matric = schema.TextLine(
380        title = _(u'If yes, matric number'),
381        required = False,
382        readonly = False,
383        )
384
[9564]385class INigeriaStudentPersonal(IStudentPersonal):
386    """Student personal data.
[8862]387
[9564]388    """
389
390    is_foreigner = Attribute('True if student is non-Nigerian')
391
392    next_kin_name = schema.TextLine(
393        title = _(u'Next of Kin Name'),
394        required = False,
395        readonly = False,
396        )
397
398    next_kin_relation = schema.TextLine(
399        title = _(u'Next of Kin Relationship'),
400        required = False,
401        readonly = False,
402        )
403
404    next_kin_address = schema.Text(
405        title = _(u'Next of Kin Address'),
406        required = False,
407        readonly = False,
408        )
409
[9567]410    next_kin_phone = PhoneNumber(
411        title = _(u'Next of Kin Phone'),
412        description = u'',
413        required = False,
414        readonly = False,
415        )
416
[9564]417    marit_stat = schema.Choice(
418        title = u'Maritual Status',
419        default = 'unmarried',
420        required = False,
421        vocabulary = SimpleKofaVocabulary(
422            (_('Unmarried'), 'unmarried'),
423            (_('Married'), 'married'),)
424        )
425
426    religion = schema.Choice(
427        title = u'Religion',
428        default = 'no_say',
429        required = False,
430        vocabulary = SimpleKofaVocabulary(
431            (_('Muslim'), 'muslim'),
432            (_('Christian'), 'christian'),
433            (_('Others'), 'others'),
434            (_('Prefer not to say'), 'no_say'),)
435        )
436
437    disabled = schema.Bool(
438        title = u'Disabled',
439        default = False,
440        required = False,
441        )
442
443
[8863]444class INigeriaStudent(INigeriaStudentBase,INigeriaUGStudentClearance,
445    INigeriaPGStudentClearance,INigeriaStudentPersonal):
[8862]446    """Representation of a student.
447
448    """
449
[9564]450class INigeriaStudentPersonalEdit(INigeriaStudentPersonal):
451    """Interface for editing personal data by students.
452
453    Here we can repeat the fields from IStudentPersonal and set the
454    `required` if necessary.
455    """
456
457    perm_address = schema.Text(
458        title = _(u'Permanent Address'),
459        required = True,
460        )
461
462    next_kin_name = schema.TextLine(
463        title = _(u'Next of Kin Name'),
464        required = True,
465        readonly = False,
466        )
467
468    next_kin_relation = schema.TextLine(
469        title = _(u'Next of Kin Relationship'),
470        required = True,
471        readonly = False,
472        )
473
474    next_kin_address = schema.Text(
475        title = _(u'Next of Kin Address'),
476        required = True,
477        readonly = False,
478        )
479
[9567]480    next_kin_phone = PhoneNumber(
481        title = _(u'Next of Kin Phone'),
482        description = u'',
483        required = True,
484        readonly = False,
485        )
486
487INigeriaStudentPersonalEdit['perm_address'].order = INigeriaStudentPersonal[
488    'perm_address'].order
[9564]489INigeriaStudentPersonalEdit['next_kin_name'].order = INigeriaStudentPersonal[
490    'next_kin_name'].order
491INigeriaStudentPersonalEdit['next_kin_relation'].order = INigeriaStudentPersonal[
492    'next_kin_relation'].order
493INigeriaStudentPersonalEdit['next_kin_address'].order = INigeriaStudentPersonal[
494    'next_kin_address'].order
[9567]495INigeriaStudentPersonalEdit['next_kin_phone'].order = INigeriaStudentPersonal[
496    'next_kin_phone'].order
[9564]497
[8863]498class INigeriaStudentStudyCourse(IStudentStudyCourse):
[8862]499    """A container for student study levels.
500
501    """
502
[8863]503class INigeriaStudentStudyLevel(IStudentStudyLevel):
[8862]504    """A container for course tickets.
505
506    """
507
[8863]508class INigeriaStudentOnlinePayment(INigeriaOnlinePayment):
[8862]509    """A student payment via payment gateways.
510
511    This Interface does not inherit from IStudentOnlinePayment.
512    Thus all fields from IStudentOnlinePayment have to be repeated here.
513    """
514
[9471]515    p_current = schema.Bool(
516        title = _(u'Current Session Payment'),
517        default = True,
518        required = False,
519        )
520
[8862]521    p_level = schema.Int(
522        title = _(u'Payment Level'),
523        required = False,
524        )
525
[8863]526INigeriaStudentOnlinePayment['p_level'].order = INigeriaStudentOnlinePayment[
[8862]527    'p_session'].order
528
[8863]529class INigeriaCourseTicket(ICourseTicket):
[8862]530    """A course ticket.
531
532    """
533
[8863]534class INigeriaStudentUpdateByRegNo(INigeriaStudent):
[8862]535    """Representation of a student. Skip regular reg_number validation.
536
537    """
538    reg_number = schema.TextLine(
539        title = _(u'Registration Number'),
540        required = False,
541        )
542
[8863]543class INigeriaStudentUpdateByMatricNo(INigeriaStudent):
[8862]544    """Representation of a student. Skip regular matric_number validation.
545
546    """
547    matric_number = schema.TextLine(
548        title = _(u'Matriculation Number'),
549        required = False,
550        )
Note: See TracBrowser for help on using the repository browser.