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

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

Enable application slip for special applications.

  • Property svn:keywords set to Id
File size: 13.2 KB
Line 
1## $Id: interfaces.py 15588 2019-09-17 18:27:50Z 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 datetime import datetime
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)
29from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
30from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
31from waeup.kofa.applicants.interfaces import (
32    contextual_reg_num_source, ISpecialApplicant)
33from kofacustom.nigeria.applicants.interfaces import (
34    LGASource, high_qual, high_grade, exam_types,
35    OMIT_DISPLAY_FIELDS,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    )
42from kofacustom.dspg.interfaces import MessageFactory as _
43from kofacustom.dspg.payments.interfaces import ICustomOnlinePayment
44
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',
61    #'jamb_subjects',
62    #'jamb_score',
63    'aggregate')
64
65class ICustomUGApplicant(IApplicantBaseData):
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    """
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        )
273
274ICustomUGApplicant[
275    'sex'].order =  IApplicantBaseData['sex'].order
276
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
285def grad_year_range():
286    curr_year = datetime.now().year
287    return range(curr_year - 10, curr_year + 0)
288
289class ICustomSpecialApplicant(ISpecialApplicant):
290
291    department = schema.TextLine(
292        title = _(u'Department'),
293        required = True,
294        readonly = False,
295        )
296
297    grad_year = schema.Choice(
298        title = _(u'Year of Graduation'),
299        required = True,
300        values = grad_year_range(),
301        readonly = False,
302        )
303
304    carryover_courses = schema.Text(
305        title = _(u'Carry-Over Courses'),
306        required = False,
307        #description = _(
308        #    u'Enter course titles if carry-over remedial payment.'),
309        )
310class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
311                       ICustomSpecialApplicant):
312    """An interface for both types of applicants.
313
314    Attention: The ICustomPGApplicant field seetings will be overwritten
315    by ICustomPGApplicant field settings. If a field is defined
316    in both interfaces zope.schema validates only against the
317    constraints in ICustomUGApplicant. This does not affect the forms
318    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
319    """
320
321    def writeLogMessage(view, comment):
322        """Adds an INFO message to the log file
323        """
324
325    def createStudent():
326        """Create a student object from applicant data
327        and copy applicant object.
328        """
329
330class ICustomUGApplicantEdit(ICustomUGApplicant):
331    """An undergraduate applicant interface for edit forms.
332
333    Here we can repeat the fields from base data and set the
334    `required` and `readonly` attributes to True to further restrict
335    the data access. Or we can allow only certain certificates to be
336    selected by choosing the appropriate source.
337
338    We cannot omit fields here. This has to be done in the
339    respective form page.
340    """
341    email = schema.ASCIILine(
342        title = _(u'Email Address'),
343        required = True,
344        constraint=validate_email,
345        )
346    phone = PhoneNumber(
347        title = _(u'Phone'),
348        description = u'',
349        required = True,
350        )
351    date_of_birth = FormattedDate(
352        title = _(u'Date of Birth'),
353        required = True,
354        show_year = True,
355        )
356    sex = schema.Choice(
357        title = _(u'Sex'),
358        source = GenderSource(),
359        required = True,
360        )
361    nationality = schema.Choice(
362        source = nats_vocab,
363        title = _(u'Nationality'),
364        required = True,
365        )
366    course1 = schema.Choice(
367        title = _(u'1st Choice Course of Study'),
368        source = AppCatCertificateSource(),
369        required = True,
370        )
371    olevel_type = schema.Choice(
372        title = _(u'Qualification Obtained'),
373        required = True,
374        readonly = False,
375        vocabulary = exam_types,
376        )
377    jamb_subjects = schema.Text(
378        title = _(u'Subjects and Scores'),
379        description = _(u'(one subject with score per line)'),
380        required = False,
381        )
382    jamb_reg_number = schema.TextLine(
383        title = _(u'JAMB Registration Number'),
384        required = False,
385        )
386
387ICustomUGApplicantEdit[
388    'nationality'].order =  ICustomUGApplicant['nationality'].order
389ICustomUGApplicantEdit[
390    'email'].order =  ICustomUGApplicant['email'].order
391ICustomUGApplicantEdit[
392    'phone'].order =  ICustomUGApplicant['phone'].order
393ICustomUGApplicantEdit[
394    'course1'].order =  ICustomUGApplicant['course1'].order
395ICustomUGApplicantEdit[
396    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
397ICustomUGApplicantEdit[
398    'sex'].order =  ICustomUGApplicant['sex'].order
399ICustomUGApplicantEdit[
400    'olevel_type'].order =  ICustomUGApplicant['olevel_type'].order
401ICustomUGApplicantEdit[
402    'jamb_subjects'].order =  ICustomUGApplicant['jamb_subjects'].order
403ICustomUGApplicantEdit[
404    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
405
406class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
407    """A postgraduate applicant interface for editing.
408
409    Here we can repeat the fields from base data and set the
410    `required` and `readonly` attributes to True to further restrict
411    the data access. Or we can allow only certain certificates to be
412    selected by choosing the appropriate source.
413
414    We cannot omit fields here. This has to be done in the
415    respective form page.
416    """
417
418class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
419    """An applicant payment via payment gateways.
420
421    """
422
423class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
424    """Representation of an applicant.
425
426    Skip regular reg_number validation if reg_number is used for finding
427    the applicant object.
428    """
Note: See TracBrowser for help on using the repository browser.