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

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

Set required field for teaching practice in CustomApplicantEditFormPage?.

  • Property svn:keywords set to Id
File size: 16.6 KB
Line 
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
21from zope import schema
22from zc.sourcefactory.basic import BasicSourceFactory
23from waeup.kofa.applicants.interfaces import (
24    IApplicantBaseData,
25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
27from waeup.kofa.interfaces import (
28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
29    IKofaObject)
30from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
31from waeup.kofa.schoolgrades import ResultEntryField
32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
33from waeup.kofa.applicants.interfaces import contextual_reg_num_source
34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    OMIT_DISPLAY_FIELDS
42    )
43from waeup.fceokene.applicants.schools_tpu import SCHOOLS_TPU
44from waeup.fceokene.applicants.schools_utp import SCHOOLS_UTP
45from waeup.fceokene.interfaces import MessageFactory as _
46
47BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
48BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
49BEC_OMIT_MANAGE_FIELDS = ('special_application',)
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
59class TPUCertificateSource(AppCatCertificateSource):
60
61    def getValues(self, context):
62        resultlist = super(TPUCertificateSource, self).getValues(context)
63        return [i for i in resultlist if i.code.startswith('NCE')]
64
65class UTPCertificateSource(AppCatCertificateSource):
66
67    def getValues(self, context):
68        resultlist = super(UTPCertificateSource, self).getValues(context)
69        return [i for i in resultlist if i.code.startswith('BED')]
70
71class TPUSchoolSource(BasicSourceFactory):
72    """A source that delivers all kinds of TPU schools.
73    """
74    def getValues(self):
75        sorted_items = sorted(
76            SCHOOLS_TPU.items(),
77            key=lambda element: element[1][0] + element[1][1] +element[1][2])
78        return [item[0] for item in sorted_items]
79
80    def getToken(self, value):
81        return value
82
83    def getTitle(self, value):
84        if not SCHOOLS_TPU.get(value, None):
85            return u"none-existent"
86        return u"%s: %s -- %s" % (
87            SCHOOLS_TPU[value][0],
88            SCHOOLS_TPU[value][1],
89            SCHOOLS_TPU[value][2],)
90
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
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
184    subj_comb = schema.Choice(
185        title = _(u'Subject Combination'),
186        source = TPUCertificateSource(),
187        required = False,
188        )
189
190    school_tpu = schema.Choice(
191        title = _(u'1st Choice TPZ and School'),
192        source = TPUSchoolSource(),
193        required = False,
194        )
195
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(),
272        required = False,
273        )
274
275    school_utp = schema.Choice(
276        title = _(u'1st Choice UTP and School'),
277        source = UTPSchoolSource(),
278        required = False,
279        )
280
281class ICustomUGApplicant(INigeriaUGApplicant):
282    """An undergraduate applicant.
283
284    This interface defines the least common multiple of all fields
285    in ug application forms. In customized forms, fields can be excluded by
286    adding them to the OMIT* tuples.
287    """
288
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(),
306        required = False,
307        )
308    course2 = schema.Choice(
309        title = _(u'2nd Choice Course of Study'),
310        source = AppCatCertificateSource(),
311        required = False,
312        )
313    olevel_type = schema.Choice(
314        title = _(u'1st Qualification Obtained'),
315        required = False,
316        readonly = False,
317        vocabulary = exam_types,
318        )
319    olevel_school = schema.TextLine(
320        title = _(u'1st Institution Attended'),
321        required = False,
322        readonly = False,
323        )
324    olevel_exam_number = schema.TextLine(
325        title = _(u'1st Exam Number'),
326        required = False,
327        readonly = False,
328        )
329    olevel_exam_date = FormattedDate(
330        title = _(u'1st Exam Date'),
331        required = False,
332        readonly = False,
333        show_year = True,
334        )
335    olevel_results = schema.List(
336        title = _(u'1st Exam Results'),
337        value_type = ResultEntryField(),
338        required = False,
339        readonly = False,
340        defaultFactory=list,
341        )
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,
369        defaultFactory=list,
370        )
371    hq_type = schema.Choice(
372        title = _(u'Qualification Obtained'),
373        required = False,
374        readonly = False,
375        vocabulary = high_qual,
376        )
377    hq_matric_no = schema.TextLine(
378        title = _(u'Former Matric Number'),
379        required = False,
380        readonly = False,
381        )
382    hq_degree = schema.Choice(
383        title = _(u'Class of Degree'),
384        required = False,
385        readonly = False,
386        vocabulary = high_grade,
387        )
388    hq_school = schema.TextLine(
389        title = _(u'Institution Attended'),
390        required = False,
391        readonly = False,
392        )
393    hq_session = schema.TextLine(
394        title = _(u'Years Attended'),
395        required = False,
396        readonly = False,
397        )
398    hq_disc = schema.TextLine(
399        title = _(u'Discipline'),
400        required = False,
401        readonly = False,
402        )
403    jamb_subjects = schema.Text(
404        title = _(u'Subjects and Scores'),
405        description = _(u'(one subject with score per line)'),
406        required = False,
407        )
408    jamb_score = schema.Int(
409        title = _(u'Total JAMB Score'),
410        required = False,
411        )
412    jamb_reg_number = schema.TextLine(
413        title = _(u'JAMB Registration Number'),
414        required = False,
415        )
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,
440        required = False,
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,
455        required = False,
456        )
457
458
459class ICustomPGApplicant(INigeriaPGApplicant):
460    """A postgraduate applicant.
461
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.
465    """
466
467class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
468    ITPURegistration, IUTPRegistration):
469    """An interface for all types of applicants.
470
471    Attention: The ICustomPGApplicant field seetings will be overwritten
472    by ICustomPGApplicant field settings. If a field is defined
473    in both interfaces zope.schema validates only against the
474    constraints in ICustomUGApplicant. This does not affect the forms
475    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
476    """
477
478    def writeLogMessage(view, comment):
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
487class ICustomUGApplicantEdit(ICustomUGApplicant):
488    """An undergraduate applicant interface for edit forms.
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
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        )
510    jamb_reg_number = schema.TextLine(
511        title = _(u'JAMB Registration Number'),
512        required = True,
513        )
514    course1 = schema.Choice(
515        title = _(u'1st Choice Course of Study'),
516        source = AppCatCertificateSource(),
517        required = True,
518        )
519
520ICustomUGApplicantEdit[
521    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
522ICustomUGApplicantEdit[
523    'email'].order =  ICustomUGApplicant['email'].order
524ICustomUGApplicantEdit[
525    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
526ICustomUGApplicantEdit[
527    'course1'].order =  ICustomUGApplicant['course1'].order
528
529class ICustomPGApplicantEdit(ICustomPGApplicant):
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.
539    """
540
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
552ICustomPGApplicantEdit[
553    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
554ICustomPGApplicantEdit[
555    'email'].order =  ICustomPGApplicant['email'].order
556
557
558class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
559    """An applicant payment via payment gateways.
560
561    """
562
563class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
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
575class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
576    """Representation of an applicant.
577
578    Skip regular reg_number validation if reg_number is used for finding
579    the applicant object.
580    """
581
Note: See TracBrowser for help on using the repository browser.