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

Last change on this file since 10932 was 10924, checked in by Henrik Bettermann, 11 years ago

Add field programme_type and make date_of_birth compulsory.

  • Property svn:keywords set to Id
File size: 9.8 KB
Line 
1## $Id: interfaces.py 10924 2014-01-15 10:17:30Z 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 zope.interface import Attribute, invariant, Invalid
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)
29from waeup.kofa.schema import FormattedDate, TextLineChoice
30from waeup.kofa.students.vocabularies import nats_vocab, GenderSource
31from waeup.kofa.applicants.interfaces import (
32    contextual_reg_num_source,
33    IApplicantBaseData)
34from kofacustom.nigeria.applicants.interfaces import (
35    LGASource, high_qual, high_grade, exam_types,
36    INigeriaUGApplicant, INigeriaPGApplicant,
37    INigeriaApplicantOnlinePayment,
38    INigeriaUGApplicantEdit, INigeriaPGApplicantEdit,
39    INigeriaApplicantUpdateByRegNo,
40    IPUTMEApplicantEdit,
41    )
42from waeup.aaue.interfaces import MessageFactory as _
43from waeup.aaue.payments.interfaces import ICustomOnlinePayment
44
45programme_types_vocab = SimpleKofaVocabulary(
46    (_('5-Year Undergraduate Programme'), 'regular'),
47    (_('4-Year Undergraduate Programme (Direct Entry)'), 'direct'),
48    (_('not applicable'), 'na'),
49    )
50
51class ICustomUGApplicant(IApplicantBaseData):
52    """An undergraduate applicant.
53
54    This interface defines the least common multiple of all fields
55    in ug application forms. In customized forms, fields can be excluded by
56    adding them to the UG_OMIT* tuples.
57    """
58
59    programme_type = schema.Choice(
60        title = _(u'Programme Type'),
61        vocabulary = programme_types_vocab,
62        required = True,
63        )
64
65    nationality = schema.Choice(
66        source = nats_vocab,
67        title = _(u'Nationality'),
68        required = True,
69        )
70    lga = schema.Choice(
71        source = LGASource(),
72        title = _(u'State/LGA (Nigerians only)'),
73        required = False,
74        )
75    perm_address = schema.Text(
76        title = _(u'Permanent Address'),
77        required = False,
78        )
79    home_town = schema.TextLine(
80        title = _(u'Home Town'),
81        required = False,
82        )
83    jamb_reg_number = schema.TextLine(
84        title = _(u'JAMB Registration Number'),
85        required = False,
86        )
87    jamb_score = schema.Int(
88        title = _(u'Total JAMB Score'),
89        required = False,
90        )
91    course1 = schema.Choice(
92        title = _(u'1st Choice Course of Study'),
93        source = AppCatCertificateSource(),
94        required = True,
95        )
96    course2 = schema.Choice(
97        title = _(u'2nd Choice Course of Study'),
98        source = AppCatCertificateSource(),
99        required = False,
100        )
101    fst_sit_fname = schema.TextLine(
102        title = _(u'Full Name'),
103        required = False,
104        readonly = False,
105        )
106    fst_sit_no = schema.TextLine(
107        title = _(u'Exam Number'),
108        required = False,
109        readonly = False,
110        )
111    fst_sit_date = FormattedDate(
112        title = _(u'Exam Date'),
113        required = False,
114        readonly = False,
115        show_year = True,
116        )
117    fst_sit_type = schema.Choice(
118        title = _(u'Exam Type'),
119        required = False,
120        readonly = False,
121        vocabulary = exam_types,
122        )
123    fst_sit_results = schema.List(
124        title = _(u'Exam Results'),
125        value_type = ResultEntryField(),
126        required = False,
127        readonly = False,
128        default = [],
129        )
130    scd_sit_fname = schema.TextLine(
131        title = _(u'Full Name'),
132        required = False,
133        readonly = False,
134        )
135    scd_sit_no = schema.TextLine(
136        title = _(u'Exam Number'),
137        required = False,
138        readonly = False,
139        )
140    scd_sit_date = FormattedDate(
141        title = _(u'Exam Date'),
142        required = False,
143        readonly = False,
144        show_year = True,
145        )
146    scd_sit_type = schema.Choice(
147        title = _(u'Exam Type'),
148        required = False,
149        readonly = False,
150        vocabulary = exam_types,
151        )
152    scd_sit_results = schema.List(
153        title = _(u'Exam Results'),
154        value_type = ResultEntryField(),
155        required = False,
156        readonly = False,
157        default = [],
158        )
159    alr_fname = schema.TextLine(
160        title = _(u'Full Name'),
161        required = False,
162        readonly = False,
163        )
164    alr_no = schema.TextLine(
165        title = _(u'Exam Number'),
166        required = False,
167        readonly = False,
168        )
169    alr_date = FormattedDate(
170        title = _(u'Exam Date'),
171        required = False,
172        readonly = False,
173        show_year = True,
174        )
175    alr_results = schema.List(
176        title = _(u'Exam Results'),
177        value_type = ResultEntryField(),
178        required = False,
179        readonly = False,
180        default = [],
181        )
182    notice = schema.Text(
183        title = _(u'Notice'),
184        required = False,
185        )
186    #screening_venue = schema.TextLine(
187    #    title = _(u'Screening Venue'),
188    #    required = False,
189    #    )
190    #screening_date = schema.TextLine(
191    #    title = _(u'Screening Date'),
192    #    required = False,
193    #    )
194    #screening_score = schema.Int(
195    #    title = _(u'Screening Score (%)'),
196    #    required = False,
197    #    )
198    #aggregate = schema.Int(
199    #    title = _(u'Aggregate Score (%)'),
200    #    description = _(u'(average of relative JAMB and PUTME scores)'),
201    #    required = False,
202    #    )
203    result_uploaded = schema.Bool(
204        title = _(u'Result uploaded'),
205        default = False,
206        )
207    student_id = schema.TextLine(
208        title = _(u'Student Id'),
209        required = False,
210        readonly = False,
211        )
212    course_admitted = schema.Choice(
213        title = _(u'Admitted Course of Study'),
214        source = CertificateSource(),
215        required = False,
216        )
217    locked = schema.Bool(
218        title = _(u'Form locked'),
219        default = False,
220        )
221
222    @invariant
223    def second_choice(applicant):
224        if applicant.course1 == applicant.course2:
225            raise Invalid(_("2nd choice course must differ from 1st choice course."))
226
227ICustomUGApplicant['programme_type'].order = IApplicantBaseData[
228    'reg_number'].order
229
230class ICustomPGApplicant(INigeriaPGApplicant):
231    """A postgraduate applicant.
232
233    This interface defines the least common multiple of all fields
234    in pg application forms. In customized forms, fields can be excluded by
235    adding them to the PG_OMIT* tuples.
236    """
237
238class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant):
239    """An interface for both types of applicants.
240
241    Attention: The ICustomPGApplicant field seetings will be overwritten
242    by ICustomPGApplicant field settings. If a field is defined
243    in both interfaces zope.schema validates only against the
244    constraints in ICustomUGApplicant. This does not affect the forms
245    since they are build on either ICustomUGApplicant or ICustomPGApplicant.
246    """
247
248    def writeLogMessage(view, comment):
249        """Adds an INFO message to the log file
250        """
251
252    def createStudent():
253        """Create a student object from applicatnt data
254        and copy applicant object.
255        """
256
257class ICustomUGApplicantEdit(ICustomUGApplicant):
258    """An undergraduate applicant interface for edit forms.
259
260    Here we can repeat the fields from base data and set the
261    `required` and `readonly` attributes to True to further restrict
262    the data access. Or we can allow only certain certificates to be
263    selected by choosing the appropriate source.
264
265    We cannot omit fields here. This has to be done in the
266    respective form page.
267    """
268
269    date_of_birth = FormattedDate(
270        title = _(u'Date of Birth'),
271        required = True,
272        show_year = True,
273        )
274
275ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant[
276    'date_of_birth'].order
277
278class ICustomPGApplicantEdit(INigeriaPGApplicantEdit):
279    """A postgraduate applicant interface for editing.
280
281    Here we can repeat the fields from base data and set the
282    `required` and `readonly` attributes to True to further restrict
283    the data access. Or we can allow only certain certificates to be
284    selected by choosing the appropriate source.
285
286    We cannot omit fields here. This has to be done in the
287    respective form page.
288    """
289
290class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment):
291    """An applicant payment via payment gateways.
292
293    """
294
295class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
296    """An undergraduate applicant interface for editing.
297
298    Here we can repeat the fields from base data and set the
299    `required` and `readonly` attributes to True to further restrict
300    the data access. Or we can allow only certain certificates to be
301    selected by choosing the appropriate source.
302
303    We cannot omit fields here. This has to be done in the
304    respective form page.
305    """
306
307class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
308    """Representation of an applicant.
309
310    Skip regular reg_number validation if reg_number is used for finding
311    the applicant object.
312    """
313
Note: See TracBrowser for help on using the repository browser.