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
RevLine 
[7853]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
[8012]21from zope import schema
[8051]22from waeup.kofa.applicants.interfaces import (
[8053]23    IApplicantBaseData,
[8051]24    AppCatCertificateSource, CertificateSource)
25from waeup.kofa.schoolgrades import ResultEntryField
[8530]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
[8928]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    )
[8020]46from waeup.uniben.interfaces import MessageFactory as _
[8247]47from waeup.uniben.payments.interfaces import ICustomOnlinePayment
[7853]48
[8844]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
[8928]58class ICustomUGApplicant(INigeriaUGApplicant):
[8012]59    """An undergraduate applicant.
60
[8519]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.
[8012]64    """
65
[8071]66    nationality = schema.Choice(
67        source = nats_vocab,
68        title = _(u'Nationality'),
69        required = False,
70        )
71    lga = schema.Choice(
[8502]72        source = LGASource(),
[8071]73        title = _(u'State/LGA (Nigerians only)'),
74        required = False,
75        )
[8530]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        )
[8535]90    jamb_subjects = schema.Text(
91        title = _(u'Subjects and Scores'),
[8530]92        required = False,
93        )
[8535]94    jamb_score = schema.Int(
95        title = _(u'Total Score'),
96        required = False,
97        )
[8530]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        )
[8577]106    screening_date = schema.TextLine(
107        title = _(u'Screening Date'),
108        required = False,
109        )
[8530]110    screening_score = schema.Int(
[8803]111        title = _(u'Screening Score (%)'),
[8530]112        required = False,
113        )
[8803]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        )
[8530]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
[8928]138class ICustomPGApplicant(INigeriaPGApplicant):
[7853]139    """A postgraduate applicant.
140
[8519]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.
[7866]144    """
145
[8071]146    nationality = schema.Choice(
147        source = nats_vocab,
148        title = _(u'Nationality'),
149        required = False,
150        )
151    lga = schema.Choice(
[8502]152        source = LGASource(),
[8071]153        title = _(u'State/LGA (Nigerians only)'),
154        required = False,
155        )
[8051]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        )
[8101]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(
[8502]224        source = LGASource(),
[8101]225        title = _(u'Nysc Location'),
226        required = False,
227        )
[8012]228    employer = schema.TextLine(
229        title = _(u'Employer'),
230        required = False,
231        readonly = False,
232        )
[8051]233    emp_position = schema.TextLine(
234        title = _(u'Employer Position'),
235        required = False,
236        readonly = False,
237        )
[8184]238    emp_start = FormattedDate(
[8051]239        title = _(u'Start Date'),
240        required = False,
241        readonly = False,
[8378]242        show_year = True,
[8051]243        )
[8184]244    emp_end = FormattedDate(
[8051]245        title = _(u'End Date'),
246        required = False,
247        readonly = False,
[8378]248        show_year = True,
[8051]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        )
[8184]265    emp2_start = FormattedDate(
[8051]266        title = _(u'Start Date'),
267        required = False,
268        readonly = False,
[8378]269        show_year = True,
[8051]270        )
[8184]271    emp2_end = FormattedDate(
[8051]272        title = _(u'End Date'),
273        required = False,
274        readonly = False,
[8378]275        show_year = True,
[8051]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        )
[8582]292    screening_date = schema.TextLine(
293        title = _(u'Screening Date'),
294        required = False,
295        )
[8051]296    screening_score = schema.Int(
297        title = _(u'Screening Score'),
298        required = False,
299        readonly = False,
300        )
[8530]301    student_id = schema.TextLine(
302        title = _(u'Student Id'),
303        required = False,
304        readonly = False,
305        )
[8051]306    course_admitted = schema.Choice(
307        title = _(u'Admitted Course of Study'),
308        source = CertificateSource(),
309        required = False,
310        readonly = False,
311        )
[8530]312    locked = schema.Bool(
313        title = _(u'Form locked'),
314        default = False,
315        )
[8012]316
[8928]317class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
[8012]318    """An interface for both types of applicants.
319
[8928]320    Attention: The ICustomPGApplicant field seetings will be overwritten
321    by ICustomPGApplicant field settings. If a field is defined
[8727]322    in both interfaces zope.schema validates only against the
[8928]323    constraints in ICustomUGApplicant. This does not affect the forms
324    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]325    """
326
[8743]327    def writeLogMessage(view, comment):
[8053]328        """Adds an INFO message to the log file
329        """
330
331    def createStudent():
[8668]332        """Create a student object from applicant data
[8053]333        and copy applicant object.
334        """
335
[8928]336class ICustomUGApplicantEdit(ICustomUGApplicant):
[8727]337    """An undergraduate applicant interface for edit forms.
[8012]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
[8646]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
[8928]359ICustomUGApplicantEdit[
360    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
361ICustomUGApplicantEdit[
362    'email'].order =  ICustomUGApplicant['email'].order
[8646]363
[8928]364class ICustomPGApplicantEdit(ICustomPGApplicant):
[7866]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.
[8017]374    """
[8454]375
[8646]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
[8928]387ICustomPGApplicantEdit[
388    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
389ICustomPGApplicantEdit[
390    'email'].order =  ICustomPGApplicant['email'].order
[8646]391
[8928]392class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]393    """An applicant payment via payment gateways.
394
395    """
[8530]396
[8928]397class IPUTMEApplicantEdit(ICustomUGApplicant):
[8530]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        )
[8539]413    date_of_birth = FormattedDate(
414        title = _(u'Date of Birth'),
415        required = True,
416        show_year = True,
417        )
[8530]418
419IPUTMEApplicantEdit[
[8928]420    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
[8539]421IPUTMEApplicantEdit[
[8928]422    'email'].order =  ICustomUGApplicant['email'].order
[8582]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.