1 | ## $Id: interfaces.py 10500 2013-08-14 12:28: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 |
---|
29 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
30 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
31 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
32 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
33 | LGASource, high_qual, high_grade, exam_types, |
---|
34 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
35 | INigeriaApplicantOnlinePayment, |
---|
36 | INigeriaUGApplicantEdit, |
---|
37 | INigeriaApplicantUpdateByRegNo, |
---|
38 | IPUTMEApplicantEdit, |
---|
39 | OMIT_DISPLAY_FIELDS |
---|
40 | ) |
---|
41 | from waeup.fceokene.interfaces import MessageFactory as _ |
---|
42 | |
---|
43 | BEC_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS |
---|
44 | BEC_OMIT_PDF_FIELDS = BEC_OMIT_DISPLAY_FIELDS + ('phone',) |
---|
45 | BEC_OMIT_MANAGE_FIELDS = () |
---|
46 | BEC_OMIT_EDIT_FIELDS = BEC_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + ( |
---|
47 | 'student_id', 'notice', |
---|
48 | 'screening_score', |
---|
49 | 'screening_venue', |
---|
50 | 'screening_date', |
---|
51 | #'jamb_subjects', |
---|
52 | #'jamb_score', |
---|
53 | 'aggregate') |
---|
54 | |
---|
55 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
56 | """An undergraduate applicant. |
---|
57 | |
---|
58 | This interface defines the least common multiple of all fields |
---|
59 | in ug application forms. In customized forms, fields can be excluded by |
---|
60 | adding them to the OMIT* tuples. |
---|
61 | """ |
---|
62 | |
---|
63 | nationality = schema.Choice( |
---|
64 | source = nats_vocab, |
---|
65 | title = _(u'Nationality'), |
---|
66 | required = True, |
---|
67 | ) |
---|
68 | lga = schema.Choice( |
---|
69 | source = LGASource(), |
---|
70 | title = _(u'State/LGA (Nigerians only)'), |
---|
71 | required = False, |
---|
72 | ) |
---|
73 | #perm_address = schema.Text( |
---|
74 | # title = _(u'Permanent Address'), |
---|
75 | # required = False, |
---|
76 | # ) |
---|
77 | course1 = schema.Choice( |
---|
78 | title = _(u'1st Choice Course of Study'), |
---|
79 | source = AppCatCertificateSource(), |
---|
80 | required = True, |
---|
81 | ) |
---|
82 | course2 = schema.Choice( |
---|
83 | title = _(u'2nd Choice Course of Study'), |
---|
84 | source = AppCatCertificateSource(), |
---|
85 | required = False, |
---|
86 | ) |
---|
87 | olevel_type = schema.Choice( |
---|
88 | title = _(u'1st Qualification Obtained'), |
---|
89 | required = False, |
---|
90 | readonly = False, |
---|
91 | vocabulary = exam_types, |
---|
92 | ) |
---|
93 | olevel_school = schema.TextLine( |
---|
94 | title = _(u'1st Institution Attended'), |
---|
95 | required = False, |
---|
96 | readonly = False, |
---|
97 | ) |
---|
98 | olevel_exam_number = schema.TextLine( |
---|
99 | title = _(u'1st Exam Number'), |
---|
100 | required = False, |
---|
101 | readonly = False, |
---|
102 | ) |
---|
103 | olevel_exam_date = FormattedDate( |
---|
104 | title = _(u'1st Exam Date'), |
---|
105 | required = False, |
---|
106 | readonly = False, |
---|
107 | show_year = True, |
---|
108 | ) |
---|
109 | olevel_results = schema.List( |
---|
110 | title = _(u'1st Exam Results'), |
---|
111 | value_type = ResultEntryField(), |
---|
112 | required = False, |
---|
113 | readonly = False, |
---|
114 | default = [], |
---|
115 | ) |
---|
116 | olevel_type2 = schema.Choice( |
---|
117 | title = _(u'2nd Qualification Obtained'), |
---|
118 | required = False, |
---|
119 | readonly = False, |
---|
120 | vocabulary = exam_types, |
---|
121 | ) |
---|
122 | olevel_school2 = schema.TextLine( |
---|
123 | title = _(u'2nd Institution Attended'), |
---|
124 | required = False, |
---|
125 | readonly = False, |
---|
126 | ) |
---|
127 | olevel_exam_number2 = schema.TextLine( |
---|
128 | title = _(u'2nd Exam Number'), |
---|
129 | required = False, |
---|
130 | readonly = False, |
---|
131 | ) |
---|
132 | olevel_exam_date2 = FormattedDate( |
---|
133 | title = _(u'2nd Exam Date'), |
---|
134 | required = False, |
---|
135 | readonly = False, |
---|
136 | show_year = True, |
---|
137 | ) |
---|
138 | olevel_results2 = schema.List( |
---|
139 | title = _(u'2nd Exam Results'), |
---|
140 | value_type = ResultEntryField(), |
---|
141 | required = False, |
---|
142 | readonly = False, |
---|
143 | default = [], |
---|
144 | ) |
---|
145 | hq_type = schema.Choice( |
---|
146 | title = _(u'Qualification Obtained'), |
---|
147 | required = False, |
---|
148 | readonly = False, |
---|
149 | vocabulary = high_qual, |
---|
150 | ) |
---|
151 | hq_matric_no = schema.TextLine( |
---|
152 | title = _(u'Former Matric Number'), |
---|
153 | required = False, |
---|
154 | readonly = False, |
---|
155 | ) |
---|
156 | hq_degree = schema.Choice( |
---|
157 | title = _(u'Class of Degree'), |
---|
158 | required = False, |
---|
159 | readonly = False, |
---|
160 | vocabulary = high_grade, |
---|
161 | ) |
---|
162 | hq_school = schema.TextLine( |
---|
163 | title = _(u'Institution Attended'), |
---|
164 | required = False, |
---|
165 | readonly = False, |
---|
166 | ) |
---|
167 | hq_session = schema.TextLine( |
---|
168 | title = _(u'Years Attended'), |
---|
169 | required = False, |
---|
170 | readonly = False, |
---|
171 | ) |
---|
172 | hq_disc = schema.TextLine( |
---|
173 | title = _(u'Discipline'), |
---|
174 | required = False, |
---|
175 | readonly = False, |
---|
176 | ) |
---|
177 | jamb_subjects = schema.Text( |
---|
178 | title = _(u'Subjects and Scores'), |
---|
179 | required = False, |
---|
180 | ) |
---|
181 | jamb_score = schema.Int( |
---|
182 | title = _(u'Total JAMB Score'), |
---|
183 | required = False, |
---|
184 | ) |
---|
185 | jamb_reg_number = schema.TextLine( |
---|
186 | title = _(u'JAMB Registration Number'), |
---|
187 | required = False, |
---|
188 | ) |
---|
189 | notice = schema.Text( |
---|
190 | title = _(u'Notice'), |
---|
191 | required = False, |
---|
192 | ) |
---|
193 | screening_venue = schema.TextLine( |
---|
194 | title = _(u'Screening Venue'), |
---|
195 | required = False, |
---|
196 | ) |
---|
197 | screening_date = schema.TextLine( |
---|
198 | title = _(u'Screening Date'), |
---|
199 | required = False, |
---|
200 | ) |
---|
201 | screening_score = schema.Int( |
---|
202 | title = _(u'Screening Score (%)'), |
---|
203 | required = False, |
---|
204 | ) |
---|
205 | aggregate = schema.Int( |
---|
206 | title = _(u'Aggregate Score (%)'), |
---|
207 | description = _(u'(average of relative JAMB and PUTME scores)'), |
---|
208 | required = False, |
---|
209 | ) |
---|
210 | result_uploaded = schema.Bool( |
---|
211 | title = _(u'Result uploaded'), |
---|
212 | default = False, |
---|
213 | ) |
---|
214 | student_id = schema.TextLine( |
---|
215 | title = _(u'Student Id'), |
---|
216 | required = False, |
---|
217 | readonly = False, |
---|
218 | ) |
---|
219 | course_admitted = schema.Choice( |
---|
220 | title = _(u'Admitted Course of Study'), |
---|
221 | source = CertificateSource(), |
---|
222 | required = False, |
---|
223 | ) |
---|
224 | locked = schema.Bool( |
---|
225 | title = _(u'Form locked'), |
---|
226 | default = False, |
---|
227 | ) |
---|
228 | |
---|
229 | |
---|
230 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
231 | """A postgraduate applicant. |
---|
232 | |
---|
233 | This interface defines the least common multiple of all fields |
---|
234 | in pg application forms. In customized forms, fields can be excluded by |
---|
235 | adding them to the PG_OMIT* tuples. |
---|
236 | """ |
---|
237 | |
---|
238 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
239 | """An interface for both types of applicants. |
---|
240 | |
---|
241 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
242 | by ICustomPGApplicant field settings. If a field is defined |
---|
243 | in both interfaces zope.schema validates only against the |
---|
244 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
245 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
246 | """ |
---|
247 | |
---|
248 | def writeLogMessage(view, comment): |
---|
249 | """Adds an INFO message to the log file |
---|
250 | """ |
---|
251 | |
---|
252 | def createStudent(): |
---|
253 | """Create a student object from applicatnt data |
---|
254 | and copy applicant object. |
---|
255 | """ |
---|
256 | |
---|
257 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
258 | """An undergraduate applicant interface for edit forms. |
---|
259 | |
---|
260 | Here we can repeat the fields from base data and set the |
---|
261 | `required` and `readonly` attributes to True to further restrict |
---|
262 | the data access. Or we can allow only certain certificates to be |
---|
263 | selected by choosing the appropriate source. |
---|
264 | |
---|
265 | We cannot omit fields here. This has to be done in the |
---|
266 | respective form page. |
---|
267 | """ |
---|
268 | |
---|
269 | |
---|
270 | email = schema.ASCIILine( |
---|
271 | title = _(u'Email Address'), |
---|
272 | required = True, |
---|
273 | constraint=validate_email, |
---|
274 | ) |
---|
275 | date_of_birth = FormattedDate( |
---|
276 | title = _(u'Date of Birth'), |
---|
277 | required = True, |
---|
278 | show_year = True, |
---|
279 | ) |
---|
280 | |
---|
281 | ICustomUGApplicantEdit[ |
---|
282 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
283 | ICustomUGApplicantEdit[ |
---|
284 | 'email'].order = ICustomUGApplicant['email'].order |
---|
285 | ICustomUGApplicantEdit[ |
---|
286 | 'jamb_reg_number'].order = ICustomUGApplicant['reg_number'].order |
---|
287 | |
---|
288 | class ICustomPGApplicantEdit(ICustomPGApplicant): |
---|
289 | """A postgraduate applicant interface for editing. |
---|
290 | |
---|
291 | Here we can repeat the fields from base data and set the |
---|
292 | `required` and `readonly` attributes to True to further restrict |
---|
293 | the data access. Or we can allow only certain certificates to be |
---|
294 | selected by choosing the appropriate source. |
---|
295 | |
---|
296 | We cannot omit fields here. This has to be done in the |
---|
297 | respective form page. |
---|
298 | """ |
---|
299 | |
---|
300 | email = schema.ASCIILine( |
---|
301 | title = _(u'Email Address'), |
---|
302 | required = True, |
---|
303 | constraint=validate_email, |
---|
304 | ) |
---|
305 | date_of_birth = FormattedDate( |
---|
306 | title = _(u'Date of Birth'), |
---|
307 | required = True, |
---|
308 | show_year = True, |
---|
309 | ) |
---|
310 | |
---|
311 | ICustomPGApplicantEdit[ |
---|
312 | 'date_of_birth'].order = ICustomPGApplicant['date_of_birth'].order |
---|
313 | ICustomPGApplicantEdit[ |
---|
314 | 'email'].order = ICustomPGApplicant['email'].order |
---|
315 | |
---|
316 | |
---|
317 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
318 | """An applicant payment via payment gateways. |
---|
319 | |
---|
320 | """ |
---|
321 | |
---|
322 | class IPUTMEApplicantEdit(IPUTMEApplicantEdit): |
---|
323 | """An undergraduate applicant interface for editing. |
---|
324 | |
---|
325 | Here we can repeat the fields from base data and set the |
---|
326 | `required` and `readonly` attributes to True to further restrict |
---|
327 | the data access. Or we can allow only certain certificates to be |
---|
328 | selected by choosing the appropriate source. |
---|
329 | |
---|
330 | We cannot omit fields here. This has to be done in the |
---|
331 | respective form page. |
---|
332 | """ |
---|
333 | |
---|
334 | class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo): |
---|
335 | """Representation of an applicant. |
---|
336 | |
---|
337 | Skip regular reg_number validation if reg_number is used for finding |
---|
338 | the applicant object. |
---|
339 | """ |
---|
340 | |
---|