1 | ## $Id: utils.py 17964 2024-11-27 00:30:20Z 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 | from copy import deepcopy |
---|
21 | from zope.security import checkPermission |
---|
22 | from kofacustom.nigeria.utils.utils import NigeriaKofaUtils |
---|
23 | |
---|
24 | class CustomKofaUtils(NigeriaKofaUtils): |
---|
25 | """A collection of methods subject to customization. |
---|
26 | """ |
---|
27 | |
---|
28 | SYSTEM_MAX_LOAD = { |
---|
29 | 'swap-mem': None, |
---|
30 | 'virt-mem': 80.0, |
---|
31 | 'cpu-load': 100.0, |
---|
32 | } |
---|
33 | |
---|
34 | PREFERRED_LANGUAGES_DICT = { |
---|
35 | } |
---|
36 | |
---|
37 | APP_CATS_DICT = { |
---|
38 | 'basic': 'ASE, PUDE, PCE, PRENCE', |
---|
39 | 'no': 'No Application', |
---|
40 | 'sandwich': 'Sandwich', |
---|
41 | 'cest': 'Part-Time, Diploma, Certificate', |
---|
42 | 'dp_ft': 'Diploma Full-Time Programmes', |
---|
43 | 'dp': 'Diploma Programmes', |
---|
44 | 'pt_ext': 'Part-Time (extended application)', |
---|
45 | 'pg': 'Postgraduate (main advert)', |
---|
46 | 'coe': 'CoE Programmes', |
---|
47 | 'pgnils': 'Postgraduate NILS', |
---|
48 | 'spesse': 'SPESSE Programmes', |
---|
49 | 'pg_ft': 'Postgraduate Full-Time (deprecated)', |
---|
50 | 'pg_pt': 'Postgraduate Part-Time (deprecated)', |
---|
51 | 'pg_ext': 'Postgraduate (extended application, deprecated)', |
---|
52 | 'pg_new': 'Postgraduate (supplementary application #1, deprecated)', |
---|
53 | 'pg_new2': 'Postgraduate (supplementary application #2, deprecated)', |
---|
54 | 'pre': 'Pre-Degree Studies', |
---|
55 | 'asaba': 'FCE Asaba', |
---|
56 | 'akoka': 'FCE Akoka', |
---|
57 | 'akokaj': 'FCE Akoka JUPEB', |
---|
58 | 'special_ft': 'Special Full-Time', |
---|
59 | 'cdl': 'Center For Distance Learning', |
---|
60 | 'french': 'French Language Center', |
---|
61 | 'afrimal': 'African Institute of Management and Leadership', |
---|
62 | } |
---|
63 | |
---|
64 | # de modes are only used for entry_mode |
---|
65 | MODE_GROUPS = { |
---|
66 | 'All':('all',), |
---|
67 | 'Undergraduate Full-Time':('ug_ft', 'special_ft'), |
---|
68 | 'Undergraduate Part-Time':('ug_pt'), |
---|
69 | 'Diploma/Certificate Full-Time':('dp_ft', 'ct_ft'), |
---|
70 | 'Diploma/Certificate Part-Time':('dp_pt', 'ct_pt'), |
---|
71 | 'Postgraduate Full-Time':('pg_ft', 'pgd_ft'), |
---|
72 | 'Postgraduate Part-Time':('pg_pt', 'special_pg_pt', 'pgd_pt'), |
---|
73 | } |
---|
74 | |
---|
75 | PAYMENT_CATEGORIES = { |
---|
76 | 'schoolfee': 'School Fee', |
---|
77 | 'schoolfee_1': 'School Fee (1st instalment)', |
---|
78 | 'secondinstall':'School Fee (2nd instalment)', |
---|
79 | 'clearance': 'Acceptance Fee', |
---|
80 | 'bed_allocation': 'Bed Allocation Fee', |
---|
81 | #'hostel_application': 'Hostel Application Fee', |
---|
82 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
83 | #'tempmaint_1': 'Hall 1-4 M/F Ekehuan', |
---|
84 | #'tempmaint_2': 'Hall 5 M/F', |
---|
85 | #'tempmaint_3': 'Clinical Hostel', |
---|
86 | 'transfer': 'Transfer Fee', |
---|
87 | 'gown': 'Gown Hire Fee', |
---|
88 | 'application': 'Application Fee', |
---|
89 | 'transcript': 'Transcript Fee', |
---|
90 | 'admission_checking': 'Admission Checking Fee', |
---|
91 | 'jupeb': 'JUPEB Examination Fee', |
---|
92 | 'registration': 'Total Registration Fee', |
---|
93 | 'clinexam':'Clinical Examination Fee', |
---|
94 | #'pharmd_1':'Clerkship Fee', |
---|
95 | 'pharmd_2':'Module 1 Fee', |
---|
96 | 'develop':'Development Fee', |
---|
97 | 'carryover':'School Fee (carry over from previous sessions)', |
---|
98 | 'foreign':'School Fee (paid in foreign currency)', |
---|
99 | 'medical_quest':'Medical Questionnaire Fee', |
---|
100 | 'plag_test':'Final Year Plagiarism Test', |
---|
101 | 'flc_modules': 'FLC Modules Fee', |
---|
102 | 'medical_clearance': 'Medical Clearance Fee', |
---|
103 | } |
---|
104 | |
---|
105 | SELECTABLE_PAYMENT_CATEGORIES = { |
---|
106 | 'schoolfee': 'School Fee', |
---|
107 | 'clearance': 'Acceptance Fee', |
---|
108 | 'bed_allocation': 'Bed Allocation Fee', |
---|
109 | #'hostel_application': 'Hostel Application Fee', |
---|
110 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
111 | #'tempmaint_1': 'Hall 1-4 M/F Ekehuan Maintenance Fee', |
---|
112 | #'tempmaint_2': 'Hall 5 M/F Maintenance Fee', |
---|
113 | #'tempmaint_3': 'Clinical Hostel Maintenance Fee', |
---|
114 | 'gown': 'Gown Hire Fee', |
---|
115 | 'application': 'Application Fee', |
---|
116 | 'transcript': 'Transcript Fee', |
---|
117 | 'transfer': 'Transfer Fee', |
---|
118 | 'jupeb': 'JUPEB Examination Fee', |
---|
119 | 'clinexam':'Clinical Examination Fee', |
---|
120 | #'pharmd_1':'PharmD Clerkship Fee (1st school fee prepayment)', |
---|
121 | 'pharmd_2':'PharmD Module 1 Fee (school fee prepayment)', |
---|
122 | #'develop':'Development Fee', |
---|
123 | 'medical_quest':'Medical Questionnaire Fee', |
---|
124 | 'plag_test':'Final Year Plagiarism Test (for final year project or PG thesis)', |
---|
125 | 'flc_modules': 'FLC Modules Fee', |
---|
126 | 'medical_clearance': 'Medical Clearance Fee', |
---|
127 | } |
---|
128 | |
---|
129 | REPORTABLE_PAYMENT_CATEGORIES = { |
---|
130 | 'schoolfee': 'School Fee', |
---|
131 | 'schoolfee_1': 'School Fee (1st instalment)', |
---|
132 | 'secondinstall':'School Fee (2nd instalment)', |
---|
133 | 'clearance': 'Acceptance Fee', |
---|
134 | 'bed_allocation': 'Bed Allocation Fee', |
---|
135 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
136 | 'medical_quest':'Medical Questionnaire Fee', |
---|
137 | } |
---|
138 | |
---|
139 | def selectable_payment_categories(self, student): |
---|
140 | spc = deepcopy(self.SELECTABLE_PAYMENT_CATEGORIES) |
---|
141 | if student.is_jupeb: |
---|
142 | spc[schoolfee_1] = 'School Fee (1st instalment)' |
---|
143 | spc[secondinstal] = 'School Fee (2nd instalment)' |
---|
144 | return spc |
---|
145 | |
---|
146 | PREVIOUS_PAYMENT_CATEGORIES = deepcopy(SELECTABLE_PAYMENT_CATEGORIES) |
---|
147 | |
---|
148 | DISABLE_PAYMENT_GROUP_DICT = { |
---|
149 | 'sf_all': 'School Fee - All', |
---|
150 | 'sf_found': 'School Fee - Foundation', |
---|
151 | 'sf_pg': 'School Fee - PG', |
---|
152 | 'sf_pt': 'School Fee - UG PT', |
---|
153 | 'sf_ft': 'School Fee - UG FT', |
---|
154 | 'sf_sw': 'School Fee - Sandwich', |
---|
155 | 'sf_dp': 'School Fee - Diploma', |
---|
156 | 'sf_return': 'School Fee - Returning', |
---|
157 | 'maint_all': 'Accomm. Fee - All', |
---|
158 | 'cl_all': 'Accept. Fee - All', |
---|
159 | 'cl_jupeb': 'Accept. Fee - JUPEB', |
---|
160 | 'cl_allexj': 'Accept. Fee - All except JUPEB', |
---|
161 | } |
---|
162 | |
---|
163 | SEMESTER_DICT = { |
---|
164 | 1: '1st Semester', |
---|
165 | 2: '2nd Semester', |
---|
166 | 3: 'Combined', |
---|
167 | 4: '1st Term', |
---|
168 | 5: '2nd Term', |
---|
169 | 6: '3rd Term', |
---|
170 | 9: 'N/A', |
---|
171 | 11: 'Module I', |
---|
172 | 12: 'Module II', |
---|
173 | 13: 'Module III', |
---|
174 | } |
---|
175 | |
---|
176 | BALANCE_PAYMENT_CATEGORIES = { |
---|
177 | 'schoolfee': 'School Fee', |
---|
178 | 'clearance': 'Clearance Fee', |
---|
179 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
---|
180 | 'bed_allocation': 'Bed Allocation Fee', |
---|
181 | 'carryover':'School Fee (carry over from previous sessions)', |
---|
182 | 'foreign':'School Fee (paid in foreign currency)', |
---|
183 | 'flc_modules': 'FLC Modules Fee', |
---|
184 | } |
---|
185 | |
---|
186 | EXAM_GRADES = NigeriaKofaUtils.EXAM_GRADES + (('B1', 'B1'), ('P', 'P'),) |
---|
187 | |
---|
188 | SPECIAL_HANDLING_DICT = { |
---|
189 | 'regular': 'Regular Hostel', |
---|
190 | 'blocked': 'Blocked Hostel', |
---|
191 | 'clinical': 'Clinical Hostel', |
---|
192 | 'ekenwan': 'Ekenwan Campus', |
---|
193 | 'pg': 'Postgraduate Hostel', |
---|
194 | } |
---|
195 | |
---|
196 | STUDY_MODES_DICT = { |
---|
197 | 'ume_ft': 'UME Full-Time', |
---|
198 | 'ug_ft': 'Undergraduate Full-Time', |
---|
199 | 'ug_pt': 'Undergraduate Part-Time', |
---|
200 | 'dp_pt': 'Diploma Part-Time', |
---|
201 | 'ct_ft': 'Certificate Full-Time', |
---|
202 | 'dp_ft': 'Diploma Full-Time', |
---|
203 | 'de_ft': 'Direct Entry Full-Time', |
---|
204 | 'de_pt': 'Direct Entry Part-Time', |
---|
205 | 'pg_ft': 'Postgraduate Full-Time', |
---|
206 | 'pg_pt': 'Postgraduate Part-Time', |
---|
207 | 'pgd_ft': 'Postgraduate Diploma Full-Time', |
---|
208 | 'pgd_pt': 'Postgraduate Diploma Part-Time', |
---|
209 | 'special_pg_pt': 'Special Postgraduate Part-Time', |
---|
210 | 'ug_sw': 'Undergraduate Sandwich', |
---|
211 | 'transfer_pt': 'Transfer Part-Time', |
---|
212 | 'transfer_ft': 'Transfer Full-Time', |
---|
213 | 'ct_pt': 'Certificate Part-Time', |
---|
214 | 'transfer': 'Transfer', |
---|
215 | 'transferred': 'Transferred', |
---|
216 | 'found': 'Foundation', |
---|
217 | 'no': 'no application', |
---|
218 | 'special_ft': 'Special Full-Time', |
---|
219 | 'cdl': 'Open & Distance Learning', |
---|
220 | } |
---|
221 | |
---|
222 | def sortCertificates(self, context, resultset): |
---|
223 | """Sort already filtered certificates in `CertificateSource`. |
---|
224 | """ |
---|
225 | resultlist = sorted(resultset, key=lambda |
---|
226 | value: value.__parent__.__parent__.__parent__.code + |
---|
227 | value.__parent__.__parent__.code + |
---|
228 | value.code) |
---|
229 | return resultlist |
---|
230 | |
---|
231 | def getCertTitle(self, context, value): |
---|
232 | """Compose the titles in `CertificateSource`. |
---|
233 | """ |
---|
234 | try: title = "%s / %s / %s (%s)" % ( |
---|
235 | value.__parent__.__parent__.__parent__.title, |
---|
236 | value.__parent__.__parent__.title, |
---|
237 | value.title, value.code) |
---|
238 | except AttributeError: |
---|
239 | title = "NA / %s (%s)" % (value.title, value.code) |
---|
240 | return title |
---|
241 | |
---|
242 | def collect_exporters(self, context): |
---|
243 | # Used for `ExportJobContainerJobConfig`. |
---|
244 | # We provide all student exporters, nothing else, yet. |
---|
245 | # Bursary, Department or Accommodation Officers don't |
---|
246 | # have the general exportData |
---|
247 | # permission and are only allowed to export bursary, payments |
---|
248 | # overview or accommodation data respectively. |
---|
249 | # This is the only place where waeup.exportAccommodationData, |
---|
250 | # waeup.exportBursaryData and waeup.exportPaymentsOverview |
---|
251 | # are used. |
---|
252 | # Uniben: Add NYSC Officers. |
---|
253 | exporters = [] |
---|
254 | if not checkPermission('waeup.exportData', context): |
---|
255 | if checkPermission('waeup.exportBursaryData', context): |
---|
256 | exporters += [('Bursary Data', 'bursary'), |
---|
257 | ('School Fee Payments Overview', |
---|
258 | 'sfpaymentsoverview'), |
---|
259 | ('Session Payments Overview', |
---|
260 | 'sessionpaymentsoverview')] |
---|
261 | if checkPermission('waeup.exportPaymentsOverview', context): |
---|
262 | exporters += [('School Fee Payments Overview', |
---|
263 | 'sfpaymentsoverview'), |
---|
264 | ('Session Payments Overview', |
---|
265 | 'sessionpaymentsoverview')] |
---|
266 | if checkPermission('waeup.exportAccommodationData', context): |
---|
267 | exporters += [('Bed Tickets', 'bedtickets'), |
---|
268 | ('Accommodation Payments', |
---|
269 | 'accommodationpayments')] |
---|
270 | if checkPermission('waeup.exportNYSCData', context): |
---|
271 | exporters += [('NYSC Indication', 'nysc'),] |
---|
272 | return exporters |
---|
273 | |
---|