1 | ## $Id: interfaces.py 8807 2012-06-26 07:46:53Z 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 |
---|
29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
31 | from waeup.fceokene.interfaces import ( |
---|
32 | LGASource, high_qual, high_grade, exam_types) |
---|
33 | from waeup.fceokene.interfaces import MessageFactory as _ |
---|
34 | from waeup.fceokene.payments.interfaces import ICustomOnlinePayment |
---|
35 | |
---|
36 | UG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', |
---|
37 | 'password', 'result_uploaded') |
---|
38 | UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone') |
---|
39 | UG_OMIT_MANAGE_FIELDS = () |
---|
40 | UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + ('locked', 'course_admitted', |
---|
41 | 'student_id', 'screening_score', 'screening_venue', 'notice', |
---|
42 | 'screening_date', 'result_uploaded') |
---|
43 | PUTME_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + ( |
---|
44 | 'firstname', 'middlename', 'lastname', 'sex', |
---|
45 | 'course1', 'lga', 'jamb_score', 'jamb_subjects') |
---|
46 | UG_OMIT_RESULT_SLIP_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone', |
---|
47 | 'date_of_birth', 'sex', |
---|
48 | 'nationality', 'lga', 'perm_address', 'course2', 'screening_venue', |
---|
49 | 'screening_date') |
---|
50 | |
---|
51 | PG_OMIT_DISPLAY_FIELDS = ('locked', 'course_admitted', 'password') |
---|
52 | PG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('email', 'phone') |
---|
53 | PG_OMIT_MANAGE_FIELDS = () |
---|
54 | PG_OMIT_EDIT_FIELDS = PG_OMIT_MANAGE_FIELDS + ( |
---|
55 | 'locked', 'course_admitted', |
---|
56 | 'student_id', 'screening_score', 'screening_venue', 'notice', |
---|
57 | 'screening_date') |
---|
58 | |
---|
59 | class IUGApplicant(IApplicantBaseData): |
---|
60 | """An undergraduate applicant. |
---|
61 | |
---|
62 | This interface defines the least common multiple of all fields |
---|
63 | in ug application forms. In customized forms, fields can be excluded by |
---|
64 | adding them to the UG_OMIT* tuples. |
---|
65 | """ |
---|
66 | |
---|
67 | nationality = schema.Choice( |
---|
68 | source = nats_vocab, |
---|
69 | title = _(u'Nationality'), |
---|
70 | required = False, |
---|
71 | ) |
---|
72 | lga = schema.Choice( |
---|
73 | source = LGASource(), |
---|
74 | title = _(u'State/LGA (Nigerians only)'), |
---|
75 | required = False, |
---|
76 | ) |
---|
77 | perm_address = schema.Text( |
---|
78 | title = _(u'Permanent Address'), |
---|
79 | required = False, |
---|
80 | ) |
---|
81 | course1 = schema.Choice( |
---|
82 | title = _(u'1st Choice Course of Study'), |
---|
83 | source = AppCatCertificateSource(), |
---|
84 | required = True, |
---|
85 | ) |
---|
86 | course2 = schema.Choice( |
---|
87 | title = _(u'2nd Choice Course of Study'), |
---|
88 | source = AppCatCertificateSource(), |
---|
89 | required = False, |
---|
90 | ) |
---|
91 | jamb_subjects = schema.Text( |
---|
92 | title = _(u'Subjects and Scores'), |
---|
93 | required = False, |
---|
94 | ) |
---|
95 | jamb_score = schema.Int( |
---|
96 | title = _(u'Total Score'), |
---|
97 | required = False, |
---|
98 | ) |
---|
99 | notice = schema.Text( |
---|
100 | title = _(u'Notice'), |
---|
101 | required = False, |
---|
102 | ) |
---|
103 | screening_venue = schema.TextLine( |
---|
104 | title = _(u'Screening Venue'), |
---|
105 | required = False, |
---|
106 | ) |
---|
107 | screening_date = schema.TextLine( |
---|
108 | title = _(u'Screening Date'), |
---|
109 | required = False, |
---|
110 | ) |
---|
111 | screening_score = schema.Int( |
---|
112 | title = _(u'Screening Score (%)'), |
---|
113 | required = False, |
---|
114 | ) |
---|
115 | aggregate = schema.Int( |
---|
116 | title = _(u'Aggregate Score (%)'), |
---|
117 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
118 | required = False, |
---|
119 | ) |
---|
120 | result_uploaded = schema.Bool( |
---|
121 | title = _(u'Result uploaded'), |
---|
122 | default = False, |
---|
123 | ) |
---|
124 | student_id = schema.TextLine( |
---|
125 | title = _(u'Student Id'), |
---|
126 | required = False, |
---|
127 | readonly = False, |
---|
128 | ) |
---|
129 | course_admitted = schema.Choice( |
---|
130 | title = _(u'Admitted Course of Study'), |
---|
131 | source = CertificateSource(), |
---|
132 | required = False, |
---|
133 | ) |
---|
134 | locked = schema.Bool( |
---|
135 | title = _(u'Form locked'), |
---|
136 | default = False, |
---|
137 | ) |
---|
138 | |
---|
139 | class IPGApplicant(IApplicantBaseData): |
---|
140 | """A postgraduate applicant. |
---|
141 | |
---|
142 | This interface defines the least common multiple of all fields |
---|
143 | in pg application forms. In customized forms, fields can be excluded by |
---|
144 | adding them to the PG_OMIT* tuples. |
---|
145 | """ |
---|
146 | |
---|
147 | nationality = schema.Choice( |
---|
148 | source = nats_vocab, |
---|
149 | title = _(u'Nationality'), |
---|
150 | required = False, |
---|
151 | ) |
---|
152 | lga = schema.Choice( |
---|
153 | source = LGASource(), |
---|
154 | title = _(u'State/LGA (Nigerians only)'), |
---|
155 | required = False, |
---|
156 | ) |
---|
157 | perm_address = schema.Text( |
---|
158 | title = _(u'Permanent Address'), |
---|
159 | required = False, |
---|
160 | ) |
---|
161 | course1 = schema.Choice( |
---|
162 | title = _(u'1st Choice Course of Study'), |
---|
163 | source = AppCatCertificateSource(), |
---|
164 | required = True, |
---|
165 | ) |
---|
166 | course2 = schema.Choice( |
---|
167 | title = _(u'2nd Choice Course of Study'), |
---|
168 | source = AppCatCertificateSource(), |
---|
169 | required = False, |
---|
170 | ) |
---|
171 | hq_type = schema.Choice( |
---|
172 | title = _(u'Qualification Obtained'), |
---|
173 | required = False, |
---|
174 | readonly = False, |
---|
175 | vocabulary = high_qual, |
---|
176 | ) |
---|
177 | hq_matric_no = schema.TextLine( |
---|
178 | title = _(u'Former Matric Number'), |
---|
179 | required = False, |
---|
180 | readonly = False, |
---|
181 | ) |
---|
182 | hq_degree = schema.Choice( |
---|
183 | title = _(u'Class of Degree'), |
---|
184 | required = False, |
---|
185 | readonly = False, |
---|
186 | vocabulary = high_grade, |
---|
187 | ) |
---|
188 | hq_school = schema.TextLine( |
---|
189 | title = _(u'Institution Attended'), |
---|
190 | required = False, |
---|
191 | readonly = False, |
---|
192 | ) |
---|
193 | hq_session = schema.TextLine( |
---|
194 | title = _(u'Years Attended'), |
---|
195 | required = False, |
---|
196 | readonly = False, |
---|
197 | ) |
---|
198 | hq_disc = schema.TextLine( |
---|
199 | title = _(u'Discipline'), |
---|
200 | required = False, |
---|
201 | readonly = False, |
---|
202 | ) |
---|
203 | pp_school = schema.Choice( |
---|
204 | title = _(u'Qualification Obtained'), |
---|
205 | required = False, |
---|
206 | readonly = False, |
---|
207 | vocabulary = exam_types, |
---|
208 | ) |
---|
209 | #presently = schema.Bool( |
---|
210 | # title = _(u'Attending'), |
---|
211 | # required = False, |
---|
212 | # readonly = False, |
---|
213 | # ) |
---|
214 | presently_inst = schema.TextLine( |
---|
215 | title = _(u'If yes, name of institution'), |
---|
216 | required = False, |
---|
217 | readonly = False, |
---|
218 | ) |
---|
219 | nysc_year = schema.Int( |
---|
220 | title = _(u'Nysc Year'), |
---|
221 | required = False, |
---|
222 | readonly = False, |
---|
223 | ) |
---|
224 | nysc_lga = schema.Choice( |
---|
225 | source = LGASource(), |
---|
226 | title = _(u'Nysc Location'), |
---|
227 | required = False, |
---|
228 | ) |
---|
229 | employer = schema.TextLine( |
---|
230 | title = _(u'Employer'), |
---|
231 | required = False, |
---|
232 | readonly = False, |
---|
233 | ) |
---|
234 | emp_position = schema.TextLine( |
---|
235 | title = _(u'Employer Position'), |
---|
236 | required = False, |
---|
237 | readonly = False, |
---|
238 | ) |
---|
239 | emp_start = FormattedDate( |
---|
240 | title = _(u'Start Date'), |
---|
241 | required = False, |
---|
242 | readonly = False, |
---|
243 | show_year = True, |
---|
244 | ) |
---|
245 | emp_end = FormattedDate( |
---|
246 | title = _(u'End Date'), |
---|
247 | required = False, |
---|
248 | readonly = False, |
---|
249 | show_year = True, |
---|
250 | ) |
---|
251 | emp_reason = schema.TextLine( |
---|
252 | title = _(u'Reason for Leaving'), |
---|
253 | required = False, |
---|
254 | readonly = False, |
---|
255 | ) |
---|
256 | employer2 = schema.TextLine( |
---|
257 | title = _(u'2nd Employer'), |
---|
258 | required = False, |
---|
259 | readonly = False, |
---|
260 | ) |
---|
261 | emp2_position = schema.TextLine( |
---|
262 | title = _(u'2nd Employer Position'), |
---|
263 | required = False, |
---|
264 | readonly = False, |
---|
265 | ) |
---|
266 | emp2_start = FormattedDate( |
---|
267 | title = _(u'Start Date'), |
---|
268 | required = False, |
---|
269 | readonly = False, |
---|
270 | show_year = True, |
---|
271 | ) |
---|
272 | emp2_end = FormattedDate( |
---|
273 | title = _(u'End Date'), |
---|
274 | required = False, |
---|
275 | readonly = False, |
---|
276 | show_year = True, |
---|
277 | ) |
---|
278 | emp2_reason = schema.TextLine( |
---|
279 | title = _(u'Reason for Leaving'), |
---|
280 | required = False, |
---|
281 | readonly = False, |
---|
282 | ) |
---|
283 | notice = schema.Text( |
---|
284 | title = _(u'Notice'), |
---|
285 | required = False, |
---|
286 | readonly = False, |
---|
287 | ) |
---|
288 | screening_venue = schema.TextLine( |
---|
289 | title = _(u'Screening Venue'), |
---|
290 | required = False, |
---|
291 | readonly = False, |
---|
292 | ) |
---|
293 | screening_date = schema.TextLine( |
---|
294 | title = _(u'Screening Date'), |
---|
295 | required = False, |
---|
296 | ) |
---|
297 | screening_score = schema.Int( |
---|
298 | title = _(u'Screening Score'), |
---|
299 | required = False, |
---|
300 | readonly = False, |
---|
301 | ) |
---|
302 | student_id = schema.TextLine( |
---|
303 | title = _(u'Student Id'), |
---|
304 | required = False, |
---|
305 | readonly = False, |
---|
306 | ) |
---|
307 | course_admitted = schema.Choice( |
---|
308 | title = _(u'Admitted Course of Study'), |
---|
309 | source = CertificateSource(), |
---|
310 | required = False, |
---|
311 | readonly = False, |
---|
312 | ) |
---|
313 | locked = schema.Bool( |
---|
314 | title = _(u'Form locked'), |
---|
315 | default = False, |
---|
316 | ) |
---|
317 | |
---|
318 | class ICustomApplicant(IUGApplicant, IPGApplicant): |
---|
319 | """An interface for both types of applicants. |
---|
320 | |
---|
321 | Attention: The IPGApplicant field seetings will be overwritten |
---|
322 | by IPGApplicant field settings. If a field is defined |
---|
323 | in both interfaces zope.schema validates only against the |
---|
324 | constraints in IUGApplicant. This does not affect the forms |
---|
325 | since they are build on either IUGApplicant or IPGApplicant. |
---|
326 | """ |
---|
327 | |
---|
328 | def writeLogMessage(view, comment): |
---|
329 | """Adds an INFO message to the log file |
---|
330 | """ |
---|
331 | |
---|
332 | def createStudent(): |
---|
333 | """Create a student object from applicatnt data |
---|
334 | and copy applicant object. |
---|
335 | """ |
---|
336 | |
---|
337 | class IUGApplicantEdit(IUGApplicant): |
---|
338 | """An undergraduate applicant interface for edit forms. |
---|
339 | |
---|
340 | Here we can repeat the fields from base data and set the |
---|
341 | `required` and `readonly` attributes to True to further restrict |
---|
342 | the data access. Or we can allow only certain certificates to be |
---|
343 | selected by choosing the appropriate source. |
---|
344 | |
---|
345 | We cannot omit fields here. This has to be done in the |
---|
346 | respective form page. |
---|
347 | """ |
---|
348 | |
---|
349 | email = schema.ASCIILine( |
---|
350 | title = _(u'Email Address'), |
---|
351 | required = True, |
---|
352 | constraint=validate_email, |
---|
353 | ) |
---|
354 | date_of_birth = FormattedDate( |
---|
355 | title = _(u'Date of Birth'), |
---|
356 | required = True, |
---|
357 | show_year = True, |
---|
358 | ) |
---|
359 | |
---|
360 | IUGApplicantEdit[ |
---|
361 | 'date_of_birth'].order = IUGApplicant['date_of_birth'].order |
---|
362 | IUGApplicantEdit[ |
---|
363 | 'email'].order = IUGApplicant['email'].order |
---|
364 | |
---|
365 | class IPGApplicantEdit(IPGApplicant): |
---|
366 | """A postgraduate applicant interface for editing. |
---|
367 | |
---|
368 | Here we can repeat the fields from base data and set the |
---|
369 | `required` and `readonly` attributes to True to further restrict |
---|
370 | the data access. Or we can allow only certain certificates to be |
---|
371 | selected by choosing the appropriate source. |
---|
372 | |
---|
373 | We cannot omit fields here. This has to be done in the |
---|
374 | respective form page. |
---|
375 | """ |
---|
376 | |
---|
377 | email = schema.ASCIILine( |
---|
378 | title = _(u'Email Address'), |
---|
379 | required = True, |
---|
380 | constraint=validate_email, |
---|
381 | ) |
---|
382 | date_of_birth = FormattedDate( |
---|
383 | title = _(u'Date of Birth'), |
---|
384 | required = True, |
---|
385 | show_year = True, |
---|
386 | ) |
---|
387 | |
---|
388 | IPGApplicantEdit[ |
---|
389 | 'date_of_birth'].order = IPGApplicant['date_of_birth'].order |
---|
390 | IPGApplicantEdit[ |
---|
391 | 'email'].order = IPGApplicant['email'].order |
---|
392 | |
---|
393 | class ICustomApplicantOnlinePayment(ICustomOnlinePayment): |
---|
394 | """An applicant payment via payment gateways. |
---|
395 | |
---|
396 | """ |
---|
397 | |
---|
398 | class IPUTMEApplicantEdit(IUGApplicant): |
---|
399 | """An undergraduate applicant interface for editing. |
---|
400 | |
---|
401 | Here we can repeat the fields from base data and set the |
---|
402 | `required` and `readonly` attributes to True to further restrict |
---|
403 | the data access. Or we can allow only certain certificates to be |
---|
404 | selected by choosing the appropriate source. |
---|
405 | |
---|
406 | We cannot omit fields here. This has to be done in the |
---|
407 | respective form page. |
---|
408 | """ |
---|
409 | email = schema.ASCIILine( |
---|
410 | title = _(u'Email Address'), |
---|
411 | required = True, |
---|
412 | constraint=validate_email, |
---|
413 | ) |
---|
414 | date_of_birth = FormattedDate( |
---|
415 | title = _(u'Date of Birth'), |
---|
416 | required = True, |
---|
417 | show_year = True, |
---|
418 | ) |
---|
419 | |
---|
420 | IPUTMEApplicantEdit[ |
---|
421 | 'date_of_birth'].order = IUGApplicant['date_of_birth'].order |
---|
422 | IPUTMEApplicantEdit[ |
---|
423 | 'email'].order = IUGApplicant['email'].order |
---|
424 | |
---|
425 | class ICustomApplicantUpdateByRegNo(ICustomApplicant): |
---|
426 | """Representation of an applicant. |
---|
427 | |
---|
428 | Skip regular reg_number validation if reg_number is used for finding |
---|
429 | the applicant object. |
---|
430 | """ |
---|
431 | reg_number = schema.TextLine( |
---|
432 | title = u'Registration Number', |
---|
433 | required = False, |
---|
434 | ) |
---|