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