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

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

Add special school fee regulations for staff members and foreign students.

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