source: main/waeup.fceokene/trunk/src/waeup/fceokene/applicants/interfaces.py @ 14212

Last change on this file since 14212 was 14067, checked in by Henrik Bettermann, 8 years ago

Add schools.

Sort automatically.

  • Property svn:keywords set to Id
File size: 13.7 KB
Line 
1## $Id: interfaces.py 14067 2016-08-10 19:27:52Z 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 zc.sourcefactory.basic import BasicSourceFactory
23from waeup.kofa.applicants.interfaces import (
24    IApplicantBaseData,
25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
27from waeup.kofa.interfaces import (
28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
29    IKofaObject)
30from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
31from waeup.kofa.schoolgrades import ResultEntryField
32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
33from waeup.kofa.applicants.interfaces import contextual_reg_num_source
34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    OMIT_DISPLAY_FIELDS
42    )
43from waeup.fceokene.applicants.schools import SCHOOLS
44from waeup.fceokene.interfaces import MessageFactory as _
45
46BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
47BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
48BEC_OMIT_MANAGE_FIELDS = ('special_application',)
49BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
50    'student_id', 'notice',
51    'screening_score',
52    'screening_venue',
53    'screening_date',
54    #'jamb_subjects',
55    #'jamb_score',
56    'aggregate')
57
58class SchoolSource(BasicSourceFactory):
59    """A source that delivers all kinds of registrations.
60    """
61    def getValues(self):
62        sorted_items = sorted(
63            SCHOOLS.items(),
64            key=lambda element: element[1][0] + element[1][1] +element[1][2])
65        return [item[0] for item in sorted_items]
66
67    def getTitle(self, value):
68        return u"%s: %s -- %s" % (
69            SCHOOLS[value][0],
70            SCHOOLS[value][1],
71            SCHOOLS[value][2],)
72
73class ITPURegistration(IKofaObject):
74    """A TPU registrant.
75    """
76
77    suspended = schema.Bool(
78        title = _(u'Account suspended'),
79        default = False,
80        required = False,
81        )
82
83    locked = schema.Bool(
84        title = _(u'Form locked'),
85        default = False,
86        required = False,
87        )
88
89    applicant_id = schema.TextLine(
90        title = _(u'Applicant Id'),
91        required = False,
92        readonly = False,
93        )
94
95    reg_number = schema.TextLine(
96        title = _(u'Registration Number'),
97        required = False,
98        readonly = False,
99        )
100
101    matric_number = schema.TextLine(
102        title = _(u'Matriculation Number'),
103        required = False,
104        readonly = False,
105        )
106
107    firstname = schema.TextLine(
108        title = _(u'First Name'),
109        required = True,
110        )
111
112    middlename = schema.TextLine(
113        title = _(u'Middle Name'),
114        required = False,
115        )
116
117    lastname = schema.TextLine(
118        title = _(u'Last Name (Surname)'),
119        required = True,
120        )
121
122    email = schema.ASCIILine(
123        title = _(u'Email Address'),
124        required = True,
125        constraint=validate_email,
126        )
127
128    phone = PhoneNumber(
129        title = _(u'Phone'),
130        description = u'',
131        required = False,
132        )
133
134    perm_address = schema.Text(
135        title = _(u'Home Address'),
136        required = False,
137        readonly = False,
138        )
139
140    lga = schema.Choice(
141        source = LGASource(),
142        title = _(u'State/LGA'),
143        required = False,
144        )
145
146    subj_comb = schema.TextLine(
147        title = _(u'Subject Combination'),
148        required = False,
149        readonly = False,
150        )
151
152    school1 = schema.Choice(
153        title = _(u'1st Choice TPZ and School'),
154        source = SchoolSource(),
155        required = False,
156        )
157
158    school2 = schema.Choice(
159        title = _(u'2nd Choice TPZ and School'),
160        source = SchoolSource(),
161        required = False,
162        )
163
164    school3 = schema.Choice(
165        title = _(u'3rd Choice TPZ and School'),
166        source = SchoolSource(),
167        required = False,
168        )
169
170class ICustomUGApplicant(INigeriaUGApplicant):
171    """An undergraduate applicant.
172
173    This interface defines the least common multiple of all fields
174    in ug application forms. In customized forms, fields can be excluded by
175    adding them to the OMIT* tuples.
176    """
177
178    nationality = schema.Choice(
179        source = nats_vocab,
180        title = _(u'Nationality'),
181        required = True,
182        )
183    lga = schema.Choice(
184        source = LGASource(),
185        title = _(u'State/LGA (Nigerians only)'),
186        required = False,
187        )
188    #perm_address = schema.Text(
189    #    title = _(u'Permanent Address'),
190    #    required = False,
191    #    )
192    course1 = schema.Choice(
193        title = _(u'1st Choice Course of Study'),
194        source = AppCatCertificateSource(),
195        required = False,
196        )
197    course2 = schema.Choice(
198        title = _(u'2nd Choice Course of Study'),
199        source = AppCatCertificateSource(),
200        required = False,
201        )
202    olevel_type = schema.Choice(
203        title = _(u'1st Qualification Obtained'),
204        required = False,
205        readonly = False,
206        vocabulary = exam_types,
207        )
208    olevel_school = schema.TextLine(
209        title = _(u'1st Institution Attended'),
210        required = False,
211        readonly = False,
212        )
213    olevel_exam_number = schema.TextLine(
214        title = _(u'1st Exam Number'),
215        required = False,
216        readonly = False,
217        )
218    olevel_exam_date = FormattedDate(
219        title = _(u'1st Exam Date'),
220        required = False,
221        readonly = False,
222        show_year = True,
223        )
224    olevel_results = schema.List(
225        title = _(u'1st Exam Results'),
226        value_type = ResultEntryField(),
227        required = False,
228        readonly = False,
229        defaultFactory=list,
230        )
231    olevel_type2 = schema.Choice(
232        title = _(u'2nd Qualification Obtained'),
233        required = False,
234        readonly = False,
235        vocabulary = exam_types,
236        )
237    olevel_school2 = schema.TextLine(
238        title = _(u'2nd Institution Attended'),
239        required = False,
240        readonly = False,
241        )
242    olevel_exam_number2 = schema.TextLine(
243        title = _(u'2nd Exam Number'),
244        required = False,
245        readonly = False,
246        )
247    olevel_exam_date2 = FormattedDate(
248        title = _(u'2nd Exam Date'),
249        required = False,
250        readonly = False,
251        show_year = True,
252        )
253    olevel_results2 = schema.List(
254        title = _(u'2nd Exam Results'),
255        value_type = ResultEntryField(),
256        required = False,
257        readonly = False,
258        defaultFactory=list,
259        )
260    hq_type = schema.Choice(
261        title = _(u'Qualification Obtained'),
262        required = False,
263        readonly = False,
264        vocabulary = high_qual,
265        )
266    hq_matric_no = schema.TextLine(
267        title = _(u'Former Matric Number'),
268        required = False,
269        readonly = False,
270        )
271    hq_degree = schema.Choice(
272        title = _(u'Class of Degree'),
273        required = False,
274        readonly = False,
275        vocabulary = high_grade,
276        )
277    hq_school = schema.TextLine(
278        title = _(u'Institution Attended'),
279        required = False,
280        readonly = False,
281        )
282    hq_session = schema.TextLine(
283        title = _(u'Years Attended'),
284        required = False,
285        readonly = False,
286        )
287    hq_disc = schema.TextLine(
288        title = _(u'Discipline'),
289        required = False,
290        readonly = False,
291        )
292    jamb_subjects = schema.Text(
293        title = _(u'Subjects and Scores'),
294        description = _(u'(one subject with score per line)'),
295        required = False,
296        )
297    jamb_score = schema.Int(
298        title = _(u'Total JAMB Score'),
299        required = False,
300        )
301    jamb_reg_number = schema.TextLine(
302        title = _(u'JAMB Registration Number'),
303        required = False,
304        )
305    notice = schema.Text(
306        title = _(u'Notice'),
307        required = False,
308        )
309    screening_venue = schema.TextLine(
310        title = _(u'Screening Venue'),
311        required = False,
312        )
313    screening_date = schema.TextLine(
314        title = _(u'Screening Date'),
315        required = False,
316        )
317    screening_score = schema.Int(
318        title = _(u'Screening Score (%)'),
319        required = False,
320        )
321    aggregate = schema.Int(
322        title = _(u'Aggregate Score (%)'),
323        description = _(u'(average of relative JAMB and PUTME scores)'),
324        required = False,
325        )
326    result_uploaded = schema.Bool(
327        title = _(u'Result uploaded'),
328        default = False,
329        )
330    student_id = schema.TextLine(
331        title = _(u'Student Id'),
332        required = False,
333        readonly = False,
334        )
335    course_admitted = schema.Choice(
336        title = _(u'Admitted Course of Study'),
337        source = CertificateSource(),
338        required = False,
339        )
340    locked = schema.Bool(
341        title = _(u'Form locked'),
342        default = False,
343        )
344
345
346class ICustomPGApplicant(INigeriaPGApplicant):
347    """A postgraduate applicant.
348
349    This interface defines the least common multiple of all fields
350    in pg application forms. In customized forms, fields can be excluded by
351    adding them to the PG_OMIT* tuples.
352    """
353
354class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
355    ITPURegistration):
356    """An interface for all types of applicants.
357
358    Attention: The ICustomPGApplicant field seetings will be overwritten
359    by ICustomPGApplicant field settings. If a field is defined
360    in both interfaces zope.schema validates only against the
361    constraints in ICustomUGApplicant. This does not affect the forms
362    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
363    """
364
365    def writeLogMessage(view, comment):
366        """Adds an INFO message to the log file
367        """
368
369    def createStudent():
370        """Create a student object from applicatnt data
371        and copy applicant object.
372        """
373
374class ICustomUGApplicantEdit(ICustomUGApplicant):
375    """An undergraduate applicant interface for edit forms.
376
377    Here we can repeat the fields from base data and set the
378    `required` and `readonly` attributes to True to further restrict
379    the data access. Or we can allow only certain certificates to be
380    selected by choosing the appropriate source.
381
382    We cannot omit fields here. This has to be done in the
383    respective form page.
384    """
385
386
387    email = schema.ASCIILine(
388        title = _(u'Email Address'),
389        required = True,
390        constraint=validate_email,
391        )
392    date_of_birth = FormattedDate(
393        title = _(u'Date of Birth'),
394        required = True,
395        show_year = True,
396        )
397    jamb_reg_number = schema.TextLine(
398        title = _(u'JAMB Registration Number'),
399        required = True,
400        )
401    course1 = schema.Choice(
402        title = _(u'1st Choice Course of Study'),
403        source = AppCatCertificateSource(),
404        required = True,
405        )
406
407ICustomUGApplicantEdit[
408    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
409ICustomUGApplicantEdit[
410    'email'].order =  ICustomUGApplicant['email'].order
411ICustomUGApplicantEdit[
412    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
413ICustomUGApplicantEdit[
414    'course1'].order =  ICustomUGApplicant['course1'].order
415
416class ICustomPGApplicantEdit(ICustomPGApplicant):
417    """A postgraduate applicant interface for editing.
418
419    Here we can repeat the fields from base data and set the
420    `required` and `readonly` attributes to True to further restrict
421    the data access. Or we can allow only certain certificates to be
422    selected by choosing the appropriate source.
423
424    We cannot omit fields here. This has to be done in the
425    respective form page.
426    """
427
428    email = schema.ASCIILine(
429        title = _(u'Email Address'),
430        required = True,
431        constraint=validate_email,
432        )
433    date_of_birth = FormattedDate(
434        title = _(u'Date of Birth'),
435        required = True,
436        show_year = True,
437        )
438
439ICustomPGApplicantEdit[
440    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
441ICustomPGApplicantEdit[
442    'email'].order =  ICustomPGApplicant['email'].order
443
444
445class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
446    """An applicant payment via payment gateways.
447
448    """
449
450class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
451    """An undergraduate applicant interface for editing.
452
453    Here we can repeat the fields from base data and set the
454    `required` and `readonly` attributes to True to further restrict
455    the data access. Or we can allow only certain certificates to be
456    selected by choosing the appropriate source.
457
458    We cannot omit fields here. This has to be done in the
459    respective form page.
460    """
461
462class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
463    """Representation of an applicant.
464
465    Skip regular reg_number validation if reg_number is used for finding
466    the applicant object.
467    """
468
Note: See TracBrowser for help on using the repository browser.