source: main/waeup.uniben/trunk/src/waeup/uniben/applicants/interfaces.py @ 8955

Last change on this file since 8955 was 8928, checked in by Henrik Bettermann, 12 years ago

Start using components and interfaces in kofacustom.nigeria. Unfortunately, this does not reduce the code in waeup.uniben very much, only because we are still using an old LGAs dictionary.

Move applicants tests into 'tests' package.

  • Property svn:keywords set to Id
File size: 13.0 KB
Line 
1## $Id: interfaces.py 8928 2012-07-07 09:25:03Z 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.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    INigeriaUGApplicant, INigeriaPGApplicant,
34    INigeriaApplicantOnlinePayment,
35    UG_OMIT_DISPLAY_FIELDS,
36    UG_OMIT_PDF_FIELDS,
37    UG_OMIT_MANAGE_FIELDS,
38    UG_OMIT_EDIT_FIELDS,
39    PUTME_OMIT_EDIT_FIELDS,
40    UG_OMIT_RESULT_SLIP_FIELDS,
41    PG_OMIT_DISPLAY_FIELDS,
42    PG_OMIT_PDF_FIELDS,
43    PG_OMIT_MANAGE_FIELDS,
44    PG_OMIT_EDIT_FIELDS,
45    )
46from waeup.uniben.interfaces import MessageFactory as _
47from waeup.uniben.payments.interfaces import ICustomOnlinePayment
48
49############################################################
50# Use former lgas for Uniben. Must be removed after application.
51from waeup.uniben.applicants.lgas import LGAS
52class LGASource(LGASource):
53    """A source for school subjects used in exam documentation.
54    """
55    lga_dict = dict(LGAS)
56############################################################
57
58class ICustomUGApplicant(INigeriaUGApplicant):
59    """An undergraduate applicant.
60
61    This interface defines the least common multiple of all fields
62    in ug application forms. In customized forms, fields can be excluded by
63    adding them to the UG_OMIT* tuples.
64    """
65
66    nationality = schema.Choice(
67        source = nats_vocab,
68        title = _(u'Nationality'),
69        required = False,
70        )
71    lga = schema.Choice(
72        source = LGASource(),
73        title = _(u'State/LGA (Nigerians only)'),
74        required = False,
75        )
76    perm_address = schema.Text(
77        title = _(u'Permanent Address'),
78        required = False,
79        )
80    course1 = schema.Choice(
81        title = _(u'1st Choice Course of Study'),
82        source = AppCatCertificateSource(),
83        required = True,
84        )
85    course2 = schema.Choice(
86        title = _(u'2nd Choice Course of Study'),
87        source = AppCatCertificateSource(),
88        required = False,
89        )
90    jamb_subjects = schema.Text(
91        title = _(u'Subjects and Scores'),
92        required = False,
93        )
94    jamb_score = schema.Int(
95        title = _(u'Total Score'),
96        required = False,
97        )
98    notice = schema.Text(
99        title = _(u'Notice'),
100        required = False,
101        )
102    screening_venue = schema.TextLine(
103        title = _(u'Screening Venue'),
104        required = False,
105        )
106    screening_date = schema.TextLine(
107        title = _(u'Screening Date'),
108        required = False,
109        )
110    screening_score = schema.Int(
111        title = _(u'Screening Score (%)'),
112        required = False,
113        )
114    aggregate = schema.Int(
115        title = _(u'Aggregate Score (%)'),
116        description = _(u'(average of relative JAMB and PUTME scores)'),
117        required = False,
118        )
119    result_uploaded = schema.Bool(
120        title = _(u'Result uploaded'),
121        default = False,
122        )
123    student_id = schema.TextLine(
124        title = _(u'Student Id'),
125        required = False,
126        readonly = False,
127        )
128    course_admitted = schema.Choice(
129        title = _(u'Admitted Course of Study'),
130        source = CertificateSource(),
131        required = False,
132        )
133    locked = schema.Bool(
134        title = _(u'Form locked'),
135        default = False,
136        )
137
138class ICustomPGApplicant(INigeriaPGApplicant):
139    """A postgraduate applicant.
140
141    This interface defines the least common multiple of all fields
142    in pg application forms. In customized forms, fields can be excluded by
143    adding them to the PG_OMIT* tuples.
144    """
145
146    nationality = schema.Choice(
147        source = nats_vocab,
148        title = _(u'Nationality'),
149        required = False,
150        )
151    lga = schema.Choice(
152        source = LGASource(),
153        title = _(u'State/LGA (Nigerians only)'),
154        required = False,
155        )
156    perm_address = schema.Text(
157        title = _(u'Permanent Address'),
158        required = False,
159        )
160    course1 = schema.Choice(
161        title = _(u'1st Choice Course of Study'),
162        source = AppCatCertificateSource(),
163        required = True,
164        )
165    course2 = schema.Choice(
166        title = _(u'2nd Choice Course of Study'),
167        source = AppCatCertificateSource(),
168        required = False,
169        )
170    hq_type = schema.Choice(
171        title = _(u'Qualification Obtained'),
172        required = False,
173        readonly = False,
174        vocabulary = high_qual,
175        )
176    hq_matric_no = schema.TextLine(
177        title = _(u'Former Matric Number'),
178        required = False,
179        readonly = False,
180        )
181    hq_degree = schema.Choice(
182        title = _(u'Class of Degree'),
183        required = False,
184        readonly = False,
185        vocabulary = high_grade,
186        )
187    hq_school = schema.TextLine(
188        title = _(u'Institution Attended'),
189        required = False,
190        readonly = False,
191        )
192    hq_session = schema.TextLine(
193        title = _(u'Years Attended'),
194        required = False,
195        readonly = False,
196        )
197    hq_disc = schema.TextLine(
198        title = _(u'Discipline'),
199        required = False,
200        readonly = False,
201        )
202    pp_school = schema.Choice(
203        title = _(u'Qualification Obtained'),
204        required = False,
205        readonly = False,
206        vocabulary = exam_types,
207        )
208    #presently = schema.Bool(
209    #    title = _(u'Attending'),
210    #    required = False,
211    #    readonly = False,
212    #    )
213    presently_inst = schema.TextLine(
214        title = _(u'If yes, name of institution'),
215        required = False,
216        readonly = False,
217        )
218    nysc_year = schema.Int(
219        title = _(u'Nysc Year'),
220        required = False,
221        readonly = False,
222        )
223    nysc_lga = schema.Choice(
224        source = LGASource(),
225        title = _(u'Nysc Location'),
226        required = False,
227        )
228    employer = schema.TextLine(
229        title = _(u'Employer'),
230        required = False,
231        readonly = False,
232        )
233    emp_position = schema.TextLine(
234        title = _(u'Employer Position'),
235        required = False,
236        readonly = False,
237        )
238    emp_start = FormattedDate(
239        title = _(u'Start Date'),
240        required = False,
241        readonly = False,
242        show_year = True,
243        )
244    emp_end = FormattedDate(
245        title = _(u'End Date'),
246        required = False,
247        readonly = False,
248        show_year = True,
249        )
250    emp_reason = schema.TextLine(
251        title = _(u'Reason for Leaving'),
252        required = False,
253        readonly = False,
254        )
255    employer2 = schema.TextLine(
256        title = _(u'2nd Employer'),
257        required = False,
258        readonly = False,
259        )
260    emp2_position = schema.TextLine(
261        title = _(u'2nd Employer Position'),
262        required = False,
263        readonly = False,
264        )
265    emp2_start = FormattedDate(
266        title = _(u'Start Date'),
267        required = False,
268        readonly = False,
269        show_year = True,
270        )
271    emp2_end = FormattedDate(
272        title = _(u'End Date'),
273        required = False,
274        readonly = False,
275        show_year = True,
276        )
277    emp2_reason = schema.TextLine(
278        title = _(u'Reason for Leaving'),
279        required = False,
280        readonly = False,
281        )
282    notice = schema.Text(
283        title = _(u'Notice'),
284        required = False,
285        readonly = False,
286        )
287    screening_venue = schema.TextLine(
288        title = _(u'Screening Venue'),
289        required = False,
290        readonly = False,
291        )
292    screening_date = schema.TextLine(
293        title = _(u'Screening Date'),
294        required = False,
295        )
296    screening_score = schema.Int(
297        title = _(u'Screening Score'),
298        required = False,
299        readonly = False,
300        )
301    student_id = schema.TextLine(
302        title = _(u'Student Id'),
303        required = False,
304        readonly = False,
305        )
306    course_admitted = schema.Choice(
307        title = _(u'Admitted Course of Study'),
308        source = CertificateSource(),
309        required = False,
310        readonly = False,
311        )
312    locked = schema.Bool(
313        title = _(u'Form locked'),
314        default = False,
315        )
316
317class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
318    """An interface for both types of applicants.
319
320    Attention: The ICustomPGApplicant field seetings will be overwritten
321    by ICustomPGApplicant field settings. If a field is defined
322    in both interfaces zope.schema validates only against the
323    constraints in ICustomUGApplicant. This does not affect the forms
324    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
325    """
326
327    def writeLogMessage(view, comment):
328        """Adds an INFO message to the log file
329        """
330
331    def createStudent():
332        """Create a student object from applicant data
333        and copy applicant object.
334        """
335
336class ICustomUGApplicantEdit(ICustomUGApplicant):
337    """An undergraduate applicant interface for edit forms.
338
339    Here we can repeat the fields from base data and set the
340    `required` and `readonly` attributes to True to further restrict
341    the data access. Or we can allow only certain certificates to be
342    selected by choosing the appropriate source.
343
344    We cannot omit fields here. This has to be done in the
345    respective form page.
346    """
347
348    email = schema.ASCIILine(
349        title = _(u'Email Address'),
350        required = True,
351        constraint=validate_email,
352        )
353    date_of_birth = FormattedDate(
354        title = _(u'Date of Birth'),
355        required = True,
356        show_year = True,
357        )
358
359ICustomUGApplicantEdit[
360    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
361ICustomUGApplicantEdit[
362    'email'].order =  ICustomUGApplicant['email'].order
363
364class ICustomPGApplicantEdit(ICustomPGApplicant):
365    """A postgraduate applicant interface for editing.
366
367    Here we can repeat the fields from base data and set the
368    `required` and `readonly` attributes to True to further restrict
369    the data access. Or we can allow only certain certificates to be
370    selected by choosing the appropriate source.
371
372    We cannot omit fields here. This has to be done in the
373    respective form page.
374    """
375
376    email = schema.ASCIILine(
377        title = _(u'Email Address'),
378        required = True,
379        constraint=validate_email,
380        )
381    date_of_birth = FormattedDate(
382        title = _(u'Date of Birth'),
383        required = True,
384        show_year = True,
385        )
386
387ICustomPGApplicantEdit[
388    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
389ICustomPGApplicantEdit[
390    'email'].order =  ICustomPGApplicant['email'].order
391
392class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
393    """An applicant payment via payment gateways.
394
395    """
396
397class IPUTMEApplicantEdit(ICustomUGApplicant):
398    """An undergraduate applicant interface for editing.
399
400    Here we can repeat the fields from base data and set the
401    `required` and `readonly` attributes to True to further restrict
402    the data access. Or we can allow only certain certificates to be
403    selected by choosing the appropriate source.
404
405    We cannot omit fields here. This has to be done in the
406    respective form page.
407    """
408    email = schema.ASCIILine(
409        title = _(u'Email Address'),
410        required = True,
411        constraint=validate_email,
412        )
413    date_of_birth = FormattedDate(
414        title = _(u'Date of Birth'),
415        required = True,
416        show_year = True,
417        )
418
419IPUTMEApplicantEdit[
420    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
421IPUTMEApplicantEdit[
422    'email'].order =  ICustomUGApplicant['email'].order
423
424class ICustomApplicantUpdateByRegNo(ICustomApplicant):
425    """Representation of an applicant.
426
427    Skip regular reg_number validation if reg_number is used for finding
428    the applicant object.
429    """
430    reg_number = schema.TextLine(
431        title = u'Registration Number',
432        required = False,
433        )
Note: See TracBrowser for help on using the repository browser.