source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py

Last change on this file was 18067, checked in by Henrik Bettermann, 2 months ago

Add JAMB registration number and NIN.

  • Property svn:keywords set to Id
File size: 17.9 KB
RevLine 
[7853]1## $Id: interfaces.py 18067 2025-04-24 01:07:30Z henrik $
2##
3## Copyright (C) 2011 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"""Customized interfaces of the university application package.
19"""
20
[8012]21from zope import schema
[13877]22from zc.sourcefactory.basic import BasicSourceFactory
[8051]23from waeup.kofa.applicants.interfaces import (
[8053]24    IApplicantBaseData,
[8051]25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
[8531]27from waeup.kofa.interfaces import (
[13877]28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
29    IKofaObject)
30from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
[9465]31from waeup.kofa.schoolgrades import ResultEntryField
[8531]32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
[17744]33from waeup.kofa.applicants.interfaces import (
34    contextual_reg_num_source,
35    contextual_email_source,
36    IApplicantRegisterUpdate)
[8933]37from kofacustom.nigeria.applicants.interfaces import (
38    LGASource, high_qual, high_grade, exam_types,
39    INigeriaUGApplicant, INigeriaPGApplicant,
40    INigeriaApplicantOnlinePayment,
[9497]41    INigeriaUGApplicantEdit,
[8979]42    INigeriaApplicantUpdateByRegNo,
43    IPUTMEApplicantEdit,
[9463]44    OMIT_DISPLAY_FIELDS
[8933]45    )
[16918]46from waeup.fceokene.applicants.schools_tpu import SCHOOLS_TPU
47from waeup.fceokene.applicants.schools_utp import SCHOOLS_UTP
[8460]48from waeup.fceokene.interfaces import MessageFactory as _
[7853]49
[9463]50BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
51BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
[10852]52BEC_OMIT_MANAGE_FIELDS = ('special_application',)
[9463]53BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
54    'student_id', 'notice',
55    'screening_score',
56    'screening_venue',
57    'screening_date',
58    #'jamb_subjects',
59    #'jamb_score',
60    'aggregate')
61
[16854]62class TPUCertificateSource(AppCatCertificateSource):
63
64    def getValues(self, context):
65        resultlist = super(TPUCertificateSource, self).getValues(context)
[16924]66        return [i for i in resultlist if i.code.startswith('NCE')]
[16854]67
[16918]68class UTPCertificateSource(AppCatCertificateSource):
69
70    def getValues(self, context):
71        resultlist = super(UTPCertificateSource, self).getValues(context)
[16924]72        return [i for i in resultlist if i.code.startswith('BED')]
[16918]73
74class TPUSchoolSource(BasicSourceFactory):
75    """A source that delivers all kinds of TPU schools.
[13877]76    """
77    def getValues(self):
[14067]78        sorted_items = sorted(
[16918]79            SCHOOLS_TPU.items(),
[14067]80            key=lambda element: element[1][0] + element[1][1] +element[1][2])
[13877]81        return [item[0] for item in sorted_items]
82
[14499]83    def getToken(self, value):
84        return value
85
[13877]86    def getTitle(self, value):
[16918]87        if not SCHOOLS_TPU.get(value, None):
[15594]88            return u"none-existent"
[13877]89        return u"%s: %s -- %s" % (
[16918]90            SCHOOLS_TPU[value][0],
91            SCHOOLS_TPU[value][1],
92            SCHOOLS_TPU[value][2],)
[13877]93
[16918]94class UTPSchoolSource(BasicSourceFactory):
95    """A source that delivers all kinds of UTP schools.
96    """
97    def getValues(self):
98        sorted_items = sorted(
99            SCHOOLS_UTP.items(),
100            key=lambda element: element[1][0] + element[1][1] +element[1][2])
101        return [item[0] for item in sorted_items]
102
103    def getToken(self, value):
104        return value
105
106    def getTitle(self, value):
107        if not SCHOOLS_UTP.get(value, None):
108            return u"none-existent"
109        return u"%s: %s -- %s" % (
110            SCHOOLS_UTP[value][0],
111            SCHOOLS_UTP[value][1],
112            SCHOOLS_UTP[value][2],)
113
[13877]114class ITPURegistration(IKofaObject):
115    """A TPU registrant.
116    """
117
118    suspended = schema.Bool(
119        title = _(u'Account suspended'),
120        default = False,
121        required = False,
122        )
123
124    locked = schema.Bool(
125        title = _(u'Form locked'),
126        default = False,
127        required = False,
128        )
129
130    applicant_id = schema.TextLine(
131        title = _(u'Applicant Id'),
132        required = False,
133        readonly = False,
134        )
135
136    reg_number = schema.TextLine(
137        title = _(u'Registration Number'),
138        required = False,
139        readonly = False,
140        )
141
142    matric_number = schema.TextLine(
143        title = _(u'Matriculation Number'),
144        required = False,
145        readonly = False,
146        )
147
148    firstname = schema.TextLine(
149        title = _(u'First Name'),
150        required = True,
151        )
152
153    middlename = schema.TextLine(
154        title = _(u'Middle Name'),
155        required = False,
156        )
157
158    lastname = schema.TextLine(
159        title = _(u'Last Name (Surname)'),
160        required = True,
161        )
162
[17744]163    email = TextLineChoice(
[13877]164        title = _(u'Email Address'),
165        required = True,
166        constraint=validate_email,
[17744]167        source = contextual_email_source,
[13877]168        )
169
170    phone = PhoneNumber(
171        title = _(u'Phone'),
172        description = u'',
173        required = False,
174        )
175
176    perm_address = schema.Text(
177        title = _(u'Home Address'),
178        required = False,
179        readonly = False,
180        )
181
182    lga = schema.Choice(
183        source = LGASource(),
184        title = _(u'State/LGA'),
185        required = False,
186        )
187
[16844]188    subj_comb = schema.Choice(
[13877]189        title = _(u'Subject Combination'),
[16854]190        source = TPUCertificateSource(),
[17359]191        required = False,
[13877]192        )
193
[16926]194    school_tpu = schema.Choice(
[13877]195        title = _(u'1st Choice TPZ and School'),
[16918]196        source = TPUSchoolSource(),
[17359]197        required = False,
[13877]198        )
199
[16918]200class IUTPRegistration(IKofaObject):
201    """An UTP registrant.
202    """
203
204    suspended = schema.Bool(
205        title = _(u'Account suspended'),
206        default = False,
207        required = False,
208        )
209
210    locked = schema.Bool(
211        title = _(u'Form locked'),
212        default = False,
213        required = False,
214        )
215
216    applicant_id = schema.TextLine(
217        title = _(u'Applicant Id'),
218        required = False,
219        readonly = False,
220        )
221
222    reg_number = schema.TextLine(
223        title = _(u'Registration Number'),
224        required = False,
225        readonly = False,
226        )
227
228    matric_number = schema.TextLine(
229        title = _(u'Matriculation Number'),
230        required = False,
231        readonly = False,
232        )
233
234    firstname = schema.TextLine(
235        title = _(u'First Name'),
236        required = True,
237        )
238
239    middlename = schema.TextLine(
240        title = _(u'Middle Name'),
241        required = False,
242        )
243
244    lastname = schema.TextLine(
245        title = _(u'Last Name (Surname)'),
246        required = True,
247        )
248
[17744]249    email = TextLineChoice(
[16918]250        title = _(u'Email Address'),
251        required = True,
252        constraint=validate_email,
[17744]253        source = contextual_email_source,
[16918]254        )
255
256    phone = PhoneNumber(
257        title = _(u'Phone'),
258        description = u'',
259        required = False,
260        )
261
262    perm_address = schema.Text(
263        title = _(u'Home Address'),
264        required = False,
265        readonly = False,
266        )
267
268    lga = schema.Choice(
269        source = LGASource(),
270        title = _(u'State/LGA'),
271        required = False,
272        )
273
274    subj_comb = schema.Choice(
275        title = _(u'Subject Combination'),
276        source = UTPCertificateSource(),
[17359]277        required = False,
[16918]278        )
279
[16927]280    school_utp = schema.Choice(
[16918]281        title = _(u'1st Choice UTP and School'),
282        source = UTPSchoolSource(),
[17359]283        required = False,
[16918]284        )
285
[8933]286class ICustomUGApplicant(INigeriaUGApplicant):
[8012]287    """An undergraduate applicant.
288
[8520]289    This interface defines the least common multiple of all fields
290    in ug application forms. In customized forms, fields can be excluded by
[9463]291    adding them to the OMIT* tuples.
[8012]292    """
293
[17744]294    email = TextLineChoice(
295        title = _(u'Email Address'),
296        required = True,
297        constraint=validate_email,
298        source = contextual_email_source,
299        )
300
[9465]301    nationality = schema.Choice(
302        source = nats_vocab,
303        title = _(u'Nationality'),
304        required = True,
305        )
306    lga = schema.Choice(
307        source = LGASource(),
308        title = _(u'State/LGA (Nigerians only)'),
309        required = False,
310        )
311    #perm_address = schema.Text(
312    #    title = _(u'Permanent Address'),
313    #    required = False,
314    #    )
315    course1 = schema.Choice(
316        title = _(u'1st Choice Course of Study'),
317        source = AppCatCertificateSource(),
[13884]318        required = False,
[9465]319        )
320    course2 = schema.Choice(
321        title = _(u'2nd Choice Course of Study'),
322        source = AppCatCertificateSource(),
323        required = False,
324        )
[9463]325    olevel_type = schema.Choice(
[9500]326        title = _(u'1st Qualification Obtained'),
[9463]327        required = False,
328        readonly = False,
[9465]329        vocabulary = exam_types,
330        )
331    olevel_school = schema.TextLine(
[9500]332        title = _(u'1st Institution Attended'),
[9465]333        required = False,
334        readonly = False,
335        )
336    olevel_exam_number = schema.TextLine(
[9500]337        title = _(u'1st Exam Number'),
[9465]338        required = False,
339        readonly = False,
340        )
341    olevel_exam_date = FormattedDate(
[9500]342        title = _(u'1st Exam Date'),
[9465]343        required = False,
344        readonly = False,
345        show_year = True,
346        )
347    olevel_results = schema.List(
[9500]348        title = _(u'1st Exam Results'),
[9465]349        value_type = ResultEntryField(),
350        required = False,
351        readonly = False,
[14018]352        defaultFactory=list,
[9465]353        )
[9500]354    olevel_type2 = schema.Choice(
355        title = _(u'2nd Qualification Obtained'),
356        required = False,
357        readonly = False,
358        vocabulary = exam_types,
359        )
360    olevel_school2 = schema.TextLine(
361        title = _(u'2nd Institution Attended'),
362        required = False,
363        readonly = False,
364        )
365    olevel_exam_number2 = schema.TextLine(
366        title = _(u'2nd Exam Number'),
367        required = False,
368        readonly = False,
369        )
370    olevel_exam_date2 = FormattedDate(
371        title = _(u'2nd Exam Date'),
372        required = False,
373        readonly = False,
374        show_year = True,
375        )
376    olevel_results2 = schema.List(
377        title = _(u'2nd Exam Results'),
378        value_type = ResultEntryField(),
379        required = False,
380        readonly = False,
[14018]381        defaultFactory=list,
[9500]382        )
[9465]383    hq_type = schema.Choice(
384        title = _(u'Qualification Obtained'),
385        required = False,
386        readonly = False,
[9463]387        vocabulary = high_qual,
388        )
[9465]389    hq_matric_no = schema.TextLine(
[9463]390        title = _(u'Former Matric Number'),
391        required = False,
392        readonly = False,
393        )
[9465]394    hq_degree = schema.Choice(
[9463]395        title = _(u'Class of Degree'),
396        required = False,
397        readonly = False,
398        vocabulary = high_grade,
399        )
[9465]400    hq_school = schema.TextLine(
[9463]401        title = _(u'Institution Attended'),
402        required = False,
403        readonly = False,
404        )
[9465]405    hq_session = schema.TextLine(
[9463]406        title = _(u'Years Attended'),
407        required = False,
408        readonly = False,
409        )
[9465]410    hq_disc = schema.TextLine(
[9463]411        title = _(u'Discipline'),
412        required = False,
413        readonly = False,
414        )
[9465]415    jamb_subjects = schema.Text(
416        title = _(u'Subjects and Scores'),
[10533]417        description = _(u'(one subject with score per line)'),
[9465]418        required = False,
419        )
420    jamb_score = schema.Int(
421        title = _(u'Total JAMB Score'),
422        required = False,
423        )
[10500]424    jamb_reg_number = schema.TextLine(
425        title = _(u'JAMB Registration Number'),
426        required = False,
427        )
[18067]428    nin = schema.Int(
429        title = _(u'National Identity Number (NIN)'),
430        required = False,
431        readonly = False,
432        min=10000000000,
433        max=99999999999,
434        )
[9465]435    notice = schema.Text(
436        title = _(u'Notice'),
437        required = False,
438        )
439    screening_venue = schema.TextLine(
440        title = _(u'Screening Venue'),
441        required = False,
442        )
443    screening_date = schema.TextLine(
444        title = _(u'Screening Date'),
445        required = False,
446        )
447    screening_score = schema.Int(
448        title = _(u'Screening Score (%)'),
449        required = False,
450        )
451    aggregate = schema.Int(
452        title = _(u'Aggregate Score (%)'),
453        description = _(u'(average of relative JAMB and PUTME scores)'),
454        required = False,
455        )
456    result_uploaded = schema.Bool(
457        title = _(u'Result uploaded'),
458        default = False,
[14335]459        required = False,
[9465]460        )
461    student_id = schema.TextLine(
462        title = _(u'Student Id'),
463        required = False,
464        readonly = False,
465        )
466    course_admitted = schema.Choice(
467        title = _(u'Admitted Course of Study'),
468        source = CertificateSource(),
469        required = False,
470        )
471    locked = schema.Bool(
472        title = _(u'Form locked'),
473        default = False,
[14335]474        required = False,
[9465]475        )
[9463]476
[17744]477ICustomUGApplicant[
478    'email'].order =  INigeriaUGApplicant['email'].order
[9463]479
[8933]480class ICustomPGApplicant(INigeriaPGApplicant):
[7853]481    """A postgraduate applicant.
482
[8520]483    This interface defines the least common multiple of all fields
484    in pg application forms. In customized forms, fields can be excluded by
485    adding them to the PG_OMIT* tuples.
[7866]486    """
487
[17744]488    email = TextLineChoice(
489        title = _(u'Email Address'),
490        required = True,
491        constraint=validate_email,
492        source = contextual_email_source,
493        )
494
495ICustomPGApplicant[
496    'email'].order =  INigeriaPGApplicant['email'].order
497
[13877]498class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
[16918]499    ITPURegistration, IUTPRegistration):
[13877]500    """An interface for all types of applicants.
[8012]501
[8933]502    Attention: The ICustomPGApplicant field seetings will be overwritten
503    by ICustomPGApplicant field settings. If a field is defined
[8729]504    in both interfaces zope.schema validates only against the
[8933]505    constraints in ICustomUGApplicant. This does not affect the forms
506    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]507    """
508
[8745]509    def writeLogMessage(view, comment):
[8053]510        """Adds an INFO message to the log file
511        """
512
513    def createStudent():
514        """Create a student object from applicatnt data
515        and copy applicant object.
516        """
517
[9497]518class ICustomUGApplicantEdit(ICustomUGApplicant):
[8729]519    """An undergraduate applicant interface for edit forms.
[8012]520
521    Here we can repeat the fields from base data and set the
522    `required` and `readonly` attributes to True to further restrict
523    the data access. Or we can allow only certain certificates to be
524    selected by choosing the appropriate source.
525
526    We cannot omit fields here. This has to be done in the
527    respective form page.
528    """
529
[17744]530    email = TextLineChoice(
[9497]531        title = _(u'Email Address'),
532        required = True,
533        constraint=validate_email,
[17744]534        source = contextual_email_source,
[9497]535        )
536    date_of_birth = FormattedDate(
537        title = _(u'Date of Birth'),
538        required = True,
539        show_year = True,
540        )
[11776]541    jamb_reg_number = schema.TextLine(
542        title = _(u'JAMB Registration Number'),
543        required = True,
544        )
[13884]545    course1 = schema.Choice(
546        title = _(u'1st Choice Course of Study'),
547        source = AppCatCertificateSource(),
548        required = True,
549        )
[9497]550
[10500]551ICustomUGApplicantEdit[
552    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
553ICustomUGApplicantEdit[
554    'email'].order =  ICustomUGApplicant['email'].order
555ICustomUGApplicantEdit[
[13238]556    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
[13884]557ICustomUGApplicantEdit[
558    'course1'].order =  ICustomUGApplicant['course1'].order
[10500]559
[9497]560class ICustomPGApplicantEdit(ICustomPGApplicant):
[7866]561    """A postgraduate applicant interface for editing.
562
563    Here we can repeat the fields from base data and set the
564    `required` and `readonly` attributes to True to further restrict
565    the data access. Or we can allow only certain certificates to be
566    selected by choosing the appropriate source.
567
568    We cannot omit fields here. This has to be done in the
569    respective form page.
[8017]570    """
[8454]571
[17744]572    email = TextLineChoice(
[9497]573        title = _(u'Email Address'),
574        required = True,
575        constraint=validate_email,
[17744]576        source = contextual_email_source,
[9497]577        )
578    date_of_birth = FormattedDate(
579        title = _(u'Date of Birth'),
580        required = True,
581        show_year = True,
582        )
583
[10500]584ICustomPGApplicantEdit[
585    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
586ICustomPGApplicantEdit[
587    'email'].order =  ICustomPGApplicant['email'].order
588
589
[8933]590class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]591    """An applicant payment via payment gateways.
592
593    """
[8531]594
[8979]595class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
[8531]596    """An undergraduate applicant interface for editing.
597
598    Here we can repeat the fields from base data and set the
599    `required` and `readonly` attributes to True to further restrict
600    the data access. Or we can allow only certain certificates to be
601    selected by choosing the appropriate source.
602
603    We cannot omit fields here. This has to be done in the
604    respective form page.
605    """
606
[8979]607class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
[8584]608    """Representation of an applicant.
609
610    Skip regular reg_number validation if reg_number is used for finding
611    the applicant object.
612    """
[8979]613
[17744]614class ICustomApplicantRegisterUpdate(IApplicantRegisterUpdate):
615    """This is a representation of an applicant for first-time registration.
616    This interface is used when applicants use the registration page to
617    update their records.
618    """
619
620    email = TextLineChoice(
621        title = _(u'Email Address'),
622        required = False,
623        constraint=validate_email,
624        source = contextual_email_source,
625        )
626
Note: See TracBrowser for help on using the repository browser.