1 | ## $Id: interfaces.py 16511 2021-06-17 15:20:46Z 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 zope.interface import Attribute, invariant, Invalid |
---|
21 | from waeup.kofa.students.vocabularies import StudyLevelSource |
---|
22 | from waeup.kofa.interfaces import validate_email, SimpleKofaVocabulary |
---|
23 | from waeup.kofa.students.interfaces import IStudentPersonal |
---|
24 | from waeup.kofa.schema import FormattedDate, PhoneNumber |
---|
25 | from kofacustom.nigeria.students.interfaces import ( |
---|
26 | INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance, |
---|
27 | INigeriaStudentPersonal, INigeriaStudentStudyLevel, |
---|
28 | INigeriaStudentStudyCourse, INigeriaCourseTicket, |
---|
29 | INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo, |
---|
30 | ) |
---|
31 | from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment |
---|
32 | from kofacustom.iuokada.applicants.interfaces import sponsors_vocab |
---|
33 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
34 | |
---|
35 | class ICustomStudentBase(INigeriaStudentBase): |
---|
36 | """Representation of student base data. |
---|
37 | |
---|
38 | """ |
---|
39 | |
---|
40 | email2 = schema.ASCIILine( |
---|
41 | title = _(u'Second Email'), |
---|
42 | required = False, |
---|
43 | constraint=validate_email, |
---|
44 | ) |
---|
45 | |
---|
46 | library = schema.Bool( |
---|
47 | title = _(u'Library Id Card'), |
---|
48 | default = False, |
---|
49 | required = False, |
---|
50 | ) |
---|
51 | sponsor = schema.Choice( |
---|
52 | title = _(u'Sponsor'), |
---|
53 | vocabulary = sponsors_vocab, |
---|
54 | required = False, |
---|
55 | ) |
---|
56 | |
---|
57 | ICustomStudentBase['email2'].order = ICustomStudentBase[ |
---|
58 | 'phone'].order |
---|
59 | ICustomStudentBase['phone'].order = ICustomStudentBase[ |
---|
60 | 'email'].order |
---|
61 | |
---|
62 | class ICustomStudentPersonal(IStudentPersonal): |
---|
63 | """Student personal/bio data. |
---|
64 | |
---|
65 | """ |
---|
66 | |
---|
67 | is_foreigner = Attribute('True if student is non-Nigerian') |
---|
68 | |
---|
69 | # Duplicated fields from the ICustomStudentBase |
---|
70 | |
---|
71 | email = schema.ASCIILine( |
---|
72 | title = _(u'Email'), |
---|
73 | required = False, |
---|
74 | constraint=validate_email, |
---|
75 | ) |
---|
76 | |
---|
77 | email2 = schema.ASCIILine( |
---|
78 | title = _(u'Second Email'), |
---|
79 | required = False, |
---|
80 | constraint=validate_email, |
---|
81 | ) |
---|
82 | |
---|
83 | phone = PhoneNumber( |
---|
84 | title = _(u'Phone'), |
---|
85 | required = False, |
---|
86 | ) |
---|
87 | |
---|
88 | parents_email = schema.ASCIILine( |
---|
89 | title = _(u"Parents' Email"), |
---|
90 | required = False, |
---|
91 | constraint=validate_email, |
---|
92 | ) |
---|
93 | |
---|
94 | sponsor = schema.Choice( |
---|
95 | title = _(u'Sponsor'), |
---|
96 | vocabulary = sponsors_vocab, |
---|
97 | required = False, |
---|
98 | ) |
---|
99 | |
---|
100 | # New fields |
---|
101 | |
---|
102 | perm_address = schema.Text( |
---|
103 | title = _(u'Home Address'), |
---|
104 | required = False, |
---|
105 | ) |
---|
106 | |
---|
107 | postal_address = schema.Text( |
---|
108 | title = _(u'Postal Address'), |
---|
109 | required = False, |
---|
110 | ) |
---|
111 | |
---|
112 | hostel_address = schema.Text( |
---|
113 | title = _(u'Hostel Address'), |
---|
114 | required = False, |
---|
115 | ) |
---|
116 | |
---|
117 | father_address = schema.Text( |
---|
118 | title = _(u'Father\'s Address'), |
---|
119 | required = False, |
---|
120 | ) |
---|
121 | |
---|
122 | mother_address = schema.Text( |
---|
123 | title = _(u'Mother\'s Address'), |
---|
124 | required = False, |
---|
125 | ) |
---|
126 | |
---|
127 | guardian_address = schema.Text( |
---|
128 | title = _(u'Guardian/Sponsor\'s Address'), |
---|
129 | required = False, |
---|
130 | ) |
---|
131 | |
---|
132 | father_phone = PhoneNumber( |
---|
133 | title = _(u'Father\'s Mobile Phone Number'), |
---|
134 | description = u'', |
---|
135 | required = False, |
---|
136 | ) |
---|
137 | |
---|
138 | mother_phone = PhoneNumber( |
---|
139 | title = _(u'Mother\'s Mobile Phone Number'), |
---|
140 | description = u'', |
---|
141 | required = False, |
---|
142 | ) |
---|
143 | |
---|
144 | guardian_phone = PhoneNumber( |
---|
145 | title = _(u'Guardian\'s Mobile Phone Number'), |
---|
146 | description = u'', |
---|
147 | required = False, |
---|
148 | ) |
---|
149 | |
---|
150 | marit_stat = schema.Choice( |
---|
151 | title = u'Marital Status', |
---|
152 | default = 'unmarried', |
---|
153 | required = False, |
---|
154 | vocabulary = SimpleKofaVocabulary( |
---|
155 | (_('Unmarried'), 'unmarried'), |
---|
156 | (_('Married'), 'married'),) |
---|
157 | ) |
---|
158 | |
---|
159 | religion = schema.Choice( |
---|
160 | title = u'Religion', |
---|
161 | default = 'no_say', |
---|
162 | required = False, |
---|
163 | vocabulary = SimpleKofaVocabulary( |
---|
164 | (_('Muslim'), 'muslim'), |
---|
165 | (_('Christian'), 'christian'), |
---|
166 | (_('Others'), 'others'), |
---|
167 | (_('Prefer not to say'), 'no_say'),) |
---|
168 | ) |
---|
169 | |
---|
170 | disabled = schema.Bool( |
---|
171 | title = u'Disabled', |
---|
172 | default = False, |
---|
173 | required = False, |
---|
174 | ) |
---|
175 | |
---|
176 | class ICustomStudentPersonalEdit(ICustomStudentPersonal): |
---|
177 | """Interface for editing personal data by students. |
---|
178 | |
---|
179 | Here we can repeat the fields from IStudentPersonal and set the |
---|
180 | `required` if necessary. |
---|
181 | """ |
---|
182 | |
---|
183 | # Duplicated fields from the ICustomStudentPersonal: |
---|
184 | # All fields are required! |
---|
185 | |
---|
186 | email = schema.ASCIILine( |
---|
187 | title = _(u'Email'), |
---|
188 | required = True, |
---|
189 | constraint=validate_email, |
---|
190 | ) |
---|
191 | |
---|
192 | email2 = schema.ASCIILine( |
---|
193 | title = _(u'Second Email'), |
---|
194 | required = True, |
---|
195 | constraint=validate_email, |
---|
196 | ) |
---|
197 | |
---|
198 | phone = PhoneNumber( |
---|
199 | title = _(u'Phone'), |
---|
200 | required = True, |
---|
201 | ) |
---|
202 | |
---|
203 | parents_email = schema.ASCIILine( |
---|
204 | title = _(u"Parents' Email"), |
---|
205 | required = True, |
---|
206 | constraint=validate_email, |
---|
207 | ) |
---|
208 | |
---|
209 | sponsor = schema.Choice( |
---|
210 | title = _(u'Sponsor'), |
---|
211 | vocabulary = sponsors_vocab, |
---|
212 | required = True, |
---|
213 | ) |
---|
214 | |
---|
215 | # New fields |
---|
216 | |
---|
217 | perm_address = schema.Text( |
---|
218 | title = _(u'Home Address'), |
---|
219 | required = True, |
---|
220 | ) |
---|
221 | |
---|
222 | postal_address = schema.Text( |
---|
223 | title = _(u'Postal Address'), |
---|
224 | required = True, |
---|
225 | ) |
---|
226 | |
---|
227 | hostel_address = schema.Text( |
---|
228 | title = _(u'Hostel Address'), |
---|
229 | required = True, |
---|
230 | ) |
---|
231 | |
---|
232 | father_address = schema.Text( |
---|
233 | title = _(u'Father\'s Address'), |
---|
234 | required = True, |
---|
235 | ) |
---|
236 | |
---|
237 | mother_address = schema.Text( |
---|
238 | title = _(u'Mother\'s Address'), |
---|
239 | required = True, |
---|
240 | ) |
---|
241 | |
---|
242 | guardian_address = schema.Text( |
---|
243 | title = _(u'Guardian/Sponsor\'s Address'), |
---|
244 | required = True, |
---|
245 | ) |
---|
246 | |
---|
247 | father_phone = PhoneNumber( |
---|
248 | title = _(u'Father\'s Mobile Phone Number'), |
---|
249 | description = u'', |
---|
250 | required = True, |
---|
251 | ) |
---|
252 | |
---|
253 | mother_phone = PhoneNumber( |
---|
254 | title = _(u'Mother\'s Mobile Phone Number'), |
---|
255 | description = u'', |
---|
256 | required = True, |
---|
257 | ) |
---|
258 | |
---|
259 | guardian_phone = PhoneNumber( |
---|
260 | title = _(u'Guardian\'s Mobile Phone Number'), |
---|
261 | description = u'', |
---|
262 | required = True, |
---|
263 | ) |
---|
264 | |
---|
265 | marit_stat = schema.Choice( |
---|
266 | title = u'Marital Status', |
---|
267 | default = 'unmarried', |
---|
268 | required = True, |
---|
269 | vocabulary = SimpleKofaVocabulary( |
---|
270 | (_('Unmarried'), 'unmarried'), |
---|
271 | (_('Married'), 'married'),) |
---|
272 | ) |
---|
273 | |
---|
274 | religion = schema.Choice( |
---|
275 | title = u'Religion', |
---|
276 | default = 'no_say', |
---|
277 | required = True, |
---|
278 | vocabulary = SimpleKofaVocabulary( |
---|
279 | (_('Muslim'), 'muslim'), |
---|
280 | (_('Christian'), 'christian'), |
---|
281 | (_('Others'), 'others'), |
---|
282 | (_('Prefer not to say'), 'no_say'),) |
---|
283 | ) |
---|
284 | |
---|
285 | disabled = schema.Bool( |
---|
286 | title = u'Disabled', |
---|
287 | default = False, |
---|
288 | required = True, |
---|
289 | ) |
---|
290 | |
---|
291 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
292 | """Representation of ug student clearance data. |
---|
293 | |
---|
294 | """ |
---|
295 | |
---|
296 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
297 | """Representation of pg student clearance data. |
---|
298 | |
---|
299 | """ |
---|
300 | |
---|
301 | |
---|
302 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
303 | ICustomPGStudentClearance, ICustomStudentPersonal): |
---|
304 | """Representation of a student. |
---|
305 | |
---|
306 | """ |
---|
307 | |
---|
308 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
309 | """A container for student study levels. |
---|
310 | |
---|
311 | """ |
---|
312 | |
---|
313 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
314 | """A container for course tickets. |
---|
315 | |
---|
316 | """ |
---|
317 | |
---|
318 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
319 | """A student payment via payment gateways. |
---|
320 | |
---|
321 | This Interface does not inherit from IStudentOnlinePayment. |
---|
322 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
323 | """ |
---|
324 | |
---|
325 | p_current = schema.Bool( |
---|
326 | title = _(u'Current Session Payment'), |
---|
327 | default = True, |
---|
328 | required = False, |
---|
329 | ) |
---|
330 | |
---|
331 | p_level = schema.Choice( |
---|
332 | title = _(u'Payment Level'), |
---|
333 | source = StudyLevelSource(), |
---|
334 | required = False, |
---|
335 | ) |
---|
336 | |
---|
337 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
338 | 'p_session'].order |
---|
339 | ICustomStudentOnlinePayment['provider_amt'].order = ICustomStudentOnlinePayment[ |
---|
340 | 'net_amt'].order |
---|
341 | |
---|
342 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
343 | """A course ticket. |
---|
344 | |
---|
345 | """ |
---|
346 | |
---|
347 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
348 | """Representation of a student. Skip regular reg_number validation. |
---|
349 | |
---|
350 | """ |
---|
351 | |
---|
352 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
353 | """Representation of a student. Skip regular matric_number validation. |
---|
354 | |
---|
355 | """ |
---|