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

Last change on this file since 16689 was 16414, checked in by Henrik Bettermann, 4 years ago

TP schools during pandemic.

  • Property svn:keywords set to Id
File size: 13.6 KB
Line 
1## $Id: interfaces.py 16414 2021-03-15 09:59:38Z 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_pandemic import SCHOOLS
44from waeup.fceokene.interfaces import MessageFactory as _
45
46BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
47BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
48BEC_OMIT_MANAGE_FIELDS = ('special_application',)
49BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
50    'student_id', 'notice',
51    'screening_score',
52    'screening_venue',
53    'screening_date',
54    #'jamb_subjects',
55    #'jamb_score',
56    'aggregate')
57
58class SchoolSource(BasicSourceFactory):
59    """A source that delivers all kinds of schools.
60    """
61    def getValues(self):
62        sorted_items = sorted(
63            SCHOOLS.items(),
64            key=lambda element: element[1][0] + element[1][1] +element[1][2])
65        return [item[0] for item in sorted_items]
66
67    def getToken(self, value):
68        return value
69
70    def getTitle(self, value):
71        if not SCHOOLS.get(value, None):
72            return u"none-existent"
73        return u"%s: %s -- %s" % (
74            SCHOOLS[value][0],
75            SCHOOLS[value][1],
76            SCHOOLS[value][2],)
77
78class ITPURegistration(IKofaObject):
79    """A TPU registrant.
80    """
81
82    suspended = schema.Bool(
83        title = _(u'Account suspended'),
84        default = False,
85        required = False,
86        )
87
88    locked = schema.Bool(
89        title = _(u'Form locked'),
90        default = False,
91        required = False,
92        )
93
94    applicant_id = schema.TextLine(
95        title = _(u'Applicant Id'),
96        required = False,
97        readonly = False,
98        )
99
100    reg_number = schema.TextLine(
101        title = _(u'Registration Number'),
102        required = False,
103        readonly = False,
104        )
105
106    matric_number = schema.TextLine(
107        title = _(u'Matriculation Number'),
108        required = False,
109        readonly = False,
110        )
111
112    firstname = schema.TextLine(
113        title = _(u'First Name'),
114        required = True,
115        )
116
117    middlename = schema.TextLine(
118        title = _(u'Middle Name'),
119        required = False,
120        )
121
122    lastname = schema.TextLine(
123        title = _(u'Last Name (Surname)'),
124        required = True,
125        )
126
127    email = schema.ASCIILine(
128        title = _(u'Email Address'),
129        required = True,
130        constraint=validate_email,
131        )
132
133    phone = PhoneNumber(
134        title = _(u'Phone'),
135        description = u'',
136        required = False,
137        )
138
139    perm_address = schema.Text(
140        title = _(u'Home Address'),
141        required = False,
142        readonly = False,
143        )
144
145    lga = schema.Choice(
146        source = LGASource(),
147        title = _(u'State/LGA'),
148        required = False,
149        )
150
151    subj_comb = schema.TextLine(
152        title = _(u'Subject Combination'),
153        required = False,
154        readonly = False,
155        )
156
157    school1 = schema.Choice(
158        title = _(u'1st Choice TPZ and School'),
159        source = SchoolSource(),
160        required = False,
161        )
162
163class ICustomUGApplicant(INigeriaUGApplicant):
164    """An undergraduate applicant.
165
166    This interface defines the least common multiple of all fields
167    in ug application forms. In customized forms, fields can be excluded by
168    adding them to the OMIT* tuples.
169    """
170
171    nationality = schema.Choice(
172        source = nats_vocab,
173        title = _(u'Nationality'),
174        required = True,
175        )
176    lga = schema.Choice(
177        source = LGASource(),
178        title = _(u'State/LGA (Nigerians only)'),
179        required = False,
180        )
181    #perm_address = schema.Text(
182    #    title = _(u'Permanent Address'),
183    #    required = False,
184    #    )
185    course1 = schema.Choice(
186        title = _(u'1st Choice Course of Study'),
187        source = AppCatCertificateSource(),
188        required = False,
189        )
190    course2 = schema.Choice(
191        title = _(u'2nd Choice Course of Study'),
192        source = AppCatCertificateSource(),
193        required = False,
194        )
195    olevel_type = schema.Choice(
196        title = _(u'1st Qualification Obtained'),
197        required = False,
198        readonly = False,
199        vocabulary = exam_types,
200        )
201    olevel_school = schema.TextLine(
202        title = _(u'1st Institution Attended'),
203        required = False,
204        readonly = False,
205        )
206    olevel_exam_number = schema.TextLine(
207        title = _(u'1st Exam Number'),
208        required = False,
209        readonly = False,
210        )
211    olevel_exam_date = FormattedDate(
212        title = _(u'1st Exam Date'),
213        required = False,
214        readonly = False,
215        show_year = True,
216        )
217    olevel_results = schema.List(
218        title = _(u'1st Exam Results'),
219        value_type = ResultEntryField(),
220        required = False,
221        readonly = False,
222        defaultFactory=list,
223        )
224    olevel_type2 = schema.Choice(
225        title = _(u'2nd Qualification Obtained'),
226        required = False,
227        readonly = False,
228        vocabulary = exam_types,
229        )
230    olevel_school2 = schema.TextLine(
231        title = _(u'2nd Institution Attended'),
232        required = False,
233        readonly = False,
234        )
235    olevel_exam_number2 = schema.TextLine(
236        title = _(u'2nd Exam Number'),
237        required = False,
238        readonly = False,
239        )
240    olevel_exam_date2 = FormattedDate(
241        title = _(u'2nd Exam Date'),
242        required = False,
243        readonly = False,
244        show_year = True,
245        )
246    olevel_results2 = schema.List(
247        title = _(u'2nd Exam Results'),
248        value_type = ResultEntryField(),
249        required = False,
250        readonly = False,
251        defaultFactory=list,
252        )
253    hq_type = schema.Choice(
254        title = _(u'Qualification Obtained'),
255        required = False,
256        readonly = False,
257        vocabulary = high_qual,
258        )
259    hq_matric_no = schema.TextLine(
260        title = _(u'Former Matric Number'),
261        required = False,
262        readonly = False,
263        )
264    hq_degree = schema.Choice(
265        title = _(u'Class of Degree'),
266        required = False,
267        readonly = False,
268        vocabulary = high_grade,
269        )
270    hq_school = schema.TextLine(
271        title = _(u'Institution Attended'),
272        required = False,
273        readonly = False,
274        )
275    hq_session = schema.TextLine(
276        title = _(u'Years Attended'),
277        required = False,
278        readonly = False,
279        )
280    hq_disc = schema.TextLine(
281        title = _(u'Discipline'),
282        required = False,
283        readonly = False,
284        )
285    jamb_subjects = schema.Text(
286        title = _(u'Subjects and Scores'),
287        description = _(u'(one subject with score per line)'),
288        required = False,
289        )
290    jamb_score = schema.Int(
291        title = _(u'Total JAMB Score'),
292        required = False,
293        )
294    jamb_reg_number = schema.TextLine(
295        title = _(u'JAMB Registration Number'),
296        required = False,
297        )
298    notice = schema.Text(
299        title = _(u'Notice'),
300        required = False,
301        )
302    screening_venue = schema.TextLine(
303        title = _(u'Screening Venue'),
304        required = False,
305        )
306    screening_date = schema.TextLine(
307        title = _(u'Screening Date'),
308        required = False,
309        )
310    screening_score = schema.Int(
311        title = _(u'Screening Score (%)'),
312        required = False,
313        )
314    aggregate = schema.Int(
315        title = _(u'Aggregate Score (%)'),
316        description = _(u'(average of relative JAMB and PUTME scores)'),
317        required = False,
318        )
319    result_uploaded = schema.Bool(
320        title = _(u'Result uploaded'),
321        default = False,
322        required = False,
323        )
324    student_id = schema.TextLine(
325        title = _(u'Student Id'),
326        required = False,
327        readonly = False,
328        )
329    course_admitted = schema.Choice(
330        title = _(u'Admitted Course of Study'),
331        source = CertificateSource(),
332        required = False,
333        )
334    locked = schema.Bool(
335        title = _(u'Form locked'),
336        default = False,
337        required = False,
338        )
339
340
341class ICustomPGApplicant(INigeriaPGApplicant):
342    """A postgraduate applicant.
343
344    This interface defines the least common multiple of all fields
345    in pg application forms. In customized forms, fields can be excluded by
346    adding them to the PG_OMIT* tuples.
347    """
348
349class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
350    ITPURegistration):
351    """An interface for all types of applicants.
352
353    Attention: The ICustomPGApplicant field seetings will be overwritten
354    by ICustomPGApplicant field settings. If a field is defined
355    in both interfaces zope.schema validates only against the
356    constraints in ICustomUGApplicant. This does not affect the forms
357    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
358    """
359
360    def writeLogMessage(view, comment):
361        """Adds an INFO message to the log file
362        """
363
364    def createStudent():
365        """Create a student object from applicatnt data
366        and copy applicant object.
367        """
368
369class ICustomUGApplicantEdit(ICustomUGApplicant):
370    """An undergraduate applicant interface for edit forms.
371
372    Here we can repeat the fields from base data and set the
373    `required` and `readonly` attributes to True to further restrict
374    the data access. Or we can allow only certain certificates to be
375    selected by choosing the appropriate source.
376
377    We cannot omit fields here. This has to be done in the
378    respective form page.
379    """
380
381
382    email = schema.ASCIILine(
383        title = _(u'Email Address'),
384        required = True,
385        constraint=validate_email,
386        )
387    date_of_birth = FormattedDate(
388        title = _(u'Date of Birth'),
389        required = True,
390        show_year = True,
391        )
392    jamb_reg_number = schema.TextLine(
393        title = _(u'JAMB Registration Number'),
394        required = True,
395        )
396    course1 = schema.Choice(
397        title = _(u'1st Choice Course of Study'),
398        source = AppCatCertificateSource(),
399        required = True,
400        )
401
402ICustomUGApplicantEdit[
403    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
404ICustomUGApplicantEdit[
405    'email'].order =  ICustomUGApplicant['email'].order
406ICustomUGApplicantEdit[
407    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
408ICustomUGApplicantEdit[
409    'course1'].order =  ICustomUGApplicant['course1'].order
410
411class ICustomPGApplicantEdit(ICustomPGApplicant):
412    """A postgraduate applicant interface for editing.
413
414    Here we can repeat the fields from base data and set the
415    `required` and `readonly` attributes to True to further restrict
416    the data access. Or we can allow only certain certificates to be
417    selected by choosing the appropriate source.
418
419    We cannot omit fields here. This has to be done in the
420    respective form page.
421    """
422
423    email = schema.ASCIILine(
424        title = _(u'Email Address'),
425        required = True,
426        constraint=validate_email,
427        )
428    date_of_birth = FormattedDate(
429        title = _(u'Date of Birth'),
430        required = True,
431        show_year = True,
432        )
433
434ICustomPGApplicantEdit[
435    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
436ICustomPGApplicantEdit[
437    'email'].order =  ICustomPGApplicant['email'].order
438
439
440class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
441    """An applicant payment via payment gateways.
442
443    """
444
445class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
446    """An undergraduate applicant interface for editing.
447
448    Here we can repeat the fields from base data and set the
449    `required` and `readonly` attributes to True to further restrict
450    the data access. Or we can allow only certain certificates to be
451    selected by choosing the appropriate source.
452
453    We cannot omit fields here. This has to be done in the
454    respective form page.
455    """
456
457class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
458    """Representation of an applicant.
459
460    Skip regular reg_number validation if reg_number is used for finding
461    the applicant object.
462    """
463
Note: See TracBrowser for help on using the repository browser.