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

Last change on this file since 15848 was 15635, checked in by Henrik Bettermann, 5 years ago

If applicants haven't saved the form before submission (which is allowed), the attribute was not set and wasn't counted. This use case was not covered by the test.

  • Property svn:keywords set to Id
File size: 13.6 KB
RevLine 
[7853]1## $Id: interfaces.py 15635 2019-10-03 20:47:58Z 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    )
[13877]43from waeup.fceokene.applicants.schools import SCHOOLS
[8460]44from waeup.fceokene.interfaces import MessageFactory as _
[7853]45
[9463]46BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
47BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
[10852]48BEC_OMIT_MANAGE_FIELDS = ('special_application',)
[9463]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
[13877]58class SchoolSource(BasicSourceFactory):
[14499]59    """A source that delivers all kinds of schools.
[13877]60    """
61    def getValues(self):
[14067]62        sorted_items = sorted(
63            SCHOOLS.items(),
64            key=lambda element: element[1][0] + element[1][1] +element[1][2])
[13877]65        return [item[0] for item in sorted_items]
66
[14499]67    def getToken(self, value):
68        return value
69
[13877]70    def getTitle(self, value):
[15594]71        if not SCHOOLS.get(value, None):
72            return u"none-existent"
[13877]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(),
[15111]160        required = False,
[13877]161        )
162
[8933]163class ICustomUGApplicant(INigeriaUGApplicant):
[8012]164    """An undergraduate applicant.
165
[8520]166    This interface defines the least common multiple of all fields
167    in ug application forms. In customized forms, fields can be excluded by
[9463]168    adding them to the OMIT* tuples.
[8012]169    """
170
[9465]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(),
[13884]188        required = False,
[9465]189        )
190    course2 = schema.Choice(
191        title = _(u'2nd Choice Course of Study'),
192        source = AppCatCertificateSource(),
193        required = False,
194        )
[9463]195    olevel_type = schema.Choice(
[9500]196        title = _(u'1st Qualification Obtained'),
[9463]197        required = False,
198        readonly = False,
[9465]199        vocabulary = exam_types,
200        )
201    olevel_school = schema.TextLine(
[9500]202        title = _(u'1st Institution Attended'),
[9465]203        required = False,
204        readonly = False,
205        )
206    olevel_exam_number = schema.TextLine(
[9500]207        title = _(u'1st Exam Number'),
[9465]208        required = False,
209        readonly = False,
210        )
211    olevel_exam_date = FormattedDate(
[9500]212        title = _(u'1st Exam Date'),
[9465]213        required = False,
214        readonly = False,
215        show_year = True,
216        )
217    olevel_results = schema.List(
[9500]218        title = _(u'1st Exam Results'),
[9465]219        value_type = ResultEntryField(),
220        required = False,
221        readonly = False,
[14018]222        defaultFactory=list,
[9465]223        )
[9500]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,
[14018]251        defaultFactory=list,
[9500]252        )
[9465]253    hq_type = schema.Choice(
254        title = _(u'Qualification Obtained'),
255        required = False,
256        readonly = False,
[9463]257        vocabulary = high_qual,
258        )
[9465]259    hq_matric_no = schema.TextLine(
[9463]260        title = _(u'Former Matric Number'),
261        required = False,
262        readonly = False,
263        )
[9465]264    hq_degree = schema.Choice(
[9463]265        title = _(u'Class of Degree'),
266        required = False,
267        readonly = False,
268        vocabulary = high_grade,
269        )
[9465]270    hq_school = schema.TextLine(
[9463]271        title = _(u'Institution Attended'),
272        required = False,
273        readonly = False,
274        )
[9465]275    hq_session = schema.TextLine(
[9463]276        title = _(u'Years Attended'),
277        required = False,
278        readonly = False,
279        )
[9465]280    hq_disc = schema.TextLine(
[9463]281        title = _(u'Discipline'),
282        required = False,
283        readonly = False,
284        )
[9465]285    jamb_subjects = schema.Text(
286        title = _(u'Subjects and Scores'),
[10533]287        description = _(u'(one subject with score per line)'),
[9465]288        required = False,
289        )
290    jamb_score = schema.Int(
291        title = _(u'Total JAMB Score'),
292        required = False,
293        )
[10500]294    jamb_reg_number = schema.TextLine(
295        title = _(u'JAMB Registration Number'),
296        required = False,
297        )
[9465]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,
[14335]322        required = False,
[9465]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,
[14335]337        required = False,
[9465]338        )
[9463]339
340
[8933]341class ICustomPGApplicant(INigeriaPGApplicant):
[7853]342    """A postgraduate applicant.
343
[8520]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.
[7866]347    """
348
[13877]349class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
350    ITPURegistration):
351    """An interface for all types of applicants.
[8012]352
[8933]353    Attention: The ICustomPGApplicant field seetings will be overwritten
354    by ICustomPGApplicant field settings. If a field is defined
[8729]355    in both interfaces zope.schema validates only against the
[8933]356    constraints in ICustomUGApplicant. This does not affect the forms
357    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]358    """
359
[8745]360    def writeLogMessage(view, comment):
[8053]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
[9497]369class ICustomUGApplicantEdit(ICustomUGApplicant):
[8729]370    """An undergraduate applicant interface for edit forms.
[8012]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
[9497]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        )
[11776]392    jamb_reg_number = schema.TextLine(
393        title = _(u'JAMB Registration Number'),
394        required = True,
395        )
[13884]396    course1 = schema.Choice(
397        title = _(u'1st Choice Course of Study'),
398        source = AppCatCertificateSource(),
399        required = True,
400        )
[9497]401
[10500]402ICustomUGApplicantEdit[
403    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
404ICustomUGApplicantEdit[
405    'email'].order =  ICustomUGApplicant['email'].order
406ICustomUGApplicantEdit[
[13238]407    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
[13884]408ICustomUGApplicantEdit[
409    'course1'].order =  ICustomUGApplicant['course1'].order
[10500]410
[9497]411class ICustomPGApplicantEdit(ICustomPGApplicant):
[7866]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.
[8017]421    """
[8454]422
[9497]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
[10500]434ICustomPGApplicantEdit[
435    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
436ICustomPGApplicantEdit[
437    'email'].order =  ICustomPGApplicant['email'].order
438
439
[8933]440class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]441    """An applicant payment via payment gateways.
442
443    """
[8531]444
[8979]445class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
[8531]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
[8979]457class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
[8584]458    """Representation of an applicant.
459
460    Skip regular reg_number validation if reg_number is used for finding
461    the applicant object.
462    """
[8979]463
Note: See TracBrowser for help on using the repository browser.