1 | ## $Id: interfaces.py 8071 2012-04-09 07:35:03Z 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 SimpleKofaVocabulary |
---|
27 | from waeup.kofa.students.vocabularies import nats_vocab |
---|
28 | from waeup.uniben.interfaces import lgas_vocab |
---|
29 | from waeup.uniben.interfaces import MessageFactory as _ |
---|
30 | |
---|
31 | high_qual = SimpleKofaVocabulary( |
---|
32 | ('National Certificate of Education','nce'), |
---|
33 | ('Pre Degree Programme','pre'), |
---|
34 | ('Diploma Programme','dip'), |
---|
35 | ('Ordinary National Diploma','ond'), |
---|
36 | ('Bachelors Degree','bd'), |
---|
37 | ('Masters Degree','md'), |
---|
38 | ('Professional Qualification','pq'), |
---|
39 | ('Other Certification','oc'), |
---|
40 | ('Higher National Diploma','hnd'), |
---|
41 | ('NCE AL OTH','nce_al_oth'), |
---|
42 | ('National Defence Academy','nda'), |
---|
43 | ('Awaiting Results','a_rslt'), |
---|
44 | ('RMC','rmc'), |
---|
45 | ) |
---|
46 | |
---|
47 | high_grade = SimpleKofaVocabulary( |
---|
48 | ('Upper Credit','upper_credit'), |
---|
49 | ('Distinction','distinction'), |
---|
50 | ('Credit','credit'), |
---|
51 | ('Merit','merit'), |
---|
52 | ('Lower Credit','lower_credit'), |
---|
53 | ('First Class','first_class'), |
---|
54 | ('Second Class Upper','second_class_upper'), |
---|
55 | ('Second Class Lower','second_class_lower'), |
---|
56 | ('Third Class','third_class'), |
---|
57 | ('Pass','pass'), |
---|
58 | ('Awaiting Results','a_rslt'), |
---|
59 | ('A Levels','al'), |
---|
60 | ) |
---|
61 | |
---|
62 | exam_types = SimpleKofaVocabulary( |
---|
63 | ('SSCE','ssce'), |
---|
64 | ('WAEC','waec'), |
---|
65 | ('GCE O\' LEVEL','gce_o_level'), |
---|
66 | ('TC II','tc_ii'), |
---|
67 | ('RSA','rsa'), |
---|
68 | ('NABTEB','nabteb'), |
---|
69 | ('NECO','neco'), |
---|
70 | ('ACE','ace'), |
---|
71 | ('GCE A\' LEVEL','gce_a_level'), |
---|
72 | ('IGCSE','igcse'), |
---|
73 | ) |
---|
74 | |
---|
75 | class IUGApplicant(IApplicantBaseData): |
---|
76 | """An undergraduate applicant. |
---|
77 | |
---|
78 | """ |
---|
79 | |
---|
80 | nationality = schema.Choice( |
---|
81 | source = nats_vocab, |
---|
82 | title = _(u'Nationality'), |
---|
83 | required = False, |
---|
84 | ) |
---|
85 | lga = schema.Choice( |
---|
86 | source = lgas_vocab, |
---|
87 | title = _(u'State/LGA (Nigerians only)'), |
---|
88 | required = False, |
---|
89 | ) |
---|
90 | |
---|
91 | # This ordering doesn't work properly. |
---|
92 | IUGApplicant[ |
---|
93 | 'nationality'].order = IApplicantBaseData['sex'].order |
---|
94 | IUGApplicant[ |
---|
95 | 'lga'].order = IUGApplicant['nationality'].order |
---|
96 | |
---|
97 | |
---|
98 | class IPGApplicant(IApplicantBaseData): |
---|
99 | """A postgraduate applicant. |
---|
100 | |
---|
101 | """ |
---|
102 | |
---|
103 | nationality = schema.Choice( |
---|
104 | source = nats_vocab, |
---|
105 | title = _(u'Nationality'), |
---|
106 | required = False, |
---|
107 | ) |
---|
108 | lga = schema.Choice( |
---|
109 | source = lgas_vocab, |
---|
110 | title = _(u'State/LGA (Nigerians only)'), |
---|
111 | required = False, |
---|
112 | ) |
---|
113 | perm_address = schema.Text( |
---|
114 | title = _(u'Permanent Address'), |
---|
115 | required = False, |
---|
116 | ) |
---|
117 | course1 = schema.Choice( |
---|
118 | title = _(u'1st Choice Course of Study'), |
---|
119 | source = AppCatCertificateSource(), |
---|
120 | required = True, |
---|
121 | ) |
---|
122 | course2 = schema.Choice( |
---|
123 | title = _(u'2nd Choice Course of Study'), |
---|
124 | source = AppCatCertificateSource(), |
---|
125 | required = False, |
---|
126 | ) |
---|
127 | hq_type = schema.Choice( |
---|
128 | title = _(u'Qualification Obtained'), |
---|
129 | required = False, |
---|
130 | readonly = False, |
---|
131 | vocabulary = high_qual, |
---|
132 | ) |
---|
133 | hq_matric_no = schema.TextLine( |
---|
134 | title = _(u'Former Matric Number'), |
---|
135 | required = False, |
---|
136 | readonly = False, |
---|
137 | ) |
---|
138 | hq_degree = schema.Choice( |
---|
139 | title = _(u'Class of Degree'), |
---|
140 | required = False, |
---|
141 | readonly = False, |
---|
142 | vocabulary = high_grade, |
---|
143 | ) |
---|
144 | hq_school = schema.TextLine( |
---|
145 | title = _(u'Institution Attended'), |
---|
146 | required = False, |
---|
147 | readonly = False, |
---|
148 | ) |
---|
149 | hq_session = schema.TextLine( |
---|
150 | title = _(u'Years Attended'), |
---|
151 | required = False, |
---|
152 | readonly = False, |
---|
153 | ) |
---|
154 | hq_disc = schema.TextLine( |
---|
155 | title = _(u'Discipline'), |
---|
156 | required = False, |
---|
157 | readonly = False, |
---|
158 | ) |
---|
159 | pp_school = schema.Choice( |
---|
160 | title = _(u'Qualification Obtained'), |
---|
161 | required = False, |
---|
162 | readonly = False, |
---|
163 | vocabulary = exam_types, |
---|
164 | ) |
---|
165 | employer = schema.TextLine( |
---|
166 | title = _(u'Employer'), |
---|
167 | required = False, |
---|
168 | readonly = False, |
---|
169 | ) |
---|
170 | emp_position = schema.TextLine( |
---|
171 | title = _(u'Employer Position'), |
---|
172 | required = False, |
---|
173 | readonly = False, |
---|
174 | ) |
---|
175 | emp_start = schema.Date( |
---|
176 | title = _(u'Start Date'), |
---|
177 | required = False, |
---|
178 | readonly = False, |
---|
179 | ) |
---|
180 | emp_end = schema.Date( |
---|
181 | title = _(u'End Date'), |
---|
182 | required = False, |
---|
183 | readonly = False, |
---|
184 | ) |
---|
185 | emp_reason = schema.TextLine( |
---|
186 | title = _(u'Reason for Leaving'), |
---|
187 | required = False, |
---|
188 | readonly = False, |
---|
189 | ) |
---|
190 | employer2 = schema.TextLine( |
---|
191 | title = _(u'2nd Employer'), |
---|
192 | required = False, |
---|
193 | readonly = False, |
---|
194 | ) |
---|
195 | emp2_position = schema.TextLine( |
---|
196 | title = _(u'2nd Employer Position'), |
---|
197 | required = False, |
---|
198 | readonly = False, |
---|
199 | ) |
---|
200 | emp2_start = schema.Date( |
---|
201 | title = _(u'Start Date'), |
---|
202 | required = False, |
---|
203 | readonly = False, |
---|
204 | ) |
---|
205 | emp2_end = schema.Date( |
---|
206 | title = _(u'End Date'), |
---|
207 | required = False, |
---|
208 | readonly = False, |
---|
209 | ) |
---|
210 | emp2_reason = schema.TextLine( |
---|
211 | title = _(u'Reason for Leaving'), |
---|
212 | required = False, |
---|
213 | readonly = False, |
---|
214 | ) |
---|
215 | notice = schema.Text( |
---|
216 | title = _(u'Notice'), |
---|
217 | required = False, |
---|
218 | readonly = False, |
---|
219 | ) |
---|
220 | screening_venue = schema.TextLine( |
---|
221 | title = _(u'Screening Venue'), |
---|
222 | required = False, |
---|
223 | readonly = False, |
---|
224 | ) |
---|
225 | screening_score = schema.Int( |
---|
226 | title = _(u'Screening Score'), |
---|
227 | required = False, |
---|
228 | readonly = False, |
---|
229 | ) |
---|
230 | course_admitted = schema.Choice( |
---|
231 | title = _(u'Admitted Course of Study'), |
---|
232 | source = CertificateSource(), |
---|
233 | required = False, |
---|
234 | readonly = False, |
---|
235 | ) |
---|
236 | |
---|
237 | |
---|
238 | # This ordering doesn't work properly. |
---|
239 | IPGApplicant[ |
---|
240 | 'nationality'].order = IApplicantBaseData['sex'].order |
---|
241 | IPGApplicant[ |
---|
242 | 'lga'].order = IPGApplicant['nationality'].order |
---|
243 | IPGApplicant[ |
---|
244 | 'student_id'].order = IPGApplicant['notice'].order |
---|
245 | |
---|
246 | |
---|
247 | class IApplicant(IUGApplicant,IPGApplicant): |
---|
248 | """An interface for both types of applicants. |
---|
249 | |
---|
250 | """ |
---|
251 | |
---|
252 | def loggerInfo(ob_class, comment): |
---|
253 | """Adds an INFO message to the log file |
---|
254 | """ |
---|
255 | |
---|
256 | def createStudent(): |
---|
257 | """Create a student object from applicatnt data |
---|
258 | and copy applicant object. |
---|
259 | """ |
---|
260 | |
---|
261 | class IUGApplicantEdit(IUGApplicant): |
---|
262 | """An undergraduate applicant interface for editing. |
---|
263 | |
---|
264 | Here we can repeat the fields from base data and set the |
---|
265 | `required` and `readonly` attributes to True to further restrict |
---|
266 | the data access. Or we can allow only certain certificates to be |
---|
267 | selected by choosing the appropriate source. |
---|
268 | |
---|
269 | We cannot omit fields here. This has to be done in the |
---|
270 | respective form page. |
---|
271 | """ |
---|
272 | |
---|
273 | class IPGApplicantEdit(IPGApplicant): |
---|
274 | """A postgraduate applicant interface for editing. |
---|
275 | |
---|
276 | Here we can repeat the fields from base data and set the |
---|
277 | `required` and `readonly` attributes to True to further restrict |
---|
278 | the data access. Or we can allow only certain certificates to be |
---|
279 | selected by choosing the appropriate source. |
---|
280 | |
---|
281 | We cannot omit fields here. This has to be done in the |
---|
282 | respective form page. |
---|
283 | """ |
---|