1 | ## $Id: interfaces.py 15838 2019-11-21 14:10:27Z 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 ( |
---|
31 | contextual_reg_num_source, IApplicantBaseData) |
---|
32 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
33 | LGASource, high_qual, high_grade, exam_types, DisabilitiesSource, |
---|
34 | programme_types_vocab, jambsubjects, validate_jamb_reg_number, |
---|
35 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
36 | INigeriaApplicantOnlinePayment, |
---|
37 | INigeriaUGApplicantEdit, INigeriaPGApplicantEdit, |
---|
38 | INigeriaApplicantUpdateByRegNo, |
---|
39 | IPUTMEApplicantEdit, |
---|
40 | ) |
---|
41 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
42 | from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment |
---|
43 | |
---|
44 | sponsors_vocab = SimpleKofaVocabulary( |
---|
45 | (_('Bauchi Government'), 'bauchi'), |
---|
46 | (_('Company'), 'company'), |
---|
47 | (_('Federal Government (Amnesty)'), 'federalgov'), |
---|
48 | (_('Dangote Group'), 'dangote'), |
---|
49 | (_('Kano Government'), 'kano'), |
---|
50 | (_('Parent/Guardian'), 'parent'), |
---|
51 | (_('Rosula Organization'), 'rosula'), |
---|
52 | (_('Self'), 'self'), |
---|
53 | (_('Social Impact Project'), 'social'), |
---|
54 | ) |
---|
55 | |
---|
56 | heard_about_types_vocab = SimpleKofaVocabulary( |
---|
57 | (_('Facebook/Twitter/Other Social Media'), 'socmedia'), |
---|
58 | (_('From a Friend'), 'friend'), |
---|
59 | (_('Newspaper Advertisement'), 'newspaper'), |
---|
60 | (_('Radio Advertisement'), 'radio'), |
---|
61 | (_('Television Advertisement'), 'television'), |
---|
62 | ) |
---|
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 | |
---|
72 | disabilities = schema.Choice( |
---|
73 | title = _(u'Disability'), |
---|
74 | source = DisabilitiesSource(), |
---|
75 | required = False, |
---|
76 | ) |
---|
77 | nationality = schema.Choice( |
---|
78 | source = nats_vocab, |
---|
79 | title = _(u'Nationality'), |
---|
80 | required = False, |
---|
81 | ) |
---|
82 | lga = schema.Choice( |
---|
83 | source = LGASource(), |
---|
84 | title = _(u'State/LGA (Nigerians only)'), |
---|
85 | required = False, |
---|
86 | ) |
---|
87 | #perm_address = schema.Text( |
---|
88 | # title = _(u'Permanent Address'), |
---|
89 | # required = False, |
---|
90 | # ) |
---|
91 | course1 = schema.Choice( |
---|
92 | title = _(u'1st Choice Course of Study'), |
---|
93 | source = AppCatCertificateSource(), |
---|
94 | required = True, |
---|
95 | ) |
---|
96 | course2 = schema.Choice( |
---|
97 | title = _(u'2nd Choice Course of Study'), |
---|
98 | source = AppCatCertificateSource(), |
---|
99 | required = False, |
---|
100 | ) |
---|
101 | programme_type = schema.Choice( |
---|
102 | title = _(u'Programme Type'), |
---|
103 | vocabulary = programme_types_vocab, |
---|
104 | required = False, |
---|
105 | ) |
---|
106 | sponsor = schema.Choice( |
---|
107 | title = _(u'Sponsor'), |
---|
108 | vocabulary = sponsors_vocab, |
---|
109 | required = False, |
---|
110 | ) |
---|
111 | heard_about = schema.Choice( |
---|
112 | title = _(u'How did you hear about IU?'), |
---|
113 | vocabulary = heard_about_types_vocab, |
---|
114 | required = False, |
---|
115 | ) |
---|
116 | fst_sit_fname = schema.TextLine( |
---|
117 | title = _(u'Full Name'), |
---|
118 | required = False, |
---|
119 | readonly = False, |
---|
120 | ) |
---|
121 | fst_sit_no = schema.TextLine( |
---|
122 | title = _(u'Exam Number'), |
---|
123 | required = False, |
---|
124 | readonly = False, |
---|
125 | ) |
---|
126 | fst_sit_date = FormattedDate( |
---|
127 | title = _(u'Exam Date'), |
---|
128 | required = False, |
---|
129 | readonly = False, |
---|
130 | show_year = True, |
---|
131 | ) |
---|
132 | fst_sit_type = schema.Choice( |
---|
133 | title = _(u'Exam Type'), |
---|
134 | required = False, |
---|
135 | readonly = False, |
---|
136 | vocabulary = exam_types, |
---|
137 | ) |
---|
138 | fst_sit_results = schema.List( |
---|
139 | title = _(u'Exam Results'), |
---|
140 | value_type = ResultEntryField(), |
---|
141 | required = False, |
---|
142 | readonly = False, |
---|
143 | defaultFactory=list, |
---|
144 | ) |
---|
145 | scd_sit_fname = schema.TextLine( |
---|
146 | title = _(u'Full Name'), |
---|
147 | required = False, |
---|
148 | readonly = False, |
---|
149 | ) |
---|
150 | scd_sit_no = schema.TextLine( |
---|
151 | title = _(u'Exam Number'), |
---|
152 | required = False, |
---|
153 | readonly = False, |
---|
154 | ) |
---|
155 | scd_sit_date = FormattedDate( |
---|
156 | title = _(u'Exam Date'), |
---|
157 | required = False, |
---|
158 | readonly = False, |
---|
159 | show_year = True, |
---|
160 | ) |
---|
161 | scd_sit_type = schema.Choice( |
---|
162 | title = _(u'Exam Type'), |
---|
163 | required = False, |
---|
164 | readonly = False, |
---|
165 | vocabulary = exam_types, |
---|
166 | ) |
---|
167 | scd_sit_results = schema.List( |
---|
168 | title = _(u'Exam Results'), |
---|
169 | value_type = ResultEntryField(), |
---|
170 | required = False, |
---|
171 | readonly = False, |
---|
172 | defaultFactory=list, |
---|
173 | ) |
---|
174 | jamb_subjects = schema.Text( |
---|
175 | title = _(u'Subjects and Scores'), |
---|
176 | required = False, |
---|
177 | ) |
---|
178 | jamb_subjects_list = schema.List( |
---|
179 | title = _(u'JAMB Subjects'), |
---|
180 | required = False, |
---|
181 | defaultFactory=list, |
---|
182 | value_type = schema.Choice( |
---|
183 | vocabulary = jambsubjects |
---|
184 | #source = JAMBSubjectSource(), |
---|
185 | ), |
---|
186 | ) |
---|
187 | jamb_score = schema.Int( |
---|
188 | title = _(u'Total JAMB Score'), |
---|
189 | required = False, |
---|
190 | ) |
---|
191 | #jamb_age = schema.Int( |
---|
192 | # title = _(u'Age (provided by JAMB)'), |
---|
193 | # required = False, |
---|
194 | # ) |
---|
195 | jamb_reg_number = schema.TextLine( |
---|
196 | title = _(u'JAMB Registration Number'), |
---|
197 | required = False, |
---|
198 | constraint=validate_jamb_reg_number, |
---|
199 | ) |
---|
200 | notice = schema.Text( |
---|
201 | title = _(u'Notice'), |
---|
202 | required = False, |
---|
203 | ) |
---|
204 | screening_venue = schema.TextLine( |
---|
205 | title = _(u'Screening Venue'), |
---|
206 | required = False, |
---|
207 | ) |
---|
208 | screening_date = schema.TextLine( |
---|
209 | title = _(u'Screening Date'), |
---|
210 | required = False, |
---|
211 | ) |
---|
212 | screening_score = schema.Int( |
---|
213 | title = _(u'Screening Score (%)'), |
---|
214 | required = False, |
---|
215 | ) |
---|
216 | aggregate = schema.Int( |
---|
217 | title = _(u'Aggregate Score (%)'), |
---|
218 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
219 | required = False, |
---|
220 | ) |
---|
221 | result_uploaded = schema.Bool( |
---|
222 | title = _(u'Result uploaded'), |
---|
223 | default = False, |
---|
224 | required = False, |
---|
225 | ) |
---|
226 | student_id = schema.TextLine( |
---|
227 | title = _(u'Student Id'), |
---|
228 | required = False, |
---|
229 | readonly = False, |
---|
230 | ) |
---|
231 | course_admitted = schema.Choice( |
---|
232 | title = _(u'Admitted Course of Study'), |
---|
233 | source = CertificateSource(), |
---|
234 | required = False, |
---|
235 | ) |
---|
236 | locked = schema.Bool( |
---|
237 | title = _(u'Form locked'), |
---|
238 | default = False, |
---|
239 | required = False, |
---|
240 | ) |
---|
241 | |
---|
242 | ICustomUGApplicant[ |
---|
243 | 'locked'].order = ICustomUGApplicant['suspended'].order |
---|
244 | ICustomUGApplicant[ |
---|
245 | 'result_uploaded'].order = ICustomUGApplicant['suspended'].order |
---|
246 | |
---|
247 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
248 | """A postgraduate applicant. |
---|
249 | |
---|
250 | This interface defines the least common multiple of all fields |
---|
251 | in pg application forms. In customized forms, fields can be excluded by |
---|
252 | adding them to the PG_OMIT* tuples. |
---|
253 | """ |
---|
254 | |
---|
255 | sponsor = schema.Choice( |
---|
256 | title = _(u'Sponsor'), |
---|
257 | vocabulary = sponsors_vocab, |
---|
258 | required = False, |
---|
259 | ) |
---|
260 | |
---|
261 | heard_about = schema.Choice( |
---|
262 | title = _(u'How did you hear about IU?'), |
---|
263 | vocabulary = heard_about_types_vocab, |
---|
264 | required = False, |
---|
265 | ) |
---|
266 | |
---|
267 | ICustomPGApplicant[ |
---|
268 | 'sponsor'].order = ICustomPGApplicant['lga'].order |
---|
269 | ICustomPGApplicant[ |
---|
270 | 'heard_about'].order = ICustomPGApplicant['lga'].order |
---|
271 | ICustomPGApplicant[ |
---|
272 | 'sponsor'].order = ICustomPGApplicant['lga'].order |
---|
273 | ICustomPGApplicant[ |
---|
274 | 'lga'].order = ICustomPGApplicant['nationality'].order |
---|
275 | |
---|
276 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
277 | """An interface for both types of applicants. |
---|
278 | |
---|
279 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
280 | by ICustomPGApplicant field settings. If a field is defined |
---|
281 | in both interfaces zope.schema validates only against the |
---|
282 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
283 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
284 | """ |
---|
285 | |
---|
286 | def writeLogMessage(view, comment): |
---|
287 | """Adds an INFO message to the log file |
---|
288 | """ |
---|
289 | |
---|
290 | def createStudent(): |
---|
291 | """Create a student object from applicant data |
---|
292 | and copy applicant object. |
---|
293 | """ |
---|
294 | |
---|
295 | class ICustomUGApplicantEdit(INigeriaUGApplicantEdit): |
---|
296 | """An undergraduate applicant interface for edit forms. |
---|
297 | |
---|
298 | Here we can repeat the fields from base data and set the |
---|
299 | `required` and `readonly` attributes to True to further restrict |
---|
300 | the data access. Or we can allow only certain certificates to be |
---|
301 | selected by choosing the appropriate source. |
---|
302 | |
---|
303 | We cannot omit fields here. This has to be done in the |
---|
304 | respective form page. |
---|
305 | """ |
---|
306 | |
---|
307 | class ICustomPGApplicantEdit(INigeriaPGApplicantEdit): |
---|
308 | """A postgraduate applicant interface for editing. |
---|
309 | |
---|
310 | Here we can repeat the fields from base data and set the |
---|
311 | `required` and `readonly` attributes to True to further restrict |
---|
312 | the data access. Or we can allow only certain certificates to be |
---|
313 | selected by choosing the appropriate source. |
---|
314 | |
---|
315 | We cannot omit fields here. This has to be done in the |
---|
316 | respective form page. |
---|
317 | """ |
---|
318 | |
---|
319 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
320 | """An applicant payment via payment gateways. |
---|
321 | |
---|
322 | """ |
---|
323 | |
---|
324 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
325 | """An undergraduate applicant interface for editing. |
---|
326 | |
---|
327 | Here we can repeat the fields from base data and set the |
---|
328 | `required` and `readonly` attributes to True to further restrict |
---|
329 | the data access. Or we can allow only certain certificates to be |
---|
330 | selected by choosing the appropriate source. |
---|
331 | |
---|
332 | We cannot omit fields here. This has to be done in the |
---|
333 | respective form page. |
---|
334 | """ |
---|
335 | |
---|
336 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
337 | """Representation of an applicant. |
---|
338 | |
---|
339 | Skip regular reg_number validation if reg_number is used for finding |
---|
340 | the applicant object. |
---|
341 | """ |
---|