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