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

Last change on this file since 13621 was 13620, checked in by Henrik Bettermann, 9 years ago

Add fields, permissions, browser views and buttons to enable financial clearance by bursory officers.

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