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

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

Add student_id field.

  • Property svn:keywords set to Id
File size: 14.1 KB
Line 
1## $Id: interfaces.py 16728 2021-12-01 13:12:34Z 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    student_id = schema.TextLine(
293        title = _(u'Student Id'),
294        required = True,
295        )
296
297    certificate = schema.Choice(
298        title = _(u'Course of Study'),
299        source = CertificateSource(),
300        required = True,
301        )
302
303    grad_year = schema.Choice(
304        title = _(u'Year of Graduation'),
305        required = True,
306        values = grad_year_range(),
307        readonly = False,
308        )
309
310    carryover_courses_1 = schema.List(
311        title = _(u'1st Semester Carry-Over Courses'),
312        value_type = schema.Choice(
313            #title = _(u'YYY'),
314            source = CourseSource(),
315            required = True,
316            ),
317        required = False,
318        readonly = False,
319        defaultFactory=list,
320        )
321
322    carryover_courses_2 = schema.List(
323        title = _(u'2nd Semester Carry-Over Courses'),
324        value_type = schema.Choice(
325            #title = _(u'YYY'),
326            source = CourseSource(),
327            required = True,
328            ),
329        required = False,
330        readonly = False,
331        defaultFactory=list,
332        )
333
334    #carryover_courses_1 = schema.Text(
335    #    title = _(u'1st Semseter Carry-Over Courses'),
336    #    required = False,
337    #    )
338
339    #carryover_courses_2 = schema.Text(
340    #    title = _(u'2nd Semester Carry-Over Courses'),
341    #    required = False,
342    #    )
343
344ICustomSpecialApplicant[
345    'student_id'].order =  ISpecialApplicant['reg_number'].order
346
347class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
348                       ICustomSpecialApplicant):
349    """An interface for both types of applicants.
350
351    Attention: The ICustomPGApplicant field seetings will be overwritten
352    by ICustomPGApplicant field settings. If a field is defined
353    in both interfaces zope.schema validates only against the
354    constraints in ICustomUGApplicant. This does not affect the forms
355    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
356    """
357
358    def writeLogMessage(view, comment):
359        """Adds an INFO message to the log file
360        """
361
362    def createStudent():
363        """Create a student object from applicant data
364        and copy applicant object.
365        """
366
367class ICustomUGApplicantEdit(ICustomUGApplicant):
368    """An undergraduate applicant interface for edit forms.
369
370    Here we can repeat the fields from base data and set the
371    `required` and `readonly` attributes to True to further restrict
372    the data access. Or we can allow only certain certificates to be
373    selected by choosing the appropriate source.
374
375    We cannot omit fields here. This has to be done in the
376    respective form page.
377    """
378    email = schema.ASCIILine(
379        title = _(u'Email Address'),
380        required = True,
381        constraint=validate_email,
382        )
383    phone = PhoneNumber(
384        title = _(u'Phone'),
385        description = u'',
386        required = True,
387        )
388    date_of_birth = FormattedDate(
389        title = _(u'Date of Birth'),
390        required = True,
391        show_year = True,
392        )
393    sex = schema.Choice(
394        title = _(u'Sex'),
395        source = GenderSource(),
396        required = True,
397        )
398    nationality = schema.Choice(
399        source = nats_vocab,
400        title = _(u'Nationality'),
401        required = True,
402        )
403    course1 = schema.Choice(
404        title = _(u'1st Choice Course of Study'),
405        source = AppCatCertificateSource(),
406        required = True,
407        )
408    olevel_type = schema.Choice(
409        title = _(u'Qualification Obtained'),
410        required = True,
411        readonly = False,
412        vocabulary = exam_types,
413        )
414    jamb_subjects = schema.Text(
415        title = _(u'Subjects and Scores'),
416        description = _(u'(one subject with score per line)'),
417        required = False,
418        )
419    jamb_reg_number = schema.TextLine(
420        title = _(u'JAMB Registration Number'),
421        required = False,
422        )
423
424ICustomUGApplicantEdit[
425    'nationality'].order =  ICustomUGApplicant['nationality'].order
426ICustomUGApplicantEdit[
427    'email'].order =  ICustomUGApplicant['email'].order
428ICustomUGApplicantEdit[
429    'phone'].order =  ICustomUGApplicant['phone'].order
430ICustomUGApplicantEdit[
431    'course1'].order =  ICustomUGApplicant['course1'].order
432ICustomUGApplicantEdit[
433    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
434ICustomUGApplicantEdit[
435    'sex'].order =  ICustomUGApplicant['sex'].order
436ICustomUGApplicantEdit[
437    'olevel_type'].order =  ICustomUGApplicant['olevel_type'].order
438ICustomUGApplicantEdit[
439    'jamb_subjects'].order =  ICustomUGApplicant['jamb_subjects'].order
440ICustomUGApplicantEdit[
441    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
442
443class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
444    """A postgraduate applicant interface for editing.
445
446    Here we can repeat the fields from base data and set the
447    `required` and `readonly` attributes to True to further restrict
448    the data access. Or we can allow only certain certificates to be
449    selected by choosing the appropriate source.
450
451    We cannot omit fields here. This has to be done in the
452    respective form page.
453    """
454
455class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
456    """An applicant payment via payment gateways.
457
458    """
459
460class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
461    """Representation of an applicant.
462
463    Skip regular reg_number validation if reg_number is used for finding
464    the applicant object.
465    """
Note: See TracBrowser for help on using the repository browser.