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