1 | ## $Id: utils.py 16830 2022-02-23 11:14:31Z 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 | """Customize general helper utilities for Kofa. |
---|
19 | """ |
---|
20 | |
---|
21 | import string |
---|
22 | import grok |
---|
23 | from kofacustom.nigeria.utils.utils import NigeriaKofaUtils |
---|
24 | from waeup.kofa.students.workflow import ALUMNI_STATES |
---|
25 | |
---|
26 | class CustomKofaUtils(NigeriaKofaUtils): |
---|
27 | """A collection of methods subject to customization. |
---|
28 | """ |
---|
29 | |
---|
30 | PREFERRED_LANGUAGES_DICT = { |
---|
31 | } |
---|
32 | |
---|
33 | COURSE_CATEGORY_DICT = { |
---|
34 | 'C':'Core Course (C)', |
---|
35 | 'R':'Required Courses (R)', |
---|
36 | 'E':'Elective Courses (E)', |
---|
37 | } |
---|
38 | |
---|
39 | PAYMENT_CATEGORIES = { |
---|
40 | 'schoolfee': 'School Fee', |
---|
41 | 'schoolfee_1': 'School Fee Plus (1st instalment)', |
---|
42 | 'schoolfee_2': 'School Fee (2nd instalment)', |
---|
43 | 'schoolfee_incl': 'School Fee Plus', |
---|
44 | 'clearance': 'Acceptance Fee', |
---|
45 | 'clearance_incl': 'Acceptance Fee Plus', |
---|
46 | 'hostel_maintenance': 'Hostel Accommodation Fee', |
---|
47 | 'application': 'Application Fee', |
---|
48 | 'app_balance': 'Application Fee Balance', |
---|
49 | 'bed_allocation': 'Bed Allocation Fee', |
---|
50 | 'transfer': 'Transfer Fee', |
---|
51 | 'transcript_local': 'Local Transcript Fee', |
---|
52 | 'transcript_inter': 'International Transcript Fee', |
---|
53 | 'late_registration': 'Late Course Registration Fee', |
---|
54 | 'welfare': 'Student Welfare Assurance Fee', |
---|
55 | 'union': 'Student Union Dues', |
---|
56 | 'lapel': 'Lapel/File Fee', |
---|
57 | 'matric_gown': 'Matriculation Gown Fee', |
---|
58 | 'concessional': 'Concessional Fee', |
---|
59 | 'id_card': 'Student ID Card', |
---|
60 | 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', |
---|
61 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
---|
62 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
---|
63 | 'gst_text_book_3': 'Text Book Fee GST222', |
---|
64 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
---|
65 | 'gst_registration_2': 'Registration Fee GST222', |
---|
66 | 'ent_text_book_1': 'Text Book Fee ENT201', |
---|
67 | 'ent_text_book_2': 'Text Book Fee ENT211', |
---|
68 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
---|
69 | 'ent_registration_1': 'Registration Fee ENT201', |
---|
70 | 'ent_registration_2': 'Registration Fee ENT211', |
---|
71 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
---|
72 | 'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211', |
---|
73 | 'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', |
---|
74 | 'ict': 'ICT/Affidavit Dues', |
---|
75 | 'affidavit': 'Affidavit Dues', |
---|
76 | 'restitution': 'Restitution Fee', |
---|
77 | 'sports': 'Sports Fee', |
---|
78 | 'library': 'UG Library Fee', |
---|
79 | 'library_pg': 'PG Library Fee', |
---|
80 | 'sports_library': 'Sports Development and Library Fee', |
---|
81 | 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', |
---|
82 | 'lab_2': 'Laboratory Due (BIO101/BIO111)', |
---|
83 | } |
---|
84 | |
---|
85 | SELECTABLE_PAYMENT_CATEGORIES = { |
---|
86 | 'schoolfee': 'School Fee without additional fees', |
---|
87 | 'schoolfee_1': 'School Fee (1st instalment) incl. additional fees', |
---|
88 | 'schoolfee_2': 'School Fee (2nd instalment)', |
---|
89 | 'schoolfee_incl': 'School Fee incl. additional fees', |
---|
90 | 'clearance': 'Acceptance Fee without additional fees', |
---|
91 | 'clearance_incl': 'Acceptance Fee incl. additional fees', |
---|
92 | 'hostel_maintenance': 'Hostel Accommodation Fee', |
---|
93 | #'application': 'Application Fee', |
---|
94 | #'bed_allocation': 'Bed Allocation Fee', |
---|
95 | #'transfer': 'Transfer Fee', |
---|
96 | 'transcript_local': 'Local Transcript Fee', |
---|
97 | 'transcript_inter': 'International Transcript Fee', |
---|
98 | 'late_registration': 'Late Course Registration Fee', |
---|
99 | #'welfare': 'Student Welfare Assurance Fee', |
---|
100 | #'union': 'Student Union Dues', |
---|
101 | #'lapel': 'Lapel/File Fee', |
---|
102 | #'matric_gown': 'Matriculation Gown Fee', |
---|
103 | 'concessional': 'Concessional Fee', |
---|
104 | #'id_card': 'Student ID Card', |
---|
105 | 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', |
---|
106 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
---|
107 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
---|
108 | 'gst_text_book_3': 'Text Book Fee GST222', |
---|
109 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
---|
110 | 'gst_registration_2': 'Registration Fee GST222', |
---|
111 | 'ent_text_book_1': 'Text Book Fee ENT201', |
---|
112 | 'ent_text_book_2': 'Text Book Fee ENT211', |
---|
113 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
---|
114 | 'ent_registration_1': 'Registration Fee ENT201', |
---|
115 | 'ent_registration_2': 'Registration Fee ENT211', |
---|
116 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
---|
117 | 'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211', |
---|
118 | #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', |
---|
119 | 'ict': 'ICT/Affidavit Dues', |
---|
120 | #'affidavit': 'Affidavit Dues', |
---|
121 | 'restitution': 'Restitution Fee', |
---|
122 | 'sports': 'Sports Fee', |
---|
123 | 'library': 'UG Library Fee', |
---|
124 | 'library_pg': 'PG Library Fee', |
---|
125 | 'sports_library': 'Sports Development and Library Fee', |
---|
126 | 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', |
---|
127 | 'lab_2': 'Laboratory Due (BIO101/BIO111)', |
---|
128 | } |
---|
129 | |
---|
130 | ALUMNI_PAYMENT_CATS = { |
---|
131 | 'transcript_local': 'Transcript Fee Local', |
---|
132 | 'transcript_inter': 'Transcript Fee International', |
---|
133 | } |
---|
134 | |
---|
135 | REDUCED_PAYMENT_CATS = { |
---|
136 | 'clearance': 'Acceptance Fee', |
---|
137 | 'schoolfee': 'School Fee', |
---|
138 | 'late_registration': 'Late Course Registration Fee', |
---|
139 | 'sports': 'Sports Fee', |
---|
140 | 'library': 'UG Library Fee', |
---|
141 | 'library_pg': 'PG Library Fee', |
---|
142 | 'sports_library': 'Sports Development and Library Fee', |
---|
143 | } |
---|
144 | |
---|
145 | IJMBE_PAYMENT_CATS = { |
---|
146 | 'clearance': 'Acceptance Fee', |
---|
147 | 'schoolfee': 'School Fee', |
---|
148 | 'schoolfee_1': 'School Fee (1st instalment)', |
---|
149 | 'schoolfee_2': 'School Fee (2nd instalment)', |
---|
150 | 'sports': 'Sports Fee', |
---|
151 | 'library': 'UG Library Fee', |
---|
152 | 'library_pg': 'PG Library Fee', |
---|
153 | 'sports_library': 'Sports Development and Library Fee', |
---|
154 | } |
---|
155 | |
---|
156 | PT_AND_DSH_PAYMENT_CATS = { |
---|
157 | 'clearance_incl': 'Acceptance Fee Plus', |
---|
158 | 'schoolfee_incl': 'School Fee Plus', |
---|
159 | 'ent_text_book_1': 'Text Book Fee ENT201', |
---|
160 | 'ent_text_book_2': 'Text Book Fee ENT211', |
---|
161 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
---|
162 | 'ent_registration_1': 'Registration Fee ENT201', |
---|
163 | 'ent_registration_2': 'Registration Fee ENT211', |
---|
164 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
---|
165 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
---|
166 | 'gst_registration_2': 'Registration Fee GST222', |
---|
167 | 'gst_text_book_0': 'Text Book Fee GST101 GST102 GST111 GST112', |
---|
168 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
---|
169 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
---|
170 | 'gst_text_book_3': 'Text Book Fee GST222', |
---|
171 | 'ent_combined': 'Registration and Textbook Fee for ENT201 and ENT211', |
---|
172 | 'late_registration': 'Late Course Registration Fee', |
---|
173 | 'sports': 'Sports Fee', |
---|
174 | 'library': 'UG Library Fee', |
---|
175 | 'library_pg': 'PG Library Fee', |
---|
176 | 'sports_library': 'Sports Development and Library Fee', |
---|
177 | 'lab_1': 'Faculty Laboratory Due (CHM102/PHY103/CSC101)', |
---|
178 | 'lab_2': 'Laboratory Due (BIO101/BIO111)', |
---|
179 | } |
---|
180 | |
---|
181 | def selectable_payment_categories(self, student): |
---|
182 | if student.state in ALUMNI_STATES: |
---|
183 | return self.ALUMNI_PAYMENT_CATS |
---|
184 | if student.current_mode in ( |
---|
185 | 'special_pg_ft', 'special_pg_pt', 'found', 'bridge'): |
---|
186 | return self.REDUCED_PAYMENT_CATS |
---|
187 | if student.current_mode in ( |
---|
188 | 'ug_pt', 'de_pt','dp_pt', 'de_dsh', 'ug_dsh'): |
---|
189 | return self.PT_AND_DSH_PAYMENT_CATS |
---|
190 | if student.current_mode == 'ijmbe': |
---|
191 | return self.IJMBE_PAYMENT_CATS |
---|
192 | return self.SELECTABLE_PAYMENT_CATEGORIES |
---|
193 | |
---|
194 | REPORTABLE_PAYMENT_CATEGORIES = { |
---|
195 | 'schoolfee': 'School Fee', |
---|
196 | 'schoolfee_incl': 'School Fee Plus', |
---|
197 | 'schoolfee_1': 'School Fee 1 Plus', |
---|
198 | 'schoolfee_2': 'School Fee 2', |
---|
199 | 'clearance': 'Acceptance Fee', |
---|
200 | 'clearance_incl': 'Acceptance Fee Plus', |
---|
201 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
202 | } |
---|
203 | |
---|
204 | BALANCE_PAYMENT_CATEGORIES = { |
---|
205 | 'schoolfee': 'School Fee', |
---|
206 | 'clearance': 'Acceptance Fee', |
---|
207 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
208 | 'late_registration': 'Late Course Registration Fee', |
---|
209 | 'welfare': 'Student Welfare Assurance Fee', |
---|
210 | 'union': 'Student Union Dues', |
---|
211 | 'lapel': 'Lapel/File Fee', |
---|
212 | 'matric_gown': 'Matriculation Gown Fee', |
---|
213 | 'id_card': 'Student ID Card', |
---|
214 | 'gst_text_book_1': 'Text Book Fee GST101 GST102', |
---|
215 | 'gst_text_book_2': 'Text Book Fee GST111 GST112', |
---|
216 | 'gst_text_book_3': 'Text Book Fee GST222', |
---|
217 | 'gst_registration_1': 'Registration Fee GST101 GST102 GST111 GST112', |
---|
218 | 'gst_registration_2': 'Registration Fee GST222', |
---|
219 | 'ent_text_book_1': 'Text Book Fee ENT201', |
---|
220 | 'ent_text_book_2': 'Text Book Fee ENT211', |
---|
221 | 'ent_text_book_0': 'Text Book Fee for ENT201 and ENT211', |
---|
222 | 'ent_registration_1': 'Registration Fee ENT201', |
---|
223 | 'ent_registration_2': 'Registration Fee ENT211', |
---|
224 | 'ent_registration_0': 'Registration Fee for ENT201 and ENT211', |
---|
225 | #'fac_dep': 'Faculty and Departmental Dues (incl. ICT/Affidavit Dues)', |
---|
226 | 'ict': 'ICT/Affidavit Dues', |
---|
227 | #'affidavit': 'Affidavit Dues', |
---|
228 | 'restitution': 'Restitution Fee', |
---|
229 | } |
---|
230 | |
---|
231 | PREVIOUS_PAYMENT_CATEGORIES = { |
---|
232 | 'schoolfee': 'School Fee', |
---|
233 | 'clearance': 'Acceptance Fee', |
---|
234 | 'late_registration': 'Late Course Registration Fee', |
---|
235 | } |
---|
236 | |
---|
237 | APP_CATS_DICT = { |
---|
238 | 'basic': 'PUTME, PUDE, PCE, PRENCE', |
---|
239 | 'no': 'No Application', |
---|
240 | 'pg_ft': 'Postgraduate Full-Time', |
---|
241 | 'pg_pt': 'Postgraduate Part-Time', |
---|
242 | 'cest': 'Part-Time, Diploma, Certificate', |
---|
243 | 'found': 'Foundation', |
---|
244 | 'ptee': 'Part-Time Entrance Examination', |
---|
245 | 'ioe_dp': 'Institute of Education Diploma', |
---|
246 | 'ijmbe': 'IJMBE Preparation', |
---|
247 | 'bridge': 'Bridge', |
---|
248 | 'dsh': 'Science and Humanities', |
---|
249 | |
---|
250 | } |
---|
251 | |
---|
252 | STUDY_MODES_DICT = { |
---|
253 | 'ug_ft': 'Undergraduate Full Time', |
---|
254 | 'ug_pt': 'Undergraduate Part Time', |
---|
255 | 'de_ft': 'Direct Entry Full Time', |
---|
256 | 'de_pt': 'Direct Entry Part Time', |
---|
257 | 'dp_pt': 'Diploma Part Time', |
---|
258 | 'dp_ft': 'Diploma Full Time', |
---|
259 | 'special_pg_ft': 'Postgraduate Full Time', |
---|
260 | 'special_pg_pt': 'Postgraduate Part Time', |
---|
261 | 'found': 'Foundation', |
---|
262 | 'transfer': 'Transfer', |
---|
263 | 'transferred': 'Transferred', |
---|
264 | 'mug_ft': 'Undergraduate Full Time Merit List', |
---|
265 | 'mde_ft': 'Direct Entry Full Time Merit List', |
---|
266 | 'ijmbe': 'IJMBE Preparation', |
---|
267 | 'bridge': 'Bridge', |
---|
268 | 'ug_dsh': 'Undergraduate Science and Humanities', |
---|
269 | 'de_dsh': 'Direct Entry Science and Humanities', |
---|
270 | } |
---|
271 | |
---|
272 | ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT |
---|
273 | |
---|
274 | VERDICTS_DICT = { |
---|
275 | '0': 'not yet', |
---|
276 | 'A': 'Successful student', |
---|
277 | 'B': 'Student with carryover courses', |
---|
278 | 'C': 'Student on probation', |
---|
279 | 'D': 'Withdrawn from the faculty', |
---|
280 | #'E': 'Student who were previously on probation', |
---|
281 | #'F': 'Medical case', |
---|
282 | #'G': 'Absent from examination', |
---|
283 | #'H': 'Withheld results', |
---|
284 | #'I': 'Expelled/rusticated/suspended student', |
---|
285 | #'J': 'Temporary withdrawn from the university', |
---|
286 | #'K': 'Unregistered student', |
---|
287 | #'L': 'Referred student', |
---|
288 | #'M': 'Reinstatement', |
---|
289 | #'N': 'Student on transfer', |
---|
290 | #'O': 'NCE-III repeater', |
---|
291 | #'Y': 'No previous verdict', |
---|
292 | #'X': 'New 300 level student', |
---|
293 | 'Z': 'Successful student (provisional)', |
---|
294 | #'A1': 'First Class', |
---|
295 | #'A2': 'Second Class Upper', |
---|
296 | #'A3': 'Second Class Lower', |
---|
297 | #'A4': 'Third Class', |
---|
298 | #'A5': 'Pass', |
---|
299 | #'A6': 'Distinction', |
---|
300 | #'A7': 'Credit', |
---|
301 | #'A8': 'Merit', |
---|
302 | 'NER': 'No evidence of registration', |
---|
303 | 'NYV': 'Not yet verified', |
---|
304 | 'FRNS': 'Faculty requirements not satisfied', |
---|
305 | } |
---|
306 | |
---|
307 | DISABLE_PAYMENT_GROUP_DICT = { |
---|
308 | 'sf_all': 'School Fee - All Students', |
---|
309 | 'sf_pg': 'School Fee - Postgraduate Students', |
---|
310 | 'sf_ug_pt': 'School Fee - Undergraduate Part-Time Students', |
---|
311 | 'sf_found': 'School Fee - Foundation Students', |
---|
312 | 'maint_all': 'Accommodation Fee - All Students', |
---|
313 | 'cl_regular': 'Acceptance Fee - Regular Students', |
---|
314 | } |
---|
315 | |
---|
316 | MODE_GROUPS = { |
---|
317 | 'All': ('all',), |
---|
318 | 'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'), |
---|
319 | 'Undergraduate Part-Time': ('ug_pt', 'de_pt'), |
---|
320 | 'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'), |
---|
321 | 'Foundation Programme': ('found',), |
---|
322 | 'Institute of Education': ('dp_ft'), |
---|
323 | 'IJMBE Preparation': ('ijmbe',), |
---|
324 | 'Bridge': ('bridge',), |
---|
325 | } |
---|
326 | |
---|
327 | #: Maximum number of files listed in `finished` subfolder |
---|
328 | MAX_FILES = 5000 |
---|
329 | |
---|
330 | def fullname(self, firstname, lastname, middlename=None): |
---|
331 | """Construct fullname. |
---|
332 | """ |
---|
333 | try: |
---|
334 | lastname = lastname.upper() |
---|
335 | except AttributeError: |
---|
336 | pass |
---|
337 | # We remove single initial |
---|
338 | if firstname and len(firstname) == 1: |
---|
339 | firstname = '' |
---|
340 | if middlename and len(middlename) == 1: |
---|
341 | middlename = '' |
---|
342 | if lastname and len(lastname) == 1: |
---|
343 | lastname = '' |
---|
344 | # We construct givennames |
---|
345 | givennames = '' |
---|
346 | if middlename and firstname: |
---|
347 | givennames = '%s %s' % (firstname, middlename) |
---|
348 | elif firstname: |
---|
349 | givennames = firstname |
---|
350 | elif middlename: |
---|
351 | givennames = middlename |
---|
352 | givennames = string.capwords( |
---|
353 | givennames.replace('-', ' - ')).replace(' - ', '-') |
---|
354 | # We construct fullname |
---|
355 | fullname = '' |
---|
356 | if lastname and givennames: |
---|
357 | fullname = '%s, %s' % (lastname, givennames) |
---|
358 | elif lastname: |
---|
359 | fullname = lastname |
---|
360 | elif givennames: |
---|
361 | fullname = givennames |
---|
362 | if '<' in fullname: |
---|
363 | return 'XXX' |
---|
364 | return fullname |
---|
365 | |
---|
366 | def getUsers(self): |
---|
367 | users = sorted( |
---|
368 | grok.getSite()['users'].items(), key=lambda x: x[0]) |
---|
369 | for key, val in users: |
---|
370 | yield(dict(name=key, val="%s - %s" % (val.name, val.title))) |
---|