1 | ## $Id: interfaces.py 17712 2024-03-08 11:04:44Z 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 | IKofaObject) |
---|
29 | from waeup.kofa.schema import FormattedDate, TextLineChoice, PhoneNumber |
---|
30 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
31 | from waeup.kofa.applicants.interfaces import ( |
---|
32 | contextual_reg_num_source, IApplicantBaseData, IApplicantOnlinePayment, |
---|
33 | IApplicantUpdateByRegNo) |
---|
34 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
35 | LGASource, high_qual, high_grade, exam_types, |
---|
36 | INigeriaApplicantOnlinePayment) |
---|
37 | from kofacustom.udss.interfaces import MessageFactory as _ |
---|
38 | from kofacustom.udss.payments.interfaces import ICustomOnlinePayment |
---|
39 | |
---|
40 | class ICustomUGApplicant(IKofaObject): |
---|
41 | """A pupil. |
---|
42 | |
---|
43 | """ |
---|
44 | |
---|
45 | suspended = schema.Bool( |
---|
46 | title = _(u'Account suspended'), |
---|
47 | default = False, |
---|
48 | required = False, |
---|
49 | ) |
---|
50 | |
---|
51 | applicant_id = schema.TextLine( |
---|
52 | title = _(u'Applicant Id'), |
---|
53 | required = False, |
---|
54 | readonly = False, |
---|
55 | ) |
---|
56 | |
---|
57 | reg_number = TextLineChoice( |
---|
58 | title = _(u'Registration Number'), |
---|
59 | readonly = False, |
---|
60 | required = False, |
---|
61 | source = contextual_reg_num_source, |
---|
62 | ) |
---|
63 | |
---|
64 | firstname = schema.TextLine( |
---|
65 | title = _(u'First Name'), |
---|
66 | required = True, |
---|
67 | ) |
---|
68 | |
---|
69 | middlename = schema.TextLine( |
---|
70 | title = _(u'Middle Name'), |
---|
71 | required = False, |
---|
72 | ) |
---|
73 | |
---|
74 | lastname = schema.TextLine( |
---|
75 | title = _(u'Last Name (Surname)'), |
---|
76 | required = True, |
---|
77 | ) |
---|
78 | |
---|
79 | date_of_birth = FormattedDate( |
---|
80 | title = _(u'Date of Birth'), |
---|
81 | required = False, |
---|
82 | show_year = True, |
---|
83 | ) |
---|
84 | |
---|
85 | sex = schema.Choice( |
---|
86 | title = _(u'Gender'), |
---|
87 | source = GenderSource(), |
---|
88 | required = True, |
---|
89 | ) |
---|
90 | nationality = schema.Choice( |
---|
91 | source = nats_vocab, |
---|
92 | title = _(u'Nationality'), |
---|
93 | required = False, |
---|
94 | ) |
---|
95 | religion = schema.Choice( |
---|
96 | title = u'Religion', |
---|
97 | default = 'no_say', |
---|
98 | required = False, |
---|
99 | vocabulary = SimpleKofaVocabulary( |
---|
100 | (_('Muslim'), 'muslim'), |
---|
101 | (_('Christian'), 'christian'), |
---|
102 | (_('Others'), 'others'), |
---|
103 | (_('Prefer not to say'), 'no_say'),) |
---|
104 | ) |
---|
105 | email = schema.ASCIILine( |
---|
106 | title = _(u'Email Address'), |
---|
107 | required = False, |
---|
108 | constraint=validate_email, |
---|
109 | ) |
---|
110 | phone = PhoneNumber( |
---|
111 | title = _(u'Phone'), |
---|
112 | description = u'', |
---|
113 | required = False, |
---|
114 | ) |
---|
115 | recent_schools_comment = schema.Text( |
---|
116 | title = _(u'Recent Schools Attended (with dates)'), |
---|
117 | required = False, |
---|
118 | ) |
---|
119 | present_class_comment = schema.Text( |
---|
120 | title = _(u'Child\'s Present Class'), |
---|
121 | description = u'Indicate the child\'s present class. Please attach a copy of the first term result of the present class. Children in Basic Four or less than 10yrs by October should not apply.', |
---|
122 | required = False, |
---|
123 | ) |
---|
124 | handicapped_comment = schema.Text( |
---|
125 | title = _(u'Health Problems'), |
---|
126 | description = u'Does the child has any special health problem or handicap? If yes, give details.', |
---|
127 | required = False, |
---|
128 | ) |
---|
129 | bloodgroup = schema.TextLine( |
---|
130 | title = _(u'Blood Group'), |
---|
131 | required = False, |
---|
132 | ) |
---|
133 | genotype = schema.TextLine( |
---|
134 | title = _(u'Genotype'), |
---|
135 | required = False, |
---|
136 | ) |
---|
137 | notice = schema.Text( |
---|
138 | title = _(u'Notice'), |
---|
139 | required = False, |
---|
140 | ) |
---|
141 | student_id = schema.TextLine( |
---|
142 | title = _(u'Student Id'), |
---|
143 | required = False, |
---|
144 | readonly = False, |
---|
145 | ) |
---|
146 | locked = schema.Bool( |
---|
147 | title = _(u'Form locked'), |
---|
148 | default = False, |
---|
149 | required = False, |
---|
150 | ) |
---|
151 | |
---|
152 | |
---|
153 | father_firstname = schema.TextLine( |
---|
154 | title = _(u'First Name of Father'), |
---|
155 | required = False, |
---|
156 | ) |
---|
157 | father_middlename = schema.TextLine( |
---|
158 | title = _(u'Middle Name of Father'), |
---|
159 | required = False, |
---|
160 | ) |
---|
161 | father_lastname = schema.TextLine( |
---|
162 | title = _(u'Last Name (Surname) of Father'), |
---|
163 | required = False, |
---|
164 | ) |
---|
165 | father_status = schema.TextLine( |
---|
166 | title = _(u'Father\'s Status and Rank'), |
---|
167 | required = False, |
---|
168 | ) |
---|
169 | father_employer = schema.TextLine( |
---|
170 | title = _(u'Father\'s Employer'), |
---|
171 | required = False, |
---|
172 | ) |
---|
173 | father_res_address = schema.Text( |
---|
174 | title = _(u'Father\'s Residential Address'), |
---|
175 | required = False, |
---|
176 | ) |
---|
177 | father_contact_address = schema.Text( |
---|
178 | title = _(u'Father\'s Contact Address (incl. P.O. Box)'), |
---|
179 | required = False, |
---|
180 | ) |
---|
181 | |
---|
182 | mother_firstname = schema.TextLine( |
---|
183 | title = _(u'First Name of Mother'), |
---|
184 | required = False, |
---|
185 | ) |
---|
186 | mother_middlename = schema.TextLine( |
---|
187 | title = _(u'Middle Name of Mother'), |
---|
188 | required = False, |
---|
189 | ) |
---|
190 | mother_lastname = schema.TextLine( |
---|
191 | title = _(u'Last Name (Surname) of Mother'), |
---|
192 | required = False, |
---|
193 | ) |
---|
194 | mother_status = schema.TextLine( |
---|
195 | title = _(u'Mother\'s Status and Rank'), |
---|
196 | required = False, |
---|
197 | ) |
---|
198 | mother_employer = schema.TextLine( |
---|
199 | title = _(u'Mother\'s Employer'), |
---|
200 | required = False, |
---|
201 | ) |
---|
202 | mother_res_address = schema.Text( |
---|
203 | title = _(u'Mother\'s Residential Address'), |
---|
204 | required = False, |
---|
205 | ) |
---|
206 | mother_contact_address = schema.Text( |
---|
207 | title = _(u'Mother\'s Contact Address (incl. P.O. Box)'), |
---|
208 | required = False, |
---|
209 | ) |
---|
210 | |
---|
211 | class ICustomApplicant(ICustomUGApplicant): |
---|
212 | """An interface for both types of applicants. |
---|
213 | |
---|
214 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
215 | by ICustomPGApplicant field settings. If a field is defined |
---|
216 | in both interfaces zope.schema validates only against the |
---|
217 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
218 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
219 | """ |
---|
220 | |
---|
221 | def writeLogMessage(view, comment): |
---|
222 | """Adds an INFO message to the log file |
---|
223 | """ |
---|
224 | |
---|
225 | def createStudent(): |
---|
226 | """Create a student object from applicant data |
---|
227 | and copy applicant object. |
---|
228 | """ |
---|
229 | |
---|
230 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
231 | """An undergraduate applicant interface for edit forms. |
---|
232 | |
---|
233 | Here we can repeat the fields from base data and set the |
---|
234 | `required` and `readonly` attributes to True to further restrict |
---|
235 | the data access. Or we can allow only certain certificates to be |
---|
236 | selected by choosing the appropriate source. |
---|
237 | |
---|
238 | We cannot omit fields here. This has to be done in the |
---|
239 | respective form page. |
---|
240 | """ |
---|
241 | |
---|
242 | email = schema.ASCIILine( |
---|
243 | title = _(u'Email Address'), |
---|
244 | required = True, |
---|
245 | constraint=validate_email, |
---|
246 | ) |
---|
247 | date_of_birth = FormattedDate( |
---|
248 | title = _(u'Date of Birth'), |
---|
249 | required = True, |
---|
250 | show_year = True, |
---|
251 | ) |
---|
252 | ICustomUGApplicantEdit[ |
---|
253 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
254 | ICustomUGApplicantEdit[ |
---|
255 | 'email'].order = ICustomUGApplicant['email'].order |
---|
256 | |
---|
257 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
258 | """An applicant payment via payment gateways. |
---|
259 | |
---|
260 | """ |
---|
261 | |
---|
262 | class ICustomApplicantUpdateByRegNo(IApplicantUpdateByRegNo): |
---|
263 | """Representation of an applicant. |
---|
264 | |
---|
265 | Skip regular reg_number validation if reg_number is used for finding |
---|
266 | the applicant object. |
---|
267 | """ |
---|