source: main/waeup.kwarapoly/branches/0.1/src/waeup/kwarapoly/applicants/interfaces.py @ 17384

Last change on this file since 17384 was 10844, checked in by Henrik Bettermann, 11 years ago

Implement special application for supplementary payments.

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