source: main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/interfaces.py @ 15362

Last change on this file since 15362 was 14019, checked in by Henrik Bettermann, 8 years ago

Use defaultFactory.

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