1 | ## $Id: interfaces.py 14084 2016-08-17 05:59:38Z henrik $ |
---|
2 | ## |
---|
3 | ## Copyright (C) 2012 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 | |
---|
19 | from zope import schema |
---|
20 | from zc.sourcefactory.contextual import BasicContextualSourceFactory |
---|
21 | from zope.catalog.interfaces import ICatalog |
---|
22 | from zope.component import getUtility |
---|
23 | from waeup.kofa.interfaces import (IKofaObject, academic_sessions_vocab) |
---|
24 | from waeup.kofa.students.vocabularies import ( |
---|
25 | StudyLevelSource, contextual_reg_num_source |
---|
26 | ) |
---|
27 | from waeup.kofa.schema import PhoneNumber, FormattedDate, TextLineChoice |
---|
28 | from kofacustom.nigeria.interfaces import LGASource |
---|
29 | from kofacustom.nigeria.students.interfaces import ( |
---|
30 | INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance, |
---|
31 | INigeriaStudentPersonal, INigeriaStudentStudyLevel, |
---|
32 | INigeriaStudentStudyCourse, INigeriaCourseTicket, |
---|
33 | INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo, |
---|
34 | ) |
---|
35 | from waeup.aaue.payments.interfaces import ICustomOnlinePayment |
---|
36 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
37 | |
---|
38 | class ICustomStudentBase(INigeriaStudentBase): |
---|
39 | """Representation of student base data. |
---|
40 | |
---|
41 | """ |
---|
42 | |
---|
43 | reg_number = TextLineChoice( |
---|
44 | title = _(u'JAMB Registration Number'), |
---|
45 | required = False, |
---|
46 | readonly = False, |
---|
47 | source = contextual_reg_num_source, |
---|
48 | ) |
---|
49 | |
---|
50 | application_number = schema.TextLine( |
---|
51 | title = _(u'Application Number'), |
---|
52 | required = False, |
---|
53 | readonly = False, |
---|
54 | ) |
---|
55 | |
---|
56 | ICustomStudentBase['reg_number'].order = INigeriaStudentBase[ |
---|
57 | 'reg_number'].order |
---|
58 | |
---|
59 | ICustomStudentBase['application_number'].order = ICustomStudentBase[ |
---|
60 | 'reg_number'].order |
---|
61 | |
---|
62 | |
---|
63 | class ICustomStudentPersonal(INigeriaStudentPersonal): |
---|
64 | """Student personal data. |
---|
65 | |
---|
66 | """ |
---|
67 | |
---|
68 | father_name = schema.TextLine( |
---|
69 | title = _(u'Father\'s Name'), |
---|
70 | required = False, |
---|
71 | readonly = False, |
---|
72 | ) |
---|
73 | |
---|
74 | father_address = schema.Text( |
---|
75 | title = _(u'Father\'s Permanent Address'), |
---|
76 | required = False, |
---|
77 | readonly = False, |
---|
78 | ) |
---|
79 | |
---|
80 | father_work = schema.TextLine( |
---|
81 | title = _(u'Father\'s Place of Work'), |
---|
82 | required = False, |
---|
83 | readonly = False, |
---|
84 | ) |
---|
85 | |
---|
86 | father_phone = PhoneNumber( |
---|
87 | title = _(u'Father\'s Phone'), |
---|
88 | required = False, |
---|
89 | readonly = False, |
---|
90 | ) |
---|
91 | |
---|
92 | mother_name = schema.TextLine( |
---|
93 | title = _(u'Mother\'s Name'), |
---|
94 | required = False, |
---|
95 | readonly = False, |
---|
96 | ) |
---|
97 | |
---|
98 | mother_address = schema.Text( |
---|
99 | title = _(u'Mother\'s Permanent Address'), |
---|
100 | required = False, |
---|
101 | readonly = False, |
---|
102 | ) |
---|
103 | |
---|
104 | mother_work = schema.TextLine( |
---|
105 | title = _(u'Mother\'s Place of Work'), |
---|
106 | required = False, |
---|
107 | readonly = False, |
---|
108 | ) |
---|
109 | |
---|
110 | mother_phone = PhoneNumber( |
---|
111 | title = _(u'Mother\'s Phone'), |
---|
112 | required = False, |
---|
113 | readonly = False, |
---|
114 | ) |
---|
115 | |
---|
116 | phone_personal = PhoneNumber( |
---|
117 | title = _(u'Student\'s Personal Phone'), |
---|
118 | description = u'', |
---|
119 | required = False, |
---|
120 | readonly = False, |
---|
121 | ) |
---|
122 | |
---|
123 | class ICustomStudentPersonalEdit(ICustomStudentPersonal): |
---|
124 | """Interface for editing personal data by students. |
---|
125 | |
---|
126 | Here we can repeat the fields from IStudentPersonal and set the |
---|
127 | `required` if necessary. |
---|
128 | """ |
---|
129 | |
---|
130 | perm_address = schema.Text( |
---|
131 | title = _(u'Permanent Address'), |
---|
132 | required = True, |
---|
133 | ) |
---|
134 | |
---|
135 | next_kin_name = schema.TextLine( |
---|
136 | title = _(u'Next of Kin Name'), |
---|
137 | required = True, |
---|
138 | readonly = False, |
---|
139 | ) |
---|
140 | |
---|
141 | next_kin_relation = schema.TextLine( |
---|
142 | title = _(u'Next of Kin Relationship'), |
---|
143 | required = True, |
---|
144 | readonly = False, |
---|
145 | ) |
---|
146 | |
---|
147 | next_kin_address = schema.Text( |
---|
148 | title = _(u'Next of Kin Address'), |
---|
149 | required = True, |
---|
150 | readonly = False, |
---|
151 | ) |
---|
152 | |
---|
153 | next_kin_phone = PhoneNumber( |
---|
154 | title = _(u'Next of Kin Phone'), |
---|
155 | description = u'', |
---|
156 | required = True, |
---|
157 | readonly = False, |
---|
158 | ) |
---|
159 | |
---|
160 | father_name = schema.TextLine( |
---|
161 | title = _(u'Father\'s Name'), |
---|
162 | required = True, |
---|
163 | readonly = False, |
---|
164 | ) |
---|
165 | |
---|
166 | father_address = schema.Text( |
---|
167 | title = _(u'Father\'s Permanent Address'), |
---|
168 | required = True, |
---|
169 | readonly = False, |
---|
170 | ) |
---|
171 | |
---|
172 | father_work = schema.TextLine( |
---|
173 | title = _(u'Father\'s Place of Work'), |
---|
174 | required = True, |
---|
175 | readonly = False, |
---|
176 | ) |
---|
177 | |
---|
178 | father_phone = PhoneNumber( |
---|
179 | title = _(u'Father\'s Phone'), |
---|
180 | required = True, |
---|
181 | readonly = False, |
---|
182 | ) |
---|
183 | |
---|
184 | mother_name = schema.TextLine( |
---|
185 | title = _(u'Mother\'s Name'), |
---|
186 | required = True, |
---|
187 | readonly = False, |
---|
188 | ) |
---|
189 | |
---|
190 | mother_address = schema.Text( |
---|
191 | title = _(u'Mother\'s Permanent Address'), |
---|
192 | required = True, |
---|
193 | readonly = False, |
---|
194 | ) |
---|
195 | |
---|
196 | mother_work = schema.TextLine( |
---|
197 | title = _(u'Mother\'s Place of Work'), |
---|
198 | required = True, |
---|
199 | readonly = False, |
---|
200 | ) |
---|
201 | |
---|
202 | mother_phone = PhoneNumber( |
---|
203 | title = _(u'Mother\'s Phone'), |
---|
204 | required = True, |
---|
205 | readonly = False, |
---|
206 | ) |
---|
207 | |
---|
208 | phone_personal = PhoneNumber( |
---|
209 | title = _(u'Student\'s Personal Phone'), |
---|
210 | description = u'', |
---|
211 | required = True, |
---|
212 | readonly = False, |
---|
213 | ) |
---|
214 | |
---|
215 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
216 | """Representation of ug student clearance data. |
---|
217 | |
---|
218 | """ |
---|
219 | |
---|
220 | #date_of_birth = FormattedDate( |
---|
221 | # title = _(u'Date of Birth'), |
---|
222 | # required = True, |
---|
223 | # show_year = True, |
---|
224 | # ) |
---|
225 | |
---|
226 | lga = schema.Choice( |
---|
227 | source = LGASource(), |
---|
228 | title = _(u'State / LGA'), |
---|
229 | required = True, |
---|
230 | ) |
---|
231 | |
---|
232 | sc_pin = schema.TextLine( |
---|
233 | title = _(u'Scratch Card Pin'), |
---|
234 | required = False, |
---|
235 | readonly = False, |
---|
236 | ) |
---|
237 | |
---|
238 | sc_serial_number = schema.TextLine( |
---|
239 | title = _(u'Scratch Card Serial Number'), |
---|
240 | required = False, |
---|
241 | readonly = False, |
---|
242 | ) |
---|
243 | |
---|
244 | ICustomUGStudentClearance['lga'].order = INigeriaUGStudentClearance[ |
---|
245 | 'lga'].order |
---|
246 | #ICustomUGStudentClearance['date_of_birth'].order = INigeriaUGStudentClearance[ |
---|
247 | # 'date_of_birth'].order |
---|
248 | ICustomUGStudentClearance['sc_pin'].order = INigeriaUGStudentClearance[ |
---|
249 | 'fst_sit_fname'].order |
---|
250 | ICustomUGStudentClearance['sc_serial_number'].order = ICustomUGStudentClearance[ |
---|
251 | 'fst_sit_fname'].order |
---|
252 | |
---|
253 | |
---|
254 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
255 | """Representation of pg student clearance data. |
---|
256 | |
---|
257 | """ |
---|
258 | |
---|
259 | |
---|
260 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
261 | ICustomPGStudentClearance,ICustomStudentPersonal): |
---|
262 | """Representation of a student. |
---|
263 | |
---|
264 | """ |
---|
265 | |
---|
266 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
267 | """A container for student study levels. |
---|
268 | |
---|
269 | """ |
---|
270 | |
---|
271 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
272 | """A container for course tickets. |
---|
273 | |
---|
274 | """ |
---|
275 | |
---|
276 | total_credits_s1 = schema.Int( |
---|
277 | title = _(u'1st Semester Units'), |
---|
278 | required = False, |
---|
279 | readonly = True, |
---|
280 | ) |
---|
281 | |
---|
282 | total_credits_s2 = schema.Int( |
---|
283 | title = _(u'2nd Semester Units'), |
---|
284 | required = False, |
---|
285 | readonly = True, |
---|
286 | ) |
---|
287 | |
---|
288 | total_credits = schema.Int( |
---|
289 | title = _(u'Total Units'), |
---|
290 | required = False, |
---|
291 | readonly = True, |
---|
292 | ) |
---|
293 | |
---|
294 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
295 | """A student payment via payment gateways. |
---|
296 | |
---|
297 | This Interface does not inherit from IStudentOnlinePayment. |
---|
298 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
299 | """ |
---|
300 | |
---|
301 | p_current = schema.Bool( |
---|
302 | title = _(u'Current Session Payment'), |
---|
303 | default = True, |
---|
304 | required = False, |
---|
305 | ) |
---|
306 | |
---|
307 | p_level = schema.Choice( |
---|
308 | title = _(u'Payment Level'), |
---|
309 | source = StudyLevelSource(), |
---|
310 | required = False, |
---|
311 | ) |
---|
312 | |
---|
313 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
314 | 'p_session'].order |
---|
315 | |
---|
316 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
317 | """A course ticket. |
---|
318 | |
---|
319 | """ |
---|
320 | |
---|
321 | ca = schema.Int( |
---|
322 | title = _(u'CA'), |
---|
323 | default = None, |
---|
324 | required = False, |
---|
325 | missing_value = None, |
---|
326 | ) |
---|
327 | |
---|
328 | class ICustomCourseTicketImport(ICustomCourseTicket): |
---|
329 | """An interface for importing course results and nothing more. |
---|
330 | """ |
---|
331 | score = schema.Int( |
---|
332 | title = _(u'Score'), |
---|
333 | required = False, |
---|
334 | readonly = False, |
---|
335 | ) |
---|
336 | |
---|
337 | ca = schema.Int( |
---|
338 | title = _(u'CA'), |
---|
339 | required = False, |
---|
340 | readonly = False, |
---|
341 | ) |
---|
342 | |
---|
343 | level_session = schema.Choice( |
---|
344 | title = _(u'Level Session'), |
---|
345 | source = academic_sessions_vocab, |
---|
346 | required = False, |
---|
347 | readonly = False, |
---|
348 | ) |
---|
349 | |
---|
350 | ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order |
---|
351 | |
---|
352 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
353 | """Representation of a student. Skip regular reg_number validation. |
---|
354 | |
---|
355 | """ |
---|
356 | |
---|
357 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
358 | """Representation of a student. Skip regular matric_number validation. |
---|
359 | |
---|
360 | """ |
---|