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

Last change on this file since 17367 was 17359, checked in by Henrik Bettermann, 20 months ago

Set required field for teaching practice in CustomApplicantEditFormPage?.

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