source: main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/interfaces.py @ 16281

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

Add current year.

  • Property svn:keywords set to Id
File size: 13.2 KB
RevLine 
[10765]1## $Id: interfaces.py 15602 2019-09-20 15:55:47Z 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
[15576]21from datetime import datetime
[10765]22from zope import schema
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)
[14721]29from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
[10765]30from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
[14865]31from waeup.kofa.applicants.interfaces import (
32    contextual_reg_num_source, ISpecialApplicant)
[10765]33from kofacustom.nigeria.applicants.interfaces import (
34    LGASource, high_qual, high_grade, exam_types,
[14721]35    OMIT_DISPLAY_FIELDS,
[10765]36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    )
[14716]42from kofacustom.dspg.interfaces import MessageFactory as _
43from kofacustom.dspg.payments.interfaces import ICustomOnlinePayment
[10765]44
[14721]45ND_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
46    'hq_type',
47    'hq_matric_no',
48    'hq_degree',
49    'hq_school',
50    'hq_session',
51    'hq_disc',
52    'hq_type')
53ND_OMIT_PDF_FIELDS = ND_OMIT_DISPLAY_FIELDS + ('phone',)
54ND_OMIT_MANAGE_FIELDS = ('special_application',)
55ND_OMIT_EDIT_FIELDS = ND_OMIT_MANAGE_FIELDS + ND_OMIT_DISPLAY_FIELDS + (
56    'student_id', 'notice',
57    'screening_score',
58    'screening_venue',
59    'screening_date',
60    'jamb_age',
[14831]61    #'jamb_subjects',
62    #'jamb_score',
[14721]63    'aggregate')
64
65class ICustomUGApplicant(IApplicantBaseData):
[10765]66    """An undergraduate applicant.
67
68    This interface defines the least common multiple of all fields
69    in ug application forms. In customized forms, fields can be excluded by
70    adding them to the UG_OMIT* tuples.
71    """
[14721]72    sex = schema.Choice(
73        title = _(u'Sex'),
74        source = GenderSource(),
75        required = False,
76        )
77    nationality = schema.Choice(
78        source = nats_vocab,
79        title = _(u'Nationality'),
80        required = False,
81        )
82    lga = schema.Choice(
83        source = LGASource(),
84        title = _(u'State/LGA (Nigerians only)'),
85        required = False,
86        )
87    #perm_address = schema.Text(
88    #    title = _(u'Permanent Address'),
89    #    required = False,
90    #    )
91    next_kin_address = schema.Text(
92        title = _(u'Next of Kin Address'),
93        required = False,
94        )
95    jamb_reg_number = schema.TextLine(
96        title = _(u'JAMB Registration Number'),
97        required = False,
98        )
99    course1 = schema.Choice(
100        title = _(u'1st Choice Course of Study'),
101        source = AppCatCertificateSource(),
102        required = False,
103        )
104    course2 = schema.Choice(
105        title = _(u'2nd Choice Course of Study'),
106        source = AppCatCertificateSource(),
107        required = False,
108        )
109    olevel_type = schema.Choice(
110        title = _(u'Qualification Obtained'),
111        required = False,
112        readonly = False,
113        vocabulary = exam_types,
114        )
115    olevel_school = schema.TextLine(
116        title = _(u'Institution Attended'),
117        required = False,
118        readonly = False,
119        )
120    olevel_exam_number = schema.TextLine(
121        title = _(u'Exam Number'),
122        required = False,
123        readonly = False,
124        )
125    olevel_exam_date = FormattedDate(
126        title = _(u'Exam Date'),
127        required = False,
128        readonly = False,
129        show_year = True,
130        )
131    olevel_results = schema.List(
132        title = _(u'Exam Results'),
133        value_type = ResultEntryField(),
134        required = False,
135        readonly = False,
136        defaultFactory=list,
137        )
138    olevel_pin = schema.TextLine(
139        title = _(u'Result Checking PIN'),
140        required = False,
141        readonly = False,
142        )
143    olevel_pin_serial = schema.TextLine(
144        title = _(u'PIN Serial Number'),
145        required = False,
146        readonly = False,
147        )
148    olevel_type2 = schema.Choice(
149        title = _(u'2nd Qualification Obtained'),
150        required = False,
151        readonly = False,
152        vocabulary = exam_types,
153        )
154    olevel_school2 = schema.TextLine(
155        title = _(u'2nd Institution Attended'),
156        required = False,
157        readonly = False,
158        )
159    olevel_exam_number2 = schema.TextLine(
160        title = _(u'2nd Exam Number'),
161        required = False,
162        readonly = False,
163        )
164    olevel_exam_date2 = FormattedDate(
165        title = _(u'2nd Exam Date'),
166        required = False,
167        readonly = False,
168        show_year = True,
169        )
170    olevel_results2 = schema.List(
171        title = _(u'2nd Exam Results'),
172        value_type = ResultEntryField(),
173        required = False,
174        readonly = False,
175        defaultFactory=list,
176        )
177    olevel_pin2 = schema.TextLine(
178        title = _(u'2nd Result Checking PIN'),
179        required = False,
180        readonly = False,
181        )
182    olevel_pin_serial2 = schema.TextLine(
183        title = _(u'2nd PIN Serial Number'),
184        required = False,
185        readonly = False,
186        )
187    hq_type = schema.Choice(
188        title = _(u'Qualification Obtained'),
189        required = False,
190        readonly = False,
191        vocabulary = high_qual,
192        )
193    hq_matric_no = schema.TextLine(
194        title = _(u'Former Matric Number'),
195        required = False,
196        readonly = False,
197        )
198    hq_degree = schema.Choice(
199        title = _(u'Class of Degree'),
200        required = False,
201        readonly = False,
202        vocabulary = high_grade,
203        )
204    hq_school = schema.TextLine(
205        title = _(u'Institution Attended'),
206        required = False,
207        readonly = False,
208        )
209    hq_session = schema.TextLine(
210        title = _(u'Years Attended'),
211        required = False,
212        readonly = False,
213        )
214    hq_disc = schema.TextLine(
215        title = _(u'Discipline'),
216        required = False,
217        readonly = False,
218        )
219    jamb_subjects = schema.Text(
220        title = _(u'Subjects and Scores'),
221        description = _(u'(one subject with score per line)'),
222        required = False,
223        )
224    jamb_score = schema.Int(
225        title = _(u'Total JAMB Score'),
226        required = False,
227        )
228    jamb_age = schema.Int(
229        title = _(u'Age (provided by JAMB)'),
230        required = False,
231        )
232    notice = schema.Text(
233        title = _(u'Notice'),
234        required = False,
235        )
236    screening_venue = schema.TextLine(
237        title = _(u'Screening Venue'),
238        required = False,
239        )
240    screening_date = schema.TextLine(
241        title = _(u'Screening Date'),
242        required = False,
243        )
244    screening_score = schema.Int(
245        title = _(u'Screening Score (%)'),
246        required = False,
247        )
248    aggregate = schema.Int(
249        title = _(u'Aggregate Score (%)'),
250        description = _(u'(average of relative JAMB and PUTME scores)'),
251        required = False,
252        )
253    result_uploaded = schema.Bool(
254        title = _(u'Result uploaded'),
255        default = False,
256        required = False,
257        )
258    student_id = schema.TextLine(
259        title = _(u'Student Id'),
260        required = False,
261        readonly = False,
262        )
263    course_admitted = schema.Choice(
264        title = _(u'Admitted Course of Study'),
265        source = CertificateSource(),
266        required = False,
267        )
268    locked = schema.Bool(
269        title = _(u'Form locked'),
270        default = False,
271        required = False,
272        )
[10765]273
[14721]274ICustomUGApplicant[
275    'sex'].order =  IApplicantBaseData['sex'].order
276
[10765]277class ICustomPGApplicant(INigeriaPGApplicant):
278    """A postgraduate applicant.
279
280    This interface defines the least common multiple of all fields
281    in pg application forms. In customized forms, fields can be excluded by
282    adding them to the PG_OMIT* tuples.
283    """
284
[15576]285def grad_year_range():
286    curr_year = datetime.now().year
[15602]287    return range(curr_year - 10, curr_year + 1)
[15576]288
[14865]289class ICustomSpecialApplicant(ISpecialApplicant):
290
[15592]291    certificate = schema.Choice(
292        title = _(u'Course of Study'),
293        source = CertificateSource(),
[15189]294        required = True,
[15186]295        )
296
[15576]297    grad_year = schema.Choice(
298        title = _(u'Year of Graduation'),
299        required = True,
300        values = grad_year_range(),
301        readonly = False,
302        )
303
[15592]304    carryover_courses_1 = schema.Text(
305        title = _(u'1st Semseter Carry-Over Courses'),
[15588]306        required = False,
307        )
[15592]308
309    carryover_courses_2 = schema.Text(
310        title = _(u'2nd Semester Carry-Over Courses'),
311        required = False,
312        )
313
[14865]314class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
315                       ICustomSpecialApplicant):
[10765]316    """An interface for both types of applicants.
317
318    Attention: The ICustomPGApplicant field seetings will be overwritten
319    by ICustomPGApplicant field settings. If a field is defined
320    in both interfaces zope.schema validates only against the
321    constraints in ICustomUGApplicant. This does not affect the forms
322    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
323    """
324
325    def writeLogMessage(view, comment):
326        """Adds an INFO message to the log file
327        """
328
329    def createStudent():
330        """Create a student object from applicant data
331        and copy applicant object.
332        """
333
[14721]334class ICustomUGApplicantEdit(ICustomUGApplicant):
[10765]335    """An undergraduate applicant interface for edit forms.
336
337    Here we can repeat the fields from base data and set the
338    `required` and `readonly` attributes to True to further restrict
339    the data access. Or we can allow only certain certificates to be
340    selected by choosing the appropriate source.
341
342    We cannot omit fields here. This has to be done in the
343    respective form page.
344    """
[14721]345    email = schema.ASCIILine(
346        title = _(u'Email Address'),
347        required = True,
348        constraint=validate_email,
349        )
350    phone = PhoneNumber(
351        title = _(u'Phone'),
352        description = u'',
353        required = True,
354        )
355    date_of_birth = FormattedDate(
356        title = _(u'Date of Birth'),
357        required = True,
358        show_year = True,
359        )
360    sex = schema.Choice(
361        title = _(u'Sex'),
362        source = GenderSource(),
363        required = True,
364        )
365    nationality = schema.Choice(
366        source = nats_vocab,
367        title = _(u'Nationality'),
368        required = True,
369        )
370    course1 = schema.Choice(
371        title = _(u'1st Choice Course of Study'),
372        source = AppCatCertificateSource(),
373        required = True,
374        )
375    olevel_type = schema.Choice(
376        title = _(u'Qualification Obtained'),
377        required = True,
378        readonly = False,
379        vocabulary = exam_types,
380        )
381    jamb_subjects = schema.Text(
382        title = _(u'Subjects and Scores'),
383        description = _(u'(one subject with score per line)'),
[14747]384        required = False,
[14721]385        )
386    jamb_reg_number = schema.TextLine(
387        title = _(u'JAMB Registration Number'),
[14747]388        required = False,
[14721]389        )
[10765]390
[14721]391ICustomUGApplicantEdit[
392    'nationality'].order =  ICustomUGApplicant['nationality'].order
393ICustomUGApplicantEdit[
394    'email'].order =  ICustomUGApplicant['email'].order
395ICustomUGApplicantEdit[
396    'phone'].order =  ICustomUGApplicant['phone'].order
397ICustomUGApplicantEdit[
398    'course1'].order =  ICustomUGApplicant['course1'].order
399ICustomUGApplicantEdit[
400    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
401ICustomUGApplicantEdit[
402    'sex'].order =  ICustomUGApplicant['sex'].order
403ICustomUGApplicantEdit[
404    'olevel_type'].order =  ICustomUGApplicant['olevel_type'].order
405ICustomUGApplicantEdit[
406    'jamb_subjects'].order =  ICustomUGApplicant['jamb_subjects'].order
407ICustomUGApplicantEdit[
408    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
409
[10765]410class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
411    """A postgraduate applicant interface for editing.
412
413    Here we can repeat the fields from base data and set the
414    `required` and `readonly` attributes to True to further restrict
415    the data access. Or we can allow only certain certificates to be
416    selected by choosing the appropriate source.
417
418    We cannot omit fields here. This has to be done in the
419    respective form page.
420    """
421
422class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
423    """An applicant payment via payment gateways.
424
425    """
426
427class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
428    """Representation of an applicant.
429
430    Skip regular reg_number validation if reg_number is used for finding
431    the applicant object.
[14721]432    """
Note: See TracBrowser for help on using the repository browser.