source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py @ 12647

Last change on this file since 12647 was 11776, checked in by Henrik Bettermann, 10 years ago

Make jamb_reg_number a requird field.

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