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

Last change on this file since 14086 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
RevLine 
[7853]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
[8012]21from zope import schema
[13877]22from zc.sourcefactory.basic import BasicSourceFactory
[8051]23from waeup.kofa.applicants.interfaces import (
[8053]24    IApplicantBaseData,
[8051]25    AppCatCertificateSource, CertificateSource)
26from waeup.kofa.schoolgrades import ResultEntryField
[8531]27from waeup.kofa.interfaces import (
[13877]28    SimpleKofaVocabulary, academic_sessions_vocab, validate_email,
29    IKofaObject)
30from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber
[9465]31from waeup.kofa.schoolgrades import ResultEntryField
[8531]32from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
33from waeup.kofa.applicants.interfaces import contextual_reg_num_source
[8933]34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
[9497]38    INigeriaUGApplicantEdit,
[8979]39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
[9463]41    OMIT_DISPLAY_FIELDS
[8933]42    )
[13877]43from waeup.fceokene.applicants.schools import SCHOOLS
[8460]44from waeup.fceokene.interfaces import MessageFactory as _
[7853]45
[9463]46BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS
47BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',)
[10852]48BEC_OMIT_MANAGE_FIELDS = ('special_application',)
[9463]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
[13877]58class SchoolSource(BasicSourceFactory):
59    """A source that delivers all kinds of registrations.
60    """
61    def getValues(self):
[14067]62        sorted_items = sorted(
63            SCHOOLS.items(),
64            key=lambda element: element[1][0] + element[1][1] +element[1][2])
[13877]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(),
[13883]155        required = False,
[13877]156        )
157
158    school2 = schema.Choice(
159        title = _(u'2nd Choice TPZ and School'),
160        source = SchoolSource(),
[13883]161        required = False,
[13877]162        )
163
164    school3 = schema.Choice(
165        title = _(u'3rd Choice TPZ and School'),
166        source = SchoolSource(),
[13883]167        required = False,
[13877]168        )
169
[8933]170class ICustomUGApplicant(INigeriaUGApplicant):
[8012]171    """An undergraduate applicant.
172
[8520]173    This interface defines the least common multiple of all fields
174    in ug application forms. In customized forms, fields can be excluded by
[9463]175    adding them to the OMIT* tuples.
[8012]176    """
177
[9465]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(),
[13884]195        required = False,
[9465]196        )
197    course2 = schema.Choice(
198        title = _(u'2nd Choice Course of Study'),
199        source = AppCatCertificateSource(),
200        required = False,
201        )
[9463]202    olevel_type = schema.Choice(
[9500]203        title = _(u'1st Qualification Obtained'),
[9463]204        required = False,
205        readonly = False,
[9465]206        vocabulary = exam_types,
207        )
208    olevel_school = schema.TextLine(
[9500]209        title = _(u'1st Institution Attended'),
[9465]210        required = False,
211        readonly = False,
212        )
213    olevel_exam_number = schema.TextLine(
[9500]214        title = _(u'1st Exam Number'),
[9465]215        required = False,
216        readonly = False,
217        )
218    olevel_exam_date = FormattedDate(
[9500]219        title = _(u'1st Exam Date'),
[9465]220        required = False,
221        readonly = False,
222        show_year = True,
223        )
224    olevel_results = schema.List(
[9500]225        title = _(u'1st Exam Results'),
[9465]226        value_type = ResultEntryField(),
227        required = False,
228        readonly = False,
[14018]229        defaultFactory=list,
[9465]230        )
[9500]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,
[14018]258        defaultFactory=list,
[9500]259        )
[9465]260    hq_type = schema.Choice(
261        title = _(u'Qualification Obtained'),
262        required = False,
263        readonly = False,
[9463]264        vocabulary = high_qual,
265        )
[9465]266    hq_matric_no = schema.TextLine(
[9463]267        title = _(u'Former Matric Number'),
268        required = False,
269        readonly = False,
270        )
[9465]271    hq_degree = schema.Choice(
[9463]272        title = _(u'Class of Degree'),
273        required = False,
274        readonly = False,
275        vocabulary = high_grade,
276        )
[9465]277    hq_school = schema.TextLine(
[9463]278        title = _(u'Institution Attended'),
279        required = False,
280        readonly = False,
281        )
[9465]282    hq_session = schema.TextLine(
[9463]283        title = _(u'Years Attended'),
284        required = False,
285        readonly = False,
286        )
[9465]287    hq_disc = schema.TextLine(
[9463]288        title = _(u'Discipline'),
289        required = False,
290        readonly = False,
291        )
[9465]292    jamb_subjects = schema.Text(
293        title = _(u'Subjects and Scores'),
[10533]294        description = _(u'(one subject with score per line)'),
[9465]295        required = False,
296        )
297    jamb_score = schema.Int(
298        title = _(u'Total JAMB Score'),
299        required = False,
300        )
[10500]301    jamb_reg_number = schema.TextLine(
302        title = _(u'JAMB Registration Number'),
303        required = False,
304        )
[9465]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        )
[9463]344
345
[8933]346class ICustomPGApplicant(INigeriaPGApplicant):
[7853]347    """A postgraduate applicant.
348
[8520]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.
[7866]352    """
353
[13877]354class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant,
355    ITPURegistration):
356    """An interface for all types of applicants.
[8012]357
[8933]358    Attention: The ICustomPGApplicant field seetings will be overwritten
359    by ICustomPGApplicant field settings. If a field is defined
[8729]360    in both interfaces zope.schema validates only against the
[8933]361    constraints in ICustomUGApplicant. This does not affect the forms
362    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
[8012]363    """
364
[8745]365    def writeLogMessage(view, comment):
[8053]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
[9497]374class ICustomUGApplicantEdit(ICustomUGApplicant):
[8729]375    """An undergraduate applicant interface for edit forms.
[8012]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
[9497]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        )
[11776]397    jamb_reg_number = schema.TextLine(
398        title = _(u'JAMB Registration Number'),
399        required = True,
400        )
[13884]401    course1 = schema.Choice(
402        title = _(u'1st Choice Course of Study'),
403        source = AppCatCertificateSource(),
404        required = True,
405        )
[9497]406
[10500]407ICustomUGApplicantEdit[
408    'date_of_birth'].order =  ICustomUGApplicant['date_of_birth'].order
409ICustomUGApplicantEdit[
410    'email'].order =  ICustomUGApplicant['email'].order
411ICustomUGApplicantEdit[
[13238]412    'jamb_reg_number'].order =  ICustomUGApplicant['jamb_reg_number'].order
[13884]413ICustomUGApplicantEdit[
414    'course1'].order =  ICustomUGApplicant['course1'].order
[10500]415
[9497]416class ICustomPGApplicantEdit(ICustomPGApplicant):
[7866]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.
[8017]426    """
[8454]427
[9497]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
[10500]439ICustomPGApplicantEdit[
440    'date_of_birth'].order =  ICustomPGApplicant['date_of_birth'].order
441ICustomPGApplicantEdit[
442    'email'].order =  ICustomPGApplicant['email'].order
443
444
[8933]445class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
[8247]446    """An applicant payment via payment gateways.
447
448    """
[8531]449
[8979]450class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
[8531]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
[8979]462class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
[8584]463    """Representation of an applicant.
464
465    Skip regular reg_number validation if reg_number is used for finding
466    the applicant object.
467    """
[8979]468
Note: See TracBrowser for help on using the repository browser.