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

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

Add jamb_age to ICustomUGApplicant.

  • Property svn:keywords set to Id
File size: 10.9 KB
Line 
1## $Id: interfaces.py 11792 2014-09-09 07:24:35Z 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        default = [],
135        )
136    olevel_type2 = schema.Choice(
137        title = _(u'2nd Qualification Obtained'),
138        required = False,
139        readonly = False,
140        vocabulary = exam_types,
141        )
142    olevel_school2 = schema.TextLine(
143        title = _(u'2nd Institution Attended'),
144        required = False,
145        readonly = False,
146        )
147    olevel_exam_number2 = schema.TextLine(
148        title = _(u'2nd Exam Number'),
149        required = False,
150        readonly = False,
151        )
152    olevel_exam_date2 = FormattedDate(
153        title = _(u'2nd Exam Date'),
154        required = False,
155        readonly = False,
156        show_year = True,
157        )
158    olevel_results2 = schema.List(
159        title = _(u'2nd Exam Results'),
160        value_type = ResultEntryField(),
161        required = False,
162        readonly = False,
163        default = [],
164        )
165    hq_type = schema.Choice(
166        title = _(u'Qualification Obtained'),
167        required = False,
168        readonly = False,
169        vocabulary = high_qual,
170        )
171    hq_matric_no = schema.TextLine(
172        title = _(u'Former Matric Number'),
173        required = False,
174        readonly = False,
175        )
176    hq_degree = schema.Choice(
177        title = _(u'Class of Degree'),
178        required = False,
179        readonly = False,
180        vocabulary = high_grade,
181        )
182    hq_school = schema.TextLine(
183        title = _(u'Institution Attended'),
184        required = False,
185        readonly = False,
186        )
187    hq_session = schema.TextLine(
188        title = _(u'Years Attended'),
189        required = False,
190        readonly = False,
191        )
192    hq_disc = schema.TextLine(
193        title = _(u'Discipline'),
194        required = False,
195        readonly = False,
196        )
197    jamb_subjects = schema.Text(
198        title = _(u'Subjects and Scores'),
199        description = _(u'(one subject with score per line)'),
200        required = False,
201        )
202    jamb_score = schema.Int(
203        title = _(u'Total JAMB Score'),
204        required = False,
205        )
206    jamb_age = schema.Int(
207        title = _(u'Age (provided by JAMB)'),
208        required = False,
209        )
210    notice = schema.Text(
211        title = _(u'Notice'),
212        required = False,
213        )
214    screening_venue = schema.TextLine(
215        title = _(u'Screening Venue'),
216        required = False,
217        )
218    screening_date = schema.TextLine(
219        title = _(u'Screening Date'),
220        required = False,
221        )
222    screening_score = schema.Int(
223        title = _(u'Screening Score (%)'),
224        required = False,
225        )
226    aggregate = schema.Int(
227        title = _(u'Aggregate Score (%)'),
228        description = _(u'(average of relative JAMB and PUTME scores)'),
229        required = False,
230        )
231    result_uploaded = schema.Bool(
232        title = _(u'Result uploaded'),
233        default = False,
234        required = False,
235        )
236    student_id = schema.TextLine(
237        title = _(u'Student Id'),
238        required = False,
239        readonly = False,
240        )
241    course_admitted = schema.Choice(
242        title = _(u'Admitted Course of Study'),
243        source = CertificateSource(),
244        required = False,
245        )
246    locked = schema.Bool(
247        title = _(u'Form locked'),
248        default = False,
249        required = False,
250        )
251
252ICustomUGApplicant[
253    'sex'].order =  IApplicantBaseData['sex'].order
254
255class ICustomPGApplicant(INigeriaPGApplicant):
256    """A postgraduate applicant.
257
258    This interface defines the least common multiple of all fields
259    in pg application forms. In customized forms, fields can be excluded by
260    adding them to the PG_OMIT* tuples.
261    """
262
263class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
264    """An interface for both types of applicants.
265
266    Attention: The ICustomPGApplicant field seetings will be overwritten
267    by ICustomPGApplicant field settings. If a field is defined
268    in both interfaces zope.schema validates only against the
269    constraints in ICustomUGApplicant. This does not affect the forms
270    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
271    """
272
273    def writeLogMessage(view, comment):
274        """Adds an INFO message to the log file
275        """
276
277    def createStudent():
278        """Create a student object from applicatnt data
279        and copy applicant object.
280        """
281
282class ICustomUGApplicantEdit(ICustomUGApplicant):
283    """An undergraduate applicant interface for edit forms.
284
285    Here we can repeat the fields from base data and set the
286    `required` and `readonly` attributes to True to further restrict
287    the data access. Or we can allow only certain certificates to be
288    selected by choosing the appropriate source.
289
290    We cannot omit fields here. This has to be done in the
291    respective form page.
292    """
293    email = schema.ASCIILine(
294        title = _(u'Email Address'),
295        required = True,
296        constraint=validate_email,
297        )
298    phone = PhoneNumber(
299        title = _(u'Phone'),
300        description = u'',
301        required = True,
302        )
303    sex = schema.Choice(
304        title = _(u'Sex'),
305        source = GenderSource(),
306        required = True,
307        )
308    course1 = schema.Choice(
309        title = _(u'1st Choice Course of Study'),
310        source = AppCatCertificateSource(),
311        required = True,
312        )
313    olevel_type = schema.Choice(
314        title = _(u'Qualification Obtained'),
315        required = True,
316        readonly = False,
317        vocabulary = exam_types,
318        )
319    jamb_subjects = schema.Text(
320        title = _(u'Subjects and Scores'),
321        description = _(u'(one subject with score per line)'),
322        required = True,
323        )
324
325ICustomUGApplicantEdit[
326    'email'].order =  ICustomUGApplicant['email'].order
327ICustomUGApplicantEdit[
328    'phone'].order =  ICustomUGApplicant['phone'].order
329ICustomUGApplicantEdit[
330    'course1'].order =  ICustomUGApplicant['course1'].order
331ICustomUGApplicantEdit[
332    'sex'].order =  ICustomUGApplicant['sex'].order
333ICustomUGApplicantEdit[
334    'olevel_type'].order =  ICustomUGApplicant['olevel_type'].order
335ICustomUGApplicantEdit[
336    'jamb_subjects'].order =  ICustomUGApplicant['jamb_subjects'].order
337
338class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
339    """A postgraduate applicant interface for editing.
340
341    Here we can repeat the fields from base data and set the
342    `required` and `readonly` attributes to True to further restrict
343    the data access. Or we can allow only certain certificates to be
344    selected by choosing the appropriate source.
345
346    We cannot omit fields here. This has to be done in the
347    respective form page.
348    """
349
350class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
351    """An applicant payment via payment gateways.
352
353    """
354
Note: See TracBrowser for help on using the repository browser.