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

Last change on this file since 15186 was 15186, checked in by Henrik Bettermann, 6 years ago

Add two fields to ICustomSpecialApplicant and export these fields too.

  • Property svn:keywords set to Id
File size: 13.0 KB
Line 
1## $Id: interfaces.py 15186 2018-10-14 16:48: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 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
293    matric_number = schema.TextLine(
294        title = _(u'Matric Number'),
295        required = False,
296        readonly = False,
297        )
298
299    department = schema.TextLine(
300        title = _(u'Department'),
301        required = False,
302        readonly = False,
303        )
304
305class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
306                       ICustomSpecialApplicant):
307    """An interface for both types of applicants.
308
309    Attention: The ICustomPGApplicant field seetings will be overwritten
310    by ICustomPGApplicant field settings. If a field is defined
311    in both interfaces zope.schema validates only against the
312    constraints in ICustomUGApplicant. This does not affect the forms
313    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
314    """
315
316    def writeLogMessage(view, comment):
317        """Adds an INFO message to the log file
318        """
319
320    def createStudent():
321        """Create a student object from applicant data
322        and copy applicant object.
323        """
324
325class ICustomUGApplicantEdit(ICustomUGApplicant):
326    """An undergraduate applicant interface for edit forms.
327
328    Here we can repeat the fields from base data and set the
329    `required` and `readonly` attributes to True to further restrict
330    the data access. Or we can allow only certain certificates to be
331    selected by choosing the appropriate source.
332
333    We cannot omit fields here. This has to be done in the
334    respective form page.
335    """
336    email = schema.ASCIILine(
337        title = _(u'Email Address'),
338        required = True,
339        constraint=validate_email,
340        )
341    phone = PhoneNumber(
342        title = _(u'Phone'),
343        description = u'',
344        required = True,
345        )
346    date_of_birth = FormattedDate(
347        title = _(u'Date of Birth'),
348        required = True,
349        show_year = True,
350        )
351    sex = schema.Choice(
352        title = _(u'Sex'),
353        source = GenderSource(),
354        required = True,
355        )
356    nationality = schema.Choice(
357        source = nats_vocab,
358        title = _(u'Nationality'),
359        required = True,
360        )
361    course1 = schema.Choice(
362        title = _(u'1st Choice Course of Study'),
363        source = AppCatCertificateSource(),
364        required = True,
365        )
366    olevel_type = schema.Choice(
367        title = _(u'Qualification Obtained'),
368        required = True,
369        readonly = False,
370        vocabulary = exam_types,
371        )
372    jamb_subjects = schema.Text(
373        title = _(u'Subjects and Scores'),
374        description = _(u'(one subject with score per line)'),
375        required = False,
376        )
377    jamb_reg_number = schema.TextLine(
378        title = _(u'JAMB Registration Number'),
379        required = False,
380        )
381
382ICustomUGApplicantEdit[
383    'nationality'].order =  ICustomUGApplicant['nationality'].order
384ICustomUGApplicantEdit[
385    'email'].order =  ICustomUGApplicant['email'].order
386ICustomUGApplicantEdit[
387    'phone'].order =  ICustomUGApplicant['phone'].order
388ICustomUGApplicantEdit[
389    'course1'].order =  ICustomUGApplicant['course1'].order
390ICustomUGApplicantEdit[
391    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
392ICustomUGApplicantEdit[
393    'sex'].order =  ICustomUGApplicant['sex'].order
394ICustomUGApplicantEdit[
395    'olevel_type'].order =  ICustomUGApplicant['olevel_type'].order
396ICustomUGApplicantEdit[
397    'jamb_subjects'].order =  ICustomUGApplicant['jamb_subjects'].order
398ICustomUGApplicantEdit[
399    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
400
401class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
402    """A postgraduate applicant interface for editing.
403
404    Here we can repeat the fields from base data and set the
405    `required` and `readonly` attributes to True to further restrict
406    the data access. Or we can allow only certain certificates to be
407    selected by choosing the appropriate source.
408
409    We cannot omit fields here. This has to be done in the
410    respective form page.
411    """
412
413class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
414    """An applicant payment via payment gateways.
415
416    """
417
418class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
419    """Representation of an applicant.
420
421    Skip regular reg_number validation if reg_number is used for finding
422    the applicant object.
423    """
Note: See TracBrowser for help on using the repository browser.