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

Last change on this file since 15073 was 14865, checked in by Henrik Bettermann, 7 years ago

Customize ISpecialApplicant.

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