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