1 | ## $Id: interfaces.py 14021 2016-07-07 06:44:47Z 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 | |
---|
21 | from zope import schema |
---|
22 | from waeup.kofa.applicants.interfaces import ( |
---|
23 | IApplicantBaseData, |
---|
24 | AppCatCertificateSource, CertificateSource) |
---|
25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
26 | from waeup.kofa.interfaces import ( |
---|
27 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email) |
---|
28 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
31 | from 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 | ) |
---|
39 | from kofacustom.wdu.interfaces import MessageFactory as _ |
---|
40 | from kofacustom.wdu.payments.interfaces import ICustomOnlinePayment |
---|
41 | |
---|
42 | class ICustomUGApplicant(IApplicantBaseData): |
---|
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 UG_OMIT* tuples. |
---|
48 | """ |
---|
49 | sex = schema.Choice( |
---|
50 | title = _(u'Sex'), |
---|
51 | source = GenderSource(), |
---|
52 | required = True, |
---|
53 | ) |
---|
54 | marit_stat = schema.Choice( |
---|
55 | title = u'Maritual Status', |
---|
56 | required = True, |
---|
57 | vocabulary = SimpleKofaVocabulary( |
---|
58 | (_('Single'), 'single'), |
---|
59 | (_('Married'), 'married'), |
---|
60 | (_('Widowed'), 'widowed'), |
---|
61 | (_('Divorced'), 'divorced'), |
---|
62 | (_('Separated'), 'separated'),) |
---|
63 | ) |
---|
64 | nationality = schema.Choice( |
---|
65 | source = nats_vocab, |
---|
66 | title = _(u'Nationality'), |
---|
67 | required = False, |
---|
68 | ) |
---|
69 | lga = schema.Choice( |
---|
70 | source = LGASource(), |
---|
71 | title = _(u'State/LGA'), |
---|
72 | description = _("Select 'Foreigner' if not a Nigerian."), |
---|
73 | required = True, |
---|
74 | ) |
---|
75 | religion = schema.Choice( |
---|
76 | title = u'Religion', |
---|
77 | default = 'no_say', |
---|
78 | required = False, |
---|
79 | vocabulary = SimpleKofaVocabulary( |
---|
80 | (_('Muslim'), 'muslim'), |
---|
81 | (_('Christian'), 'christian'), |
---|
82 | (_('Others'), 'others'), |
---|
83 | (_('Prefer not to say'), 'no_say'),) |
---|
84 | ) |
---|
85 | #perm_address = schema.Text( |
---|
86 | # title = _(u'Permanent Address'), |
---|
87 | # required = False, |
---|
88 | # ) |
---|
89 | next_kin_address = schema.Text( |
---|
90 | title = _(u'Next of Kin Address'), |
---|
91 | required = False, |
---|
92 | ) |
---|
93 | course1 = schema.Choice( |
---|
94 | title = _(u'1st Choice Course of Study'), |
---|
95 | source = AppCatCertificateSource(), |
---|
96 | required = False, |
---|
97 | ) |
---|
98 | course2 = schema.Choice( |
---|
99 | title = _(u'2nd Choice Course of Study'), |
---|
100 | source = AppCatCertificateSource(), |
---|
101 | required = False, |
---|
102 | ) |
---|
103 | olevel_type = schema.Choice( |
---|
104 | title = _(u'Qualification Obtained'), |
---|
105 | required = False, |
---|
106 | readonly = False, |
---|
107 | vocabulary = exam_types, |
---|
108 | ) |
---|
109 | olevel_school = schema.TextLine( |
---|
110 | title = _(u'Institution Attended'), |
---|
111 | required = False, |
---|
112 | readonly = False, |
---|
113 | ) |
---|
114 | olevel_exam_number = schema.TextLine( |
---|
115 | title = _(u'Exam Number'), |
---|
116 | required = False, |
---|
117 | readonly = False, |
---|
118 | ) |
---|
119 | olevel_exam_date = FormattedDate( |
---|
120 | title = _(u'Exam Date'), |
---|
121 | required = False, |
---|
122 | readonly = False, |
---|
123 | show_year = True, |
---|
124 | ) |
---|
125 | olevel_results = schema.List( |
---|
126 | title = _(u'Exam Results'), |
---|
127 | value_type = ResultEntryField(), |
---|
128 | required = False, |
---|
129 | readonly = False, |
---|
130 | defaultFactory=list, |
---|
131 | ) |
---|
132 | olevel_type2 = schema.Choice( |
---|
133 | title = _(u'2nd Qualification Obtained'), |
---|
134 | required = False, |
---|
135 | readonly = False, |
---|
136 | vocabulary = exam_types, |
---|
137 | ) |
---|
138 | olevel_school2 = schema.TextLine( |
---|
139 | title = _(u'2nd Institution Attended'), |
---|
140 | required = False, |
---|
141 | readonly = False, |
---|
142 | ) |
---|
143 | olevel_exam_number2 = schema.TextLine( |
---|
144 | title = _(u'2nd Exam Number'), |
---|
145 | required = False, |
---|
146 | readonly = False, |
---|
147 | ) |
---|
148 | olevel_exam_date2 = FormattedDate( |
---|
149 | title = _(u'2nd Exam Date'), |
---|
150 | required = False, |
---|
151 | readonly = False, |
---|
152 | show_year = True, |
---|
153 | ) |
---|
154 | olevel_results2 = schema.List( |
---|
155 | title = _(u'2nd Exam Results'), |
---|
156 | value_type = ResultEntryField(), |
---|
157 | required = False, |
---|
158 | readonly = False, |
---|
159 | defaultFactory=list, |
---|
160 | ) |
---|
161 | hq_type = schema.Choice( |
---|
162 | title = _(u'Qualification Obtained'), |
---|
163 | required = False, |
---|
164 | readonly = False, |
---|
165 | vocabulary = high_qual, |
---|
166 | ) |
---|
167 | hq_matric_no = schema.TextLine( |
---|
168 | title = _(u'Former Matric Number'), |
---|
169 | required = False, |
---|
170 | readonly = False, |
---|
171 | ) |
---|
172 | hq_degree = schema.Choice( |
---|
173 | title = _(u'Class of Degree'), |
---|
174 | required = False, |
---|
175 | readonly = False, |
---|
176 | vocabulary = high_grade, |
---|
177 | ) |
---|
178 | hq_school = schema.TextLine( |
---|
179 | title = _(u'Institution Attended'), |
---|
180 | required = False, |
---|
181 | readonly = False, |
---|
182 | ) |
---|
183 | hq_session = schema.TextLine( |
---|
184 | title = _(u'Years Attended'), |
---|
185 | required = False, |
---|
186 | readonly = False, |
---|
187 | ) |
---|
188 | hq_disc = schema.TextLine( |
---|
189 | title = _(u'Discipline'), |
---|
190 | required = False, |
---|
191 | readonly = False, |
---|
192 | ) |
---|
193 | employer = schema.TextLine( |
---|
194 | title = _(u'Employer'), |
---|
195 | required = False, |
---|
196 | readonly = False, |
---|
197 | ) |
---|
198 | emp_position = schema.TextLine( |
---|
199 | title = _(u'Employer Position'), |
---|
200 | required = False, |
---|
201 | readonly = False, |
---|
202 | ) |
---|
203 | emp_start = FormattedDate( |
---|
204 | title = _(u'Start Date'), |
---|
205 | required = False, |
---|
206 | readonly = False, |
---|
207 | show_year = True, |
---|
208 | ) |
---|
209 | emp_end = FormattedDate( |
---|
210 | title = _(u'End Date'), |
---|
211 | required = False, |
---|
212 | readonly = False, |
---|
213 | show_year = True, |
---|
214 | ) |
---|
215 | employer2 = schema.TextLine( |
---|
216 | title = _(u'2nd Employer'), |
---|
217 | required = False, |
---|
218 | readonly = False, |
---|
219 | ) |
---|
220 | emp2_position = schema.TextLine( |
---|
221 | title = _(u'2nd Employer Position'), |
---|
222 | required = False, |
---|
223 | readonly = False, |
---|
224 | ) |
---|
225 | emp2_start = FormattedDate( |
---|
226 | title = _(u'Start Date'), |
---|
227 | required = False, |
---|
228 | readonly = False, |
---|
229 | show_year = True, |
---|
230 | ) |
---|
231 | emp2_end = FormattedDate( |
---|
232 | title = _(u'End Date'), |
---|
233 | required = False, |
---|
234 | readonly = False, |
---|
235 | show_year = True, |
---|
236 | ) |
---|
237 | body_responsible_address = schema.Text( |
---|
238 | title = _(u'Name and Adress of Body'), |
---|
239 | description = _( |
---|
240 | 'Name and address of body who will be responsible for the fees. ' |
---|
241 | 'If admission to the university is offered ' |
---|
242 | 'a guarantor\'s form that all the fees will be paid will be sworn to ' |
---|
243 | 'by the person or body named. The student will not be allowed into the ' |
---|
244 | 'university until the guarantor\'s form is signed and returned ' |
---|
245 | 'to the institution.'), |
---|
246 | required = False, |
---|
247 | ) |
---|
248 | jamb_subjects = schema.Text( |
---|
249 | title = _(u'Subjects and Scores'), |
---|
250 | description = _(u'One subject with score per line.'), |
---|
251 | required = False, |
---|
252 | ) |
---|
253 | jamb_score = schema.Int( |
---|
254 | title = _(u'Total JAMB Score'), |
---|
255 | required = False, |
---|
256 | ) |
---|
257 | jamb_reg_number = schema.TextLine( |
---|
258 | title = _(u'JAMB Registration Number'), |
---|
259 | required = False, |
---|
260 | ) |
---|
261 | notice = schema.Text( |
---|
262 | title = _(u'Notice'), |
---|
263 | required = False, |
---|
264 | ) |
---|
265 | screening_venue = schema.TextLine( |
---|
266 | title = _(u'Screening Venue'), |
---|
267 | required = False, |
---|
268 | ) |
---|
269 | screening_date = schema.TextLine( |
---|
270 | title = _(u'Screening Date'), |
---|
271 | required = False, |
---|
272 | ) |
---|
273 | screening_score = schema.Int( |
---|
274 | title = _(u'Screening Score (%)'), |
---|
275 | required = False, |
---|
276 | ) |
---|
277 | aggregate = schema.Int( |
---|
278 | title = _(u'Aggregate Score (%)'), |
---|
279 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
280 | required = False, |
---|
281 | ) |
---|
282 | result_uploaded = schema.Bool( |
---|
283 | title = _(u'Result uploaded'), |
---|
284 | default = False, |
---|
285 | required = False, |
---|
286 | ) |
---|
287 | student_id = schema.TextLine( |
---|
288 | title = _(u'Student Id'), |
---|
289 | required = False, |
---|
290 | readonly = False, |
---|
291 | ) |
---|
292 | course_admitted = schema.Choice( |
---|
293 | title = _(u'Admitted Course of Study'), |
---|
294 | source = CertificateSource(), |
---|
295 | required = False, |
---|
296 | ) |
---|
297 | locked = schema.Bool( |
---|
298 | title = _(u'Form locked'), |
---|
299 | default = False, |
---|
300 | required = False, |
---|
301 | ) |
---|
302 | |
---|
303 | ICustomUGApplicant[ |
---|
304 | 'sex'].order = IApplicantBaseData['sex'].order |
---|
305 | |
---|
306 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
307 | """A postgraduate applicant. |
---|
308 | |
---|
309 | This interface defines the least common multiple of all fields |
---|
310 | in pg application forms. In customized forms, fields can be excluded by |
---|
311 | adding them to the PG_OMIT* tuples. |
---|
312 | """ |
---|
313 | |
---|
314 | |
---|
315 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
316 | """An interface for both types of applicants. |
---|
317 | |
---|
318 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
319 | by ICustomPGApplicant field settings. If a field is defined |
---|
320 | in both interfaces zope.schema validates only against the |
---|
321 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
322 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
323 | """ |
---|
324 | |
---|
325 | def writeLogMessage(view, comment): |
---|
326 | """Adds an INFO message to the log file |
---|
327 | """ |
---|
328 | |
---|
329 | def createStudent(): |
---|
330 | """Create a student object from applicant data |
---|
331 | and copy applicant object. |
---|
332 | """ |
---|
333 | |
---|
334 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
335 | """An undergraduate applicant interface for edit forms. |
---|
336 | |
---|
337 | Here we can repeat the fields from base data and set the |
---|
338 | `required` and `readonly` attributes to True to further restrict |
---|
339 | the data access. Or we can allow only certain certificates to be |
---|
340 | selected by choosing the appropriate source. |
---|
341 | |
---|
342 | We cannot omit fields here. This has to be done in the |
---|
343 | respective form page. |
---|
344 | """ |
---|
345 | |
---|
346 | email = schema.ASCIILine( |
---|
347 | title = _(u'Email Address'), |
---|
348 | required = True, |
---|
349 | constraint=validate_email, |
---|
350 | ) |
---|
351 | date_of_birth = FormattedDate( |
---|
352 | title = _(u'Date of Birth'), |
---|
353 | required = True, |
---|
354 | show_year = True, |
---|
355 | ) |
---|
356 | phone = PhoneNumber( |
---|
357 | title = _(u'Phone'), |
---|
358 | description = u'', |
---|
359 | required = True, |
---|
360 | ) |
---|
361 | |
---|
362 | ICustomUGApplicantEdit['email'].order = ICustomUGApplicant['email'].order |
---|
363 | ICustomUGApplicantEdit['date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
364 | ICustomUGApplicantEdit['phone'].order = ICustomUGApplicant['phone'].order |
---|
365 | |
---|
366 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
367 | """A postgraduate applicant interface for editing. |
---|
368 | |
---|
369 | Here we can repeat the fields from base data and set the |
---|
370 | `required` and `readonly` attributes to True to further restrict |
---|
371 | the data access. Or we can allow only certain certificates to be |
---|
372 | selected by choosing the appropriate source. |
---|
373 | |
---|
374 | We cannot omit fields here. This has to be done in the |
---|
375 | respective form page. |
---|
376 | """ |
---|
377 | |
---|
378 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
379 | """An applicant payment via payment gateways. |
---|
380 | |
---|
381 | """ |
---|
382 | |
---|
383 | class ICustomPUTMEApplicantEdit(ICustomUGApplicant): |
---|
384 | """An undergraduate applicant interface for editing. |
---|
385 | |
---|
386 | Here we can repeat the fields from base data and set the |
---|
387 | `required` and `readonly` attributes to True to further restrict |
---|
388 | the data access. Or we can allow only certain certificates to be |
---|
389 | selected by choosing the appropriate source. |
---|
390 | |
---|
391 | We cannot omit fields here. This has to be done in the |
---|
392 | respective form page. |
---|
393 | """ |
---|
394 | |
---|
395 | email = schema.ASCIILine( |
---|
396 | title = _(u'Email Address'), |
---|
397 | required = True, |
---|
398 | constraint=validate_email, |
---|
399 | ) |
---|
400 | date_of_birth = FormattedDate( |
---|
401 | title = _(u'Date of Birth'), |
---|
402 | required = True, |
---|
403 | show_year = True, |
---|
404 | ) |
---|
405 | phone = PhoneNumber( |
---|
406 | title = _(u'Phone'), |
---|
407 | description = u'', |
---|
408 | required = True, |
---|
409 | ) |
---|
410 | |
---|
411 | ICustomPUTMEApplicantEdit['email'].order = ICustomUGApplicant['email'].order |
---|
412 | ICustomPUTMEApplicantEdit['date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
413 | ICustomPUTMEApplicantEdit['phone'].order = ICustomUGApplicant['phone'].order |
---|
414 | |
---|
415 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
416 | """Representation of an applicant. |
---|
417 | |
---|
418 | Skip regular reg_number validation if reg_number is used for finding |
---|
419 | the applicant object. |
---|
420 | """ |
---|