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

Last change on this file since 16726 was 16726, checked in by Henrik Bettermann, 3 years ago

Change carryover_courses_1 and carryover_courses_2 fields.

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