| 1 | ## $Id: utils.py 18217 2025-12-17 20:48:41Z 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 | import string |
|---|
| 21 | from copy import deepcopy |
|---|
| 22 | from kofacustom.nigeria.utils.utils import NigeriaKofaUtils |
|---|
| 23 | from waeup.fceokene.interfaces import MessageFactory as _ |
|---|
| 24 | |
|---|
| 25 | class CustomKofaUtils(NigeriaKofaUtils): |
|---|
| 26 | """A collection of methods subject to customization. |
|---|
| 27 | """ |
|---|
| 28 | |
|---|
| 29 | STUDY_MODES_DICT = { |
|---|
| 30 | #'ume_ft': 'UME Full Time', |
|---|
| 31 | 'ug_ft': 'Undergraduate Full Time', |
|---|
| 32 | #'ug_pt': 'Undergraduate Part Time', |
|---|
| 33 | #'dp_pt': 'Diploma Part Time', |
|---|
| 34 | 'ct_ft': 'Certificate Full Time', |
|---|
| 35 | #'dp_ft': 'Diploma Full Time', |
|---|
| 36 | 'de_ft': 'Direct Entry Full Time', |
|---|
| 37 | 'de_pt': 'Direct Entry Part Time', |
|---|
| 38 | #'nd_ft': 'National Diploma Full Time', |
|---|
| 39 | #'nd_pt': 'National Diploma Part Time', |
|---|
| 40 | #'hnd_ft': 'Higher National Diploma Full Time', |
|---|
| 41 | #'hnd_pt': 'Higher National Diploma Part Time', |
|---|
| 42 | #'pg_ft': 'Postgraduate Full Time', |
|---|
| 43 | #'pg_pt': 'Postgraduate Part Time', |
|---|
| 44 | #'pgd_ft': 'Postgraduate Diploma Full Time', |
|---|
| 45 | #'pgd_pt': 'Postgraduate Diploma Part Time', |
|---|
| 46 | #'special_pg_pt': 'Special Postgraduate Part Time', |
|---|
| 47 | 'nce_ft': 'NCE Full Time', |
|---|
| 48 | #'nce_pt': 'NCE Part Time', |
|---|
| 49 | #'ug_sw': 'Undergraduate Sandwich', |
|---|
| 50 | 'nce_sw': 'NCE Sandwich', |
|---|
| 51 | #'jm_ft': 'Joint Matriculation Full Time', |
|---|
| 52 | #'ph_ft': 'Post Higher Education Full Time', |
|---|
| 53 | #'transfer_pt': 'Transfer Part Time', |
|---|
| 54 | #'transfer_ft': 'Transfer Full Time', |
|---|
| 55 | #'ct_pt': 'Certificate Part Time', |
|---|
| 56 | #'rmd_ft': 'Remedial with deficiencies', |
|---|
| 57 | #'rm_ft': 'Remedial', |
|---|
| 58 | 'transfer': 'Transfer', |
|---|
| 59 | 'prence': 'Pre-NCE/Pre-Degree', |
|---|
| 60 | #'prend': 'Pre-ND', |
|---|
| 61 | #'pce': 'PCE', |
|---|
| 62 | 'pd_ft': 'Professional Diploma in Education', |
|---|
| 63 | #'found': 'Foundation', |
|---|
| 64 | 'no': 'no application', |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | PREFERRED_LANGUAGES_DICT = { |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | APP_CATS_DICT = { |
|---|
| 71 | 'basic': 'UTME, DE, PCE, PRENCE', |
|---|
| 72 | 'no': 'No Application', |
|---|
| 73 | 'sandwich': 'Sandwich', |
|---|
| 74 | 'cest': 'Part-Time, Diploma, Certificate', |
|---|
| 75 | 'bec': 'Bachelor of Education Certificate Programmes', |
|---|
| 76 | 'pre': 'Pre-Degree Studies', |
|---|
| 77 | 'prence': 'Pre-NCE/Pre-Degree Programmes', |
|---|
| 78 | 'becdeg': 'Bachelor of Education (New) Degree Programmes', |
|---|
| 79 | #'tpu': 'Teaching Practice Unit Courses' use basic instead!! |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | SPECIAL_HANDLING_DICT = { |
|---|
| 83 | 'regular': 'Regular Hostel', |
|---|
| 84 | 'blocked': 'Blocked Hostel', |
|---|
| 85 | 'ugft': 'Undergraduate Fulltime Hostel' |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | PAYMENT_CATEGORIES = { |
|---|
| 89 | 'schoolfee': 'School Fee', |
|---|
| 90 | 'schoolfee_pde1': 'New PDE students first instalment', |
|---|
| 91 | 'schoolfee_ug_new': 'Undergraduate new students first instalment', |
|---|
| 92 | 'schoolfee_ug_ret': 'Undergraduate returning students first instalment', |
|---|
| 93 | 'schoolfee_third': 'NCE Third Semester Fee (6 courses)', |
|---|
| 94 | 'clearance': 'Acceptance Fee', |
|---|
| 95 | 'bed_allocation': 'Bed Allocation Fee', |
|---|
| 96 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
|---|
| 97 | 'application': 'Application Fee', |
|---|
| 98 | 'reg2sandwich': 'Regular to Sandwich (14 courses)', |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | SELECTABLE_PAYMENT_CATEGORIES = { |
|---|
| 102 | 'schoolfee': 'School Fee', |
|---|
| 103 | 'schoolfee_pde1': 'New PDE students first instalment', |
|---|
| 104 | 'schoolfee_ug_new': 'Undergraduate new students first instalment', |
|---|
| 105 | 'schoolfee_ug_ret': 'Undergraduate returning students first instalment', |
|---|
| 106 | 'schoolfee_third': 'NCE Third Semester Fee (6 courses)', |
|---|
| 107 | 'clearance': 'Acceptance Fee', |
|---|
| 108 | 'bed_allocation': 'Bed Allocation Fee', |
|---|
| 109 | 'hostel_maintenance': 'Hostel Maintenance Fee', |
|---|
| 110 | 'application': 'Application Fee', |
|---|
| 111 | #'third_semester': 'NCE Third Semester Fee (additional courses)', |
|---|
| 112 | 'reg2sandwich': 'Regular to Sandwich (14 courses)', |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | DISABLE_PAYMENT_GROUP_DICT = { |
|---|
| 116 | 'sf_all': 'School Fee - All Students', |
|---|
| 117 | 'sf_nce1': 'School Fee - NCE I Fresh Students', |
|---|
| 118 | 'cl_except_ug': 'Acceptance Fee - All Students except UG Full Time', |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | BALANCE_PAYMENT_CATEGORIES = { |
|---|
| 122 | 'schoolfee': 'School Fee', |
|---|
| 123 | 'third_semester': 'NCE Third Semester Fee (N2000 per additional course)', |
|---|
| 124 | 'reg2sandwich': 'Regular to Sandwich (N3000 per additional course)', |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | def selectable_payment_categories(self, student): |
|---|
| 128 | return self.SELECTABLE_PAYMENT_CATEGORIES |
|---|
| 129 | |
|---|
| 130 | VERDICTS_DICT = { |
|---|
| 131 | '0': 'not yet', |
|---|
| 132 | 'A': 'Successful student', |
|---|
| 133 | 'B': 'Student with carryover courses', |
|---|
| 134 | 'C': 'Student on probation', |
|---|
| 135 | 'D': 'Withdrawn from the faculty', |
|---|
| 136 | #'E': 'Student who were previously on probation', |
|---|
| 137 | #'F': 'Medical case', |
|---|
| 138 | 'G': 'Absent from examination', |
|---|
| 139 | #'H': 'Withheld results', |
|---|
| 140 | 'I': 'Expelled/rusticated/suspended student', |
|---|
| 141 | 'J': 'Temporary withdrawn from the university', |
|---|
| 142 | #'K': 'Unregistered student', |
|---|
| 143 | 'L': 'Referred student', |
|---|
| 144 | 'M': 'Reinstatement', |
|---|
| 145 | #'N': 'Student on transfer', |
|---|
| 146 | 'O': 'NCE-III repeater', |
|---|
| 147 | #'Y': 'No previous verdict', |
|---|
| 148 | #'X': 'New 300 level student (Uniben)', |
|---|
| 149 | 'Z': 'Successful student (provisional)', |
|---|
| 150 | 'A1': 'First Class', |
|---|
| 151 | 'A2': 'Second Class Upper', |
|---|
| 152 | 'A3': 'Second Class Lower', |
|---|
| 153 | 'A4': 'Third Class', |
|---|
| 154 | 'A5': 'Pass', |
|---|
| 155 | 'A6': 'Distinction', |
|---|
| 156 | 'A7': 'Credit', |
|---|
| 157 | 'A8': 'Merit', |
|---|
| 158 | 'OPDE': 'PDE repeater', |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | def getPaymentItem(self, payment): |
|---|
| 162 | """Return payment item. |
|---|
| 163 | |
|---|
| 164 | Bed coordinates are only visible after payment. |
|---|
| 165 | """ |
|---|
| 166 | if 'maintenance' in payment.p_category and payment.p_state != 'paid': |
|---|
| 167 | return _('(visible after successful payment)') |
|---|
| 168 | return payment.p_item |
|---|
| 169 | |
|---|
| 170 | def fullname(self, firstname, lastname, middlename=None): |
|---|
| 171 | """Construct fullname. |
|---|
| 172 | """ |
|---|
| 173 | try: |
|---|
| 174 | lastname = lastname.upper() |
|---|
| 175 | except AttributeError: |
|---|
| 176 | pass |
|---|
| 177 | # We remove single initial |
|---|
| 178 | if firstname and len(firstname) == 1: |
|---|
| 179 | firstname = '' |
|---|
| 180 | if middlename and len(middlename) == 1: |
|---|
| 181 | middlename = '' |
|---|
| 182 | if lastname and len(lastname) == 1: |
|---|
| 183 | lastname = '' |
|---|
| 184 | # We construct givennames |
|---|
| 185 | givennames = '' |
|---|
| 186 | if middlename and firstname: |
|---|
| 187 | givennames = '%s %s' % (firstname, middlename) |
|---|
| 188 | elif firstname: |
|---|
| 189 | givennames = firstname |
|---|
| 190 | elif middlename: |
|---|
| 191 | givennames = middlename |
|---|
| 192 | givennames = string.capwords( |
|---|
| 193 | givennames.replace('-', ' - ')).replace(' - ', '-') |
|---|
| 194 | # We construct fullname |
|---|
| 195 | fullname = '' |
|---|
| 196 | if lastname and givennames: |
|---|
| 197 | fullname = '%s %s' % (givennames, lastname) |
|---|
| 198 | elif lastname: |
|---|
| 199 | fullname = lastname |
|---|
| 200 | elif givennames: |
|---|
| 201 | fullname = givennames |
|---|
| 202 | if '<' in fullname: |
|---|
| 203 | return 'XXX' |
|---|
| 204 | return fullname |
|---|