source: main/waeup.aaue/trunk/src/waeup/aaue/applicants/interfaces.py @ 8648

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

See waeup.uniben.

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