1 | ## $Id: interfaces.py 16639 2021-09-24 09:06:57Z 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, |
---|
32 | IApplicantBaseData) |
---|
33 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
34 | LGASource, high_qual, high_grade, exam_types, |
---|
35 | jambsubjects, |
---|
36 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
37 | INigeriaApplicantOnlinePayment, |
---|
38 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
39 | INigeriaApplicantUpdateByRegNo, |
---|
40 | IPUTMEApplicantEdit, |
---|
41 | ) |
---|
42 | from kofacustom.nigeria.interfaces import ( |
---|
43 | LGASource, DisabilitiesSource, |
---|
44 | high_qual, high_grade, exam_types, validate_jamb_reg_number) |
---|
45 | |
---|
46 | from kofacustom.edocons.interfaces import MessageFactory as _ |
---|
47 | from kofacustom.edocons.payments.interfaces import ICustomOnlinePayment |
---|
48 | |
---|
49 | programme_types_vocab = SimpleKofaVocabulary( |
---|
50 | (_('Post UTME'), 'putme'), |
---|
51 | (_('Post DE'), 'pude'), |
---|
52 | (_('Admission Screening Exercise'), 'ase'), |
---|
53 | (_('not applicable'), 'na'), |
---|
54 | ) |
---|
55 | |
---|
56 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
57 | """An undergraduate applicant. |
---|
58 | """ |
---|
59 | |
---|
60 | disabilities = schema.Choice( |
---|
61 | title = _(u'Disability'), |
---|
62 | source = DisabilitiesSource(), |
---|
63 | required = False, |
---|
64 | ) |
---|
65 | nationality = schema.Choice( |
---|
66 | source = nats_vocab, |
---|
67 | title = _(u'Nationality'), |
---|
68 | required = False, |
---|
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 | |
---|
80 | next_kin_name = schema.TextLine( |
---|
81 | title = _(u'Next of Kin Name'), |
---|
82 | required = False, |
---|
83 | readonly = False, |
---|
84 | ) |
---|
85 | |
---|
86 | next_kin_relation = schema.TextLine( |
---|
87 | title = _(u'Next of Kin Relationship'), |
---|
88 | required = False, |
---|
89 | readonly = False, |
---|
90 | ) |
---|
91 | |
---|
92 | next_kin_address = schema.Text( |
---|
93 | title = _(u'Next of Kin Address'), |
---|
94 | required = False, |
---|
95 | readonly = False, |
---|
96 | ) |
---|
97 | |
---|
98 | next_kin_phone = PhoneNumber( |
---|
99 | title = _(u'Next of Kin Phone'), |
---|
100 | description = u'', |
---|
101 | required = False, |
---|
102 | readonly = False, |
---|
103 | ) |
---|
104 | |
---|
105 | course1 = schema.Choice( |
---|
106 | title = _(u'1st Choice Course of Study'), |
---|
107 | source = AppCatCertificateSource(), |
---|
108 | required = True, |
---|
109 | ) |
---|
110 | course2 = schema.Choice( |
---|
111 | title = _(u'2nd Choice Course of Study'), |
---|
112 | source = AppCatCertificateSource(), |
---|
113 | required = False, |
---|
114 | ) |
---|
115 | |
---|
116 | fst_sit_fname = schema.TextLine( |
---|
117 | title = _(u'Full Name'), |
---|
118 | required = False, |
---|
119 | readonly = False, |
---|
120 | ) |
---|
121 | |
---|
122 | fst_sit_no = schema.TextLine( |
---|
123 | title = _(u'Exam Number'), |
---|
124 | required = False, |
---|
125 | readonly = False, |
---|
126 | ) |
---|
127 | |
---|
128 | fst_sit_sc_pin = schema.TextLine( |
---|
129 | title = _(u'Scratch Card Pin'), |
---|
130 | required = False, |
---|
131 | readonly = False, |
---|
132 | ) |
---|
133 | |
---|
134 | fst_sit_sc_serial_number = schema.TextLine( |
---|
135 | title = _(u'Scratch Card Serial Number'), |
---|
136 | required = False, |
---|
137 | readonly = False, |
---|
138 | ) |
---|
139 | |
---|
140 | fst_sit_date = FormattedDate( |
---|
141 | title = _(u'Exam Date'), |
---|
142 | required = False, |
---|
143 | readonly = False, |
---|
144 | show_year = True, |
---|
145 | ) |
---|
146 | |
---|
147 | fst_sit_type = schema.Choice( |
---|
148 | title = _(u'Exam Type'), |
---|
149 | required = False, |
---|
150 | readonly = False, |
---|
151 | vocabulary = exam_types, |
---|
152 | ) |
---|
153 | |
---|
154 | fst_sit_results = schema.List( |
---|
155 | title = _(u'Exam Results'), |
---|
156 | value_type = ResultEntryField(), |
---|
157 | required = False, |
---|
158 | readonly = False, |
---|
159 | defaultFactory=list, |
---|
160 | ) |
---|
161 | |
---|
162 | scd_sit_fname = schema.TextLine( |
---|
163 | title = _(u'Full Name'), |
---|
164 | required = False, |
---|
165 | readonly = False, |
---|
166 | ) |
---|
167 | |
---|
168 | scd_sit_no = schema.TextLine( |
---|
169 | title = _(u'Exam Number'), |
---|
170 | required = False, |
---|
171 | readonly = False, |
---|
172 | ) |
---|
173 | |
---|
174 | scd_sit_sc_pin = schema.TextLine( |
---|
175 | title = _(u'Scratch Card Pin'), |
---|
176 | required = False, |
---|
177 | readonly = False, |
---|
178 | ) |
---|
179 | |
---|
180 | scd_sit_sc_serial_number = schema.TextLine( |
---|
181 | title = _(u'Scratch Card Serial Number'), |
---|
182 | required = False, |
---|
183 | readonly = False, |
---|
184 | ) |
---|
185 | |
---|
186 | scd_sit_date = FormattedDate( |
---|
187 | title = _(u'Exam Date'), |
---|
188 | required = False, |
---|
189 | readonly = False, |
---|
190 | show_year = True, |
---|
191 | ) |
---|
192 | |
---|
193 | scd_sit_type = schema.Choice( |
---|
194 | title = _(u'Exam Type'), |
---|
195 | required = False, |
---|
196 | readonly = False, |
---|
197 | vocabulary = exam_types, |
---|
198 | ) |
---|
199 | |
---|
200 | scd_sit_results = schema.List( |
---|
201 | title = _(u'Exam Results'), |
---|
202 | value_type = ResultEntryField(), |
---|
203 | required = False, |
---|
204 | readonly = False, |
---|
205 | defaultFactory=list, |
---|
206 | ) |
---|
207 | |
---|
208 | programme_type = schema.Choice( |
---|
209 | title = _(u'Programme Type'), |
---|
210 | vocabulary = programme_types_vocab, |
---|
211 | required = False, |
---|
212 | ) |
---|
213 | |
---|
214 | hq_type = schema.Choice( |
---|
215 | title = _(u'Qualification Obtained'), |
---|
216 | required = False, |
---|
217 | readonly = False, |
---|
218 | vocabulary = high_qual, |
---|
219 | ) |
---|
220 | hq_matric_no = schema.TextLine( |
---|
221 | title = _(u'Former Matric Number'), |
---|
222 | required = False, |
---|
223 | readonly = False, |
---|
224 | ) |
---|
225 | hq_degree = schema.Choice( |
---|
226 | title = _(u'Class of Degree'), |
---|
227 | required = False, |
---|
228 | readonly = False, |
---|
229 | vocabulary = high_grade, |
---|
230 | ) |
---|
231 | hq_school = schema.TextLine( |
---|
232 | title = _(u'Institution Attended'), |
---|
233 | required = False, |
---|
234 | readonly = False, |
---|
235 | ) |
---|
236 | hq_session = schema.TextLine( |
---|
237 | title = _(u'Years Attended'), |
---|
238 | required = False, |
---|
239 | readonly = False, |
---|
240 | ) |
---|
241 | hq_disc = schema.TextLine( |
---|
242 | title = _(u'Discipline'), |
---|
243 | required = False, |
---|
244 | readonly = False, |
---|
245 | ) |
---|
246 | jamb_subjects = schema.Text( |
---|
247 | title = _(u'Subjects and Scores'), |
---|
248 | required = False, |
---|
249 | ) |
---|
250 | jamb_subjects_list = schema.List( |
---|
251 | title = _(u'JAMB Subjects'), |
---|
252 | required = False, |
---|
253 | defaultFactory=list, |
---|
254 | value_type = schema.Choice( |
---|
255 | vocabulary = jambsubjects |
---|
256 | #source = JAMBSubjectSource(), |
---|
257 | ), |
---|
258 | ) |
---|
259 | jamb_score = schema.Int( |
---|
260 | title = _(u'Total JAMB Score'), |
---|
261 | required = False, |
---|
262 | ) |
---|
263 | #jamb_age = schema.Int( |
---|
264 | # title = _(u'Age (provided by JAMB)'), |
---|
265 | # required = False, |
---|
266 | # ) |
---|
267 | jamb_reg_number = schema.TextLine( |
---|
268 | title = _(u'JAMB Registration Number'), |
---|
269 | required = False, |
---|
270 | constraint=validate_jamb_reg_number, |
---|
271 | ) |
---|
272 | notice = schema.Text( |
---|
273 | title = _(u'Notice'), |
---|
274 | required = False, |
---|
275 | ) |
---|
276 | screening_venue = schema.TextLine( |
---|
277 | title = _(u'Screening Venue'), |
---|
278 | required = False, |
---|
279 | ) |
---|
280 | screening_date = schema.TextLine( |
---|
281 | title = _(u'Screening Date'), |
---|
282 | required = False, |
---|
283 | ) |
---|
284 | screening_score = schema.Int( |
---|
285 | title = _(u'Screening Score (%)'), |
---|
286 | required = False, |
---|
287 | ) |
---|
288 | aggregate = schema.Int( |
---|
289 | title = _(u'Aggregate Score (%)'), |
---|
290 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
291 | required = False, |
---|
292 | ) |
---|
293 | result_uploaded = schema.Bool( |
---|
294 | title = _(u'Result uploaded'), |
---|
295 | default = False, |
---|
296 | required = False, |
---|
297 | ) |
---|
298 | student_id = schema.TextLine( |
---|
299 | title = _(u'Student Id'), |
---|
300 | required = False, |
---|
301 | readonly = False, |
---|
302 | ) |
---|
303 | course_admitted = schema.Choice( |
---|
304 | title = _(u'Admitted Course of Study'), |
---|
305 | source = CertificateSource(), |
---|
306 | required = False, |
---|
307 | ) |
---|
308 | locked = schema.Bool( |
---|
309 | title = _(u'Form locked'), |
---|
310 | default = False, |
---|
311 | required = False, |
---|
312 | ) |
---|
313 | |
---|
314 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
315 | """A postgraduate applicant. |
---|
316 | |
---|
317 | This interface defines the least common multiple of all fields |
---|
318 | in pg application forms. In customized forms, fields can be excluded by |
---|
319 | adding them to the PG_OMIT* tuples. |
---|
320 | """ |
---|
321 | |
---|
322 | |
---|
323 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
324 | """An interface for both types of applicants. |
---|
325 | |
---|
326 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
327 | by ICustomPGApplicant field settings. If a field is defined |
---|
328 | in both interfaces zope.schema validates only against the |
---|
329 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
330 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
331 | """ |
---|
332 | |
---|
333 | def writeLogMessage(view, comment): |
---|
334 | """Adds an INFO message to the log file |
---|
335 | """ |
---|
336 | |
---|
337 | def createStudent(): |
---|
338 | """Create a student object from applicant data |
---|
339 | and copy applicant object. |
---|
340 | """ |
---|
341 | |
---|
342 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
343 | """An undergraduate applicant interface for edit forms. |
---|
344 | |
---|
345 | Here we can repeat the fields from base data and set the |
---|
346 | `required` and `readonly` attributes to True to further restrict |
---|
347 | the data access. Or we can allow only certain certificates to be |
---|
348 | selected by choosing the appropriate source. |
---|
349 | |
---|
350 | We cannot omit fields here. This has to be done in the |
---|
351 | respective form page. |
---|
352 | """ |
---|
353 | |
---|
354 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
355 | """A postgraduate applicant interface for editing. |
---|
356 | |
---|
357 | Here we can repeat the fields from base data and set the |
---|
358 | `required` and `readonly` attributes to True to further restrict |
---|
359 | the data access. Or we can allow only certain certificates to be |
---|
360 | selected by choosing the appropriate source. |
---|
361 | |
---|
362 | We cannot omit fields here. This has to be done in the |
---|
363 | respective form page. |
---|
364 | """ |
---|
365 | |
---|
366 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
367 | """An applicant payment via payment gateways. |
---|
368 | |
---|
369 | """ |
---|
370 | |
---|
371 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
372 | """An undergraduate applicant interface for editing. |
---|
373 | |
---|
374 | Here we can repeat the fields from base data and set the |
---|
375 | `required` and `readonly` attributes to True to further restrict |
---|
376 | the data access. Or we can allow only certain certificates to be |
---|
377 | selected by choosing the appropriate source. |
---|
378 | |
---|
379 | We cannot omit fields here. This has to be done in the |
---|
380 | respective form page. |
---|
381 | """ |
---|
382 | |
---|
383 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
384 | """Representation of an applicant. |
---|
385 | |
---|
386 | Skip regular reg_number validation if reg_number is used for finding |
---|
387 | the applicant object. |
---|
388 | """ |
---|