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

Last change on this file since 17931 was 17866, checked in by Henrik Bettermann, 4 months ago

Implement final clearance.

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