1 | ## $Id: interfaces.py 16654 2021-09-29 11:53:17Z 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_date = FormattedDate( |
---|
129 | title = _(u'Exam Date'), |
---|
130 | required = False, |
---|
131 | readonly = False, |
---|
132 | show_year = True, |
---|
133 | ) |
---|
134 | |
---|
135 | fst_sit_type = schema.Choice( |
---|
136 | title = _(u'Exam Type'), |
---|
137 | required = False, |
---|
138 | readonly = False, |
---|
139 | vocabulary = exam_types, |
---|
140 | ) |
---|
141 | |
---|
142 | fst_sit_results = schema.List( |
---|
143 | title = _(u'Exam Results'), |
---|
144 | value_type = ResultEntryField(), |
---|
145 | required = False, |
---|
146 | readonly = False, |
---|
147 | defaultFactory=list, |
---|
148 | ) |
---|
149 | |
---|
150 | scd_sit_fname = schema.TextLine( |
---|
151 | title = _(u'Full Name'), |
---|
152 | required = False, |
---|
153 | readonly = False, |
---|
154 | ) |
---|
155 | |
---|
156 | scd_sit_no = schema.TextLine( |
---|
157 | title = _(u'Exam Number'), |
---|
158 | required = False, |
---|
159 | readonly = False, |
---|
160 | ) |
---|
161 | |
---|
162 | scd_sit_date = FormattedDate( |
---|
163 | title = _(u'Exam Date'), |
---|
164 | required = False, |
---|
165 | readonly = False, |
---|
166 | show_year = True, |
---|
167 | ) |
---|
168 | |
---|
169 | scd_sit_type = schema.Choice( |
---|
170 | title = _(u'Exam Type'), |
---|
171 | required = False, |
---|
172 | readonly = False, |
---|
173 | vocabulary = exam_types, |
---|
174 | ) |
---|
175 | |
---|
176 | scd_sit_results = schema.List( |
---|
177 | title = _(u'Exam Results'), |
---|
178 | value_type = ResultEntryField(), |
---|
179 | required = False, |
---|
180 | readonly = False, |
---|
181 | defaultFactory=list, |
---|
182 | ) |
---|
183 | |
---|
184 | programme_type = schema.Choice( |
---|
185 | title = _(u'Programme Type'), |
---|
186 | vocabulary = programme_types_vocab, |
---|
187 | required = False, |
---|
188 | ) |
---|
189 | |
---|
190 | hq_type = schema.Choice( |
---|
191 | title = _(u'Qualification Obtained'), |
---|
192 | required = False, |
---|
193 | readonly = False, |
---|
194 | vocabulary = high_qual, |
---|
195 | ) |
---|
196 | hq_matric_no = schema.TextLine( |
---|
197 | title = _(u'Former Matric Number'), |
---|
198 | required = False, |
---|
199 | readonly = False, |
---|
200 | ) |
---|
201 | hq_degree = schema.Choice( |
---|
202 | title = _(u'Class of Degree'), |
---|
203 | required = False, |
---|
204 | readonly = False, |
---|
205 | vocabulary = high_grade, |
---|
206 | ) |
---|
207 | hq_school = schema.TextLine( |
---|
208 | title = _(u'Institution Attended'), |
---|
209 | required = False, |
---|
210 | readonly = False, |
---|
211 | ) |
---|
212 | hq_session = schema.TextLine( |
---|
213 | title = _(u'Years Attended'), |
---|
214 | required = False, |
---|
215 | readonly = False, |
---|
216 | ) |
---|
217 | hq_disc = schema.TextLine( |
---|
218 | title = _(u'Discipline'), |
---|
219 | required = False, |
---|
220 | readonly = False, |
---|
221 | ) |
---|
222 | jamb_subjects = schema.Text( |
---|
223 | title = _(u'Subjects and Scores'), |
---|
224 | required = False, |
---|
225 | ) |
---|
226 | jamb_subjects_list = schema.List( |
---|
227 | title = _(u'JAMB Subjects'), |
---|
228 | required = False, |
---|
229 | defaultFactory=list, |
---|
230 | value_type = schema.Choice( |
---|
231 | vocabulary = jambsubjects |
---|
232 | #source = JAMBSubjectSource(), |
---|
233 | ), |
---|
234 | ) |
---|
235 | jamb_score = schema.Int( |
---|
236 | title = _(u'Total JAMB Score'), |
---|
237 | required = False, |
---|
238 | ) |
---|
239 | #jamb_age = schema.Int( |
---|
240 | # title = _(u'Age (provided by JAMB)'), |
---|
241 | # required = False, |
---|
242 | # ) |
---|
243 | jamb_reg_number = schema.TextLine( |
---|
244 | title = _(u'JAMB Registration Number'), |
---|
245 | required = False, |
---|
246 | constraint=validate_jamb_reg_number, |
---|
247 | ) |
---|
248 | notice = schema.Text( |
---|
249 | title = _(u'Notice'), |
---|
250 | required = False, |
---|
251 | ) |
---|
252 | screening_venue = schema.TextLine( |
---|
253 | title = _(u'Screening Venue'), |
---|
254 | required = False, |
---|
255 | ) |
---|
256 | screening_date = schema.TextLine( |
---|
257 | title = _(u'Screening Date'), |
---|
258 | required = False, |
---|
259 | ) |
---|
260 | screening_score = schema.Int( |
---|
261 | title = _(u'Screening Score (%)'), |
---|
262 | required = False, |
---|
263 | ) |
---|
264 | aggregate = schema.Int( |
---|
265 | title = _(u'Aggregate Score (%)'), |
---|
266 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
267 | required = False, |
---|
268 | ) |
---|
269 | result_uploaded = schema.Bool( |
---|
270 | title = _(u'Result uploaded'), |
---|
271 | default = False, |
---|
272 | required = False, |
---|
273 | ) |
---|
274 | student_id = schema.TextLine( |
---|
275 | title = _(u'Student Id'), |
---|
276 | required = False, |
---|
277 | readonly = False, |
---|
278 | ) |
---|
279 | course_admitted = schema.Choice( |
---|
280 | title = _(u'Admitted Course of Study'), |
---|
281 | source = CertificateSource(), |
---|
282 | required = False, |
---|
283 | ) |
---|
284 | locked = schema.Bool( |
---|
285 | title = _(u'Form locked'), |
---|
286 | default = False, |
---|
287 | required = False, |
---|
288 | ) |
---|
289 | |
---|
290 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
291 | """A postgraduate applicant. |
---|
292 | |
---|
293 | This interface defines the least common multiple of all fields |
---|
294 | in pg application forms. In customized forms, fields can be excluded by |
---|
295 | adding them to the PG_OMIT* tuples. |
---|
296 | """ |
---|
297 | |
---|
298 | |
---|
299 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
300 | """An interface for both types of applicants. |
---|
301 | |
---|
302 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
303 | by ICustomPGApplicant field settings. If a field is defined |
---|
304 | in both interfaces zope.schema validates only against the |
---|
305 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
306 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
307 | """ |
---|
308 | |
---|
309 | def writeLogMessage(view, comment): |
---|
310 | """Adds an INFO message to the log file |
---|
311 | """ |
---|
312 | |
---|
313 | def createStudent(): |
---|
314 | """Create a student object from applicant data |
---|
315 | and copy applicant object. |
---|
316 | """ |
---|
317 | |
---|
318 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
319 | """An undergraduate applicant interface for edit forms. |
---|
320 | |
---|
321 | Here we can repeat the fields from base data and set the |
---|
322 | `required` and `readonly` attributes to True to further restrict |
---|
323 | the data access. Or we can allow only certain certificates to be |
---|
324 | selected by choosing the appropriate source. |
---|
325 | |
---|
326 | We cannot omit fields here. This has to be done in the |
---|
327 | respective form page. |
---|
328 | """ |
---|
329 | |
---|
330 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
331 | """A postgraduate applicant interface for editing. |
---|
332 | |
---|
333 | Here we can repeat the fields from base data and set the |
---|
334 | `required` and `readonly` attributes to True to further restrict |
---|
335 | the data access. Or we can allow only certain certificates to be |
---|
336 | selected by choosing the appropriate source. |
---|
337 | |
---|
338 | We cannot omit fields here. This has to be done in the |
---|
339 | respective form page. |
---|
340 | """ |
---|
341 | |
---|
342 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
343 | """An applicant payment via payment gateways. |
---|
344 | |
---|
345 | """ |
---|
346 | |
---|
347 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
348 | """An undergraduate applicant interface for editing. |
---|
349 | |
---|
350 | Here we can repeat the fields from base data and set the |
---|
351 | `required` and `readonly` attributes to True to further restrict |
---|
352 | the data access. Or we can allow only certain certificates to be |
---|
353 | selected by choosing the appropriate source. |
---|
354 | |
---|
355 | We cannot omit fields here. This has to be done in the |
---|
356 | respective form page. |
---|
357 | """ |
---|
358 | |
---|
359 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
360 | """Representation of an applicant. |
---|
361 | |
---|
362 | Skip regular reg_number validation if reg_number is used for finding |
---|
363 | the applicant object. |
---|
364 | """ |
---|