1 | ## $Id: interfaces.py 16273 2020-10-09 07:07:15Z 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 | # New fields |
---|
95 | |
---|
96 | perm_address = schema.Text( |
---|
97 | title = _(u'Home Address'), |
---|
98 | required = False, |
---|
99 | ) |
---|
100 | |
---|
101 | postal_address = schema.Text( |
---|
102 | title = _(u'Postal Address'), |
---|
103 | required = False, |
---|
104 | ) |
---|
105 | |
---|
106 | hostel_address = schema.Text( |
---|
107 | title = _(u'Hostel Address'), |
---|
108 | required = False, |
---|
109 | ) |
---|
110 | |
---|
111 | father_address = schema.Text( |
---|
112 | title = _(u'Father\'s Address'), |
---|
113 | required = False, |
---|
114 | ) |
---|
115 | |
---|
116 | mother_address = schema.Text( |
---|
117 | title = _(u'Mother\'s Address'), |
---|
118 | required = False, |
---|
119 | ) |
---|
120 | |
---|
121 | guardian_address = schema.Text( |
---|
122 | title = _(u'Guardian/Sponsor\'s Address'), |
---|
123 | required = False, |
---|
124 | ) |
---|
125 | |
---|
126 | father_phone = PhoneNumber( |
---|
127 | title = _(u'Father\'s Mobile Phone Number'), |
---|
128 | description = u'', |
---|
129 | required = False, |
---|
130 | readonly = False, |
---|
131 | ) |
---|
132 | |
---|
133 | mother_phone = PhoneNumber( |
---|
134 | title = _(u'Mother\'s Mobile Phone Number'), |
---|
135 | description = u'', |
---|
136 | required = False, |
---|
137 | readonly = False, |
---|
138 | ) |
---|
139 | |
---|
140 | guardian_phone = PhoneNumber( |
---|
141 | title = _(u'Guardian\'s Mobile Phone Number'), |
---|
142 | description = u'', |
---|
143 | required = False, |
---|
144 | readonly = False, |
---|
145 | ) |
---|
146 | |
---|
147 | marit_stat = schema.Choice( |
---|
148 | title = u'Marital Status', |
---|
149 | default = 'unmarried', |
---|
150 | required = False, |
---|
151 | vocabulary = SimpleKofaVocabulary( |
---|
152 | (_('Unmarried'), 'unmarried'), |
---|
153 | (_('Married'), 'married'),) |
---|
154 | ) |
---|
155 | |
---|
156 | religion = schema.Choice( |
---|
157 | title = u'Religion', |
---|
158 | default = 'no_say', |
---|
159 | required = False, |
---|
160 | vocabulary = SimpleKofaVocabulary( |
---|
161 | (_('Muslim'), 'muslim'), |
---|
162 | (_('Christian'), 'christian'), |
---|
163 | (_('Others'), 'others'), |
---|
164 | (_('Prefer not to say'), 'no_say'),) |
---|
165 | ) |
---|
166 | |
---|
167 | disabled = schema.Bool( |
---|
168 | title = u'Disabled', |
---|
169 | default = False, |
---|
170 | required = False, |
---|
171 | ) |
---|
172 | |
---|
173 | class ICustomStudentPersonalEdit(ICustomStudentPersonal): |
---|
174 | """Interface for editing personal data by students. |
---|
175 | |
---|
176 | Here we can repeat the fields from IStudentPersonal and set the |
---|
177 | `required` if necessary. |
---|
178 | """ |
---|
179 | |
---|
180 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
181 | """Representation of ug student clearance data. |
---|
182 | |
---|
183 | """ |
---|
184 | |
---|
185 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
186 | """Representation of pg student clearance data. |
---|
187 | |
---|
188 | """ |
---|
189 | |
---|
190 | |
---|
191 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
192 | ICustomPGStudentClearance, ICustomStudentPersonal): |
---|
193 | """Representation of a student. |
---|
194 | |
---|
195 | """ |
---|
196 | |
---|
197 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
198 | """A container for student study levels. |
---|
199 | |
---|
200 | """ |
---|
201 | |
---|
202 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
203 | """A container for course tickets. |
---|
204 | |
---|
205 | """ |
---|
206 | |
---|
207 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
208 | """A student payment via payment gateways. |
---|
209 | |
---|
210 | This Interface does not inherit from IStudentOnlinePayment. |
---|
211 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
212 | """ |
---|
213 | |
---|
214 | p_current = schema.Bool( |
---|
215 | title = _(u'Current Session Payment'), |
---|
216 | default = True, |
---|
217 | required = False, |
---|
218 | ) |
---|
219 | |
---|
220 | p_level = schema.Choice( |
---|
221 | title = _(u'Payment Level'), |
---|
222 | source = StudyLevelSource(), |
---|
223 | required = False, |
---|
224 | ) |
---|
225 | |
---|
226 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
227 | 'p_session'].order |
---|
228 | ICustomStudentOnlinePayment['provider_amt'].order = ICustomStudentOnlinePayment[ |
---|
229 | 'net_amt'].order |
---|
230 | |
---|
231 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
232 | """A course ticket. |
---|
233 | |
---|
234 | """ |
---|
235 | |
---|
236 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
237 | """Representation of a student. Skip regular reg_number validation. |
---|
238 | |
---|
239 | """ |
---|
240 | |
---|
241 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
242 | """Representation of a student. Skip regular matric_number validation. |
---|
243 | |
---|
244 | """ |
---|