source: main/kofacustom.coewarri/trunk/src/kofacustom/coewarri/applicants/interfaces.py

Last change on this file was 14334, checked in by Henrik Bettermann, 8 years ago

Set required attribute.

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