[7419] | 1 | ## $Id: utils.py 17892 2024-08-16 04:52:55Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2011 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 | ## |
---|
[7151] | 18 | import grok |
---|
[17431] | 19 | import os |
---|
| 20 | import csv |
---|
[8600] | 21 | from time import time |
---|
[14918] | 22 | from zope.component import createObject, queryUtility |
---|
| 23 | from zope.catalog.interfaces import ICatalog |
---|
[10922] | 24 | from waeup.kofa.interfaces import ( |
---|
[13594] | 25 | ADMITTED, CLEARANCE, REQUESTED, CLEARED, RETURNING, PAID, |
---|
[16667] | 26 | REGISTERED, VALIDATED, academic_sessions_vocab) |
---|
[8823] | 27 | from kofacustom.nigeria.students.utils import NigeriaStudentsUtils |
---|
[8247] | 28 | from waeup.kofa.accesscodes import create_accesscode |
---|
[10922] | 29 | from waeup.kofa.students.utils import trans |
---|
[8444] | 30 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
[6902] | 31 | |
---|
[14663] | 32 | MINIMUM_UNITS_THRESHOLD = 15 |
---|
| 33 | |
---|
[17447] | 34 | SCHOOLFEES = dict() |
---|
[17878] | 35 | SFEECHANGES = (12, 13, 14, 15, 20, 21, 22, 23, 24) |
---|
[17444] | 36 | |
---|
[17447] | 37 | for year in SFEECHANGES: |
---|
| 38 | schoolfees_path = os.path.join( |
---|
| 39 | os.path.dirname(__file__), 'schoolfees_%s.csv' %year) |
---|
| 40 | reader = csv.DictReader(open(schoolfees_path, 'rb')) |
---|
| 41 | SCHOOLFEES[year] = {item['code']:(item['tuition'], item.values()) for item in reader} |
---|
[17444] | 42 | |
---|
[17431] | 43 | acceptancefees_path = os.path.join( |
---|
| 44 | os.path.dirname(__file__), 'acceptancefees.csv') |
---|
| 45 | reader = csv.DictReader(open(acceptancefees_path, 'rb')) |
---|
| 46 | ACCEPTANCEFEES = {item['code']:(item['acceptance'], item.values()) for item in reader} |
---|
| 47 | |
---|
[8823] | 48 | class CustomStudentsUtils(NigeriaStudentsUtils): |
---|
[7151] | 49 | """A collection of customized methods. |
---|
| 50 | |
---|
| 51 | """ |
---|
| 52 | |
---|
[16672] | 53 | # PORTRAIT_CHANGE_STATES = (ADMITTED, CLEARANCE, REQUESTED, CLEARED) |
---|
[13348] | 54 | |
---|
[16672] | 55 | def allowPortraitChange(self, student): |
---|
[17667] | 56 | #if student.is_fresh: |
---|
| 57 | # return True |
---|
[16672] | 58 | return False |
---|
| 59 | |
---|
[14918] | 60 | def GPABoundaries(self, faccode=None, depcode=None, |
---|
| 61 | certcode=None, student=None): |
---|
| 62 | if student and student.current_mode.startswith('dp'): |
---|
[14959] | 63 | return ((1.5, 'IRNS / NER / NYV'), |
---|
[14918] | 64 | (2.4, 'Pass'), |
---|
| 65 | (3.5, 'Merit'), |
---|
| 66 | (4.5, 'Credit'), |
---|
| 67 | (5, 'Distinction')) |
---|
| 68 | elif student: |
---|
| 69 | return ((1, 'FRNS / NER / NYV'), |
---|
| 70 | (1.5, 'Pass'), |
---|
| 71 | (2.4, '3rd Class Honours'), |
---|
| 72 | (3.5, '2nd Class Honours Lower Division'), |
---|
| 73 | (4.5, '2nd Class Honours Upper Division'), |
---|
| 74 | (5, '1st Class Honours')) |
---|
| 75 | # Session Results Presentations depend on certificate |
---|
| 76 | results = None |
---|
| 77 | if certcode: |
---|
| 78 | cat = queryUtility(ICatalog, name='certificates_catalog') |
---|
| 79 | results = list( |
---|
| 80 | cat.searchResults(code=(certcode, certcode))) |
---|
| 81 | if results and results[0].study_mode.startswith('dp'): |
---|
[14975] | 82 | return ((1.5, 'IRNS / NER / NYV'), |
---|
[14918] | 83 | (2.4, 'Pass'), |
---|
| 84 | (3.5, 'Merit'), |
---|
| 85 | (4.5, 'Credit'), |
---|
| 86 | (5, 'Distinction')) |
---|
| 87 | else: |
---|
| 88 | return ((1, 'FRNS / NER / NYV'), |
---|
| 89 | (1.5, 'Pass'), |
---|
| 90 | (2.4, '3rd Class Honours'), |
---|
| 91 | (3.5, '2nd Class Honours Lower Division'), |
---|
| 92 | (4.5, '2nd Class Honours Upper Division'), |
---|
| 93 | (5, '1st Class Honours')) |
---|
[14899] | 94 | |
---|
[14462] | 95 | def getClassFromCGPA(self, gpa, student): |
---|
[14918] | 96 | gpa_boundaries = self.GPABoundaries(student=student) |
---|
[15095] | 97 | |
---|
| 98 | try: |
---|
| 99 | certificate = getattr(student['studycourse'],'certificate',None) |
---|
| 100 | end_level = getattr(certificate, 'end_level', None) |
---|
| 101 | final_level = max([studylevel.level for studylevel in student['studycourse'].values()]) |
---|
| 102 | if end_level and final_level >= end_level: |
---|
| 103 | dummy, repeat = divmod(final_level, 100) |
---|
| 104 | if gpa <= 5.1 and repeat == 20: |
---|
| 105 | # Irrespective of the CGPA of a student, if the He/She has |
---|
| 106 | # 3rd Extension, such student will be graduated with a "Pass". |
---|
| 107 | return 1, gpa_boundaries[1][1] |
---|
| 108 | except ValueError: |
---|
| 109 | pass |
---|
| 110 | |
---|
[14899] | 111 | if gpa < gpa_boundaries[0][0]: |
---|
| 112 | # FRNS / Fail |
---|
| 113 | return 0, gpa_boundaries[0][1] |
---|
[14977] | 114 | if student.entry_session < 2013 or \ |
---|
| 115 | student.current_mode.startswith('dp'): |
---|
[14899] | 116 | if gpa < gpa_boundaries[1][0]: |
---|
[14462] | 117 | # Pass |
---|
[14899] | 118 | return 1, gpa_boundaries[1][1] |
---|
[14462] | 119 | else: |
---|
[14899] | 120 | if gpa < gpa_boundaries[1][0]: |
---|
[14977] | 121 | # FRNS |
---|
| 122 | # Pass degree has been phased out in 2013 for non-diploma |
---|
| 123 | # students |
---|
[14899] | 124 | return 0, gpa_boundaries[0][1] |
---|
| 125 | if gpa < gpa_boundaries[2][0]: |
---|
[15095] | 126 | # 3rd / Merit |
---|
[14899] | 127 | return 2, gpa_boundaries[2][1] |
---|
| 128 | if gpa < gpa_boundaries[3][0]: |
---|
[15095] | 129 | # 2nd L / Credit |
---|
[14899] | 130 | return 3, gpa_boundaries[3][1] |
---|
| 131 | if gpa < gpa_boundaries[4][0]: |
---|
[15095] | 132 | # 2nd U / Distinction |
---|
[14899] | 133 | return 4, gpa_boundaries[4][1] |
---|
| 134 | if gpa <= gpa_boundaries[5][0]: |
---|
[15095] | 135 | # 1st |
---|
[14899] | 136 | return 5, gpa_boundaries[5][1] |
---|
[15095] | 137 | return |
---|
[14462] | 138 | |
---|
[14160] | 139 | def getDegreeClassNumber(self, level_obj): |
---|
[14415] | 140 | """Get degree class number (used for SessionResultsPresentation |
---|
| 141 | reports). |
---|
| 142 | """ |
---|
[14459] | 143 | certificate = getattr(level_obj.__parent__,'certificate', None) |
---|
[14160] | 144 | end_level = getattr(certificate, 'end_level', None) |
---|
[16708] | 145 | if level_obj.level_verdict in ('FRNS', 'NER', 'NYV'): |
---|
[16652] | 146 | return 0 |
---|
[14459] | 147 | if end_level and level_obj.level >= end_level: |
---|
[16708] | 148 | if level_obj.level > end_level: |
---|
| 149 | # spill-over level |
---|
| 150 | if level_obj.gpa_params[1] == 0: |
---|
| 151 | # no credits taken |
---|
| 152 | return 0 |
---|
| 153 | elif level_obj.gpa_params[1] < MINIMUM_UNITS_THRESHOLD: |
---|
| 154 | # credits taken below limit |
---|
| 155 | return 0 |
---|
[14160] | 156 | failed_courses = level_obj.passed_params[4] |
---|
[14411] | 157 | not_taken_courses = level_obj.passed_params[5] |
---|
[14160] | 158 | if '_m' in failed_courses: |
---|
| 159 | return 0 |
---|
[14441] | 160 | if len(not_taken_courses) \ |
---|
[14506] | 161 | and not not_taken_courses == 'Nil': |
---|
[14411] | 162 | return 0 |
---|
[16708] | 163 | elif level_obj.gpa_params[1] < MINIMUM_UNITS_THRESHOLD: |
---|
| 164 | # credits taken below limit |
---|
[14464] | 165 | return 0 |
---|
[14160] | 166 | # use gpa_boundaries above |
---|
[14462] | 167 | return self.getClassFromCGPA( |
---|
| 168 | level_obj.cumulative_params[0], level_obj.student)[0] |
---|
[14160] | 169 | |
---|
[13359] | 170 | def increaseMatricInteger(self, student): |
---|
| 171 | """Increase counter for matric numbers. |
---|
| 172 | This counter can be a centrally stored attribute or an attribute of |
---|
| 173 | faculties, departments or certificates. In the base package the counter |
---|
| 174 | is as an attribute of the site configuration container. |
---|
| 175 | """ |
---|
[15382] | 176 | if student.current_mode in ('ug_pt', 'de_pt', 'ug_dsh', 'de_dsh'): |
---|
[13359] | 177 | grok.getSite()['configuration'].next_matric_integer += 1 |
---|
| 178 | return |
---|
[13609] | 179 | elif student.is_postgrad: |
---|
| 180 | grok.getSite()['configuration'].next_matric_integer_3 += 1 |
---|
| 181 | return |
---|
[13793] | 182 | elif student.current_mode in ('dp_ft',): |
---|
| 183 | grok.getSite()['configuration'].next_matric_integer_4 += 1 |
---|
| 184 | return |
---|
[13359] | 185 | grok.getSite()['configuration'].next_matric_integer_2 += 1 |
---|
| 186 | return |
---|
| 187 | |
---|
[13749] | 188 | def _concessionalPaymentMade(self, student): |
---|
| 189 | if len(student['payments']): |
---|
| 190 | for ticket in student['payments'].values(): |
---|
| 191 | if ticket.p_state == 'paid' and \ |
---|
| 192 | ticket.p_category == 'concessional': |
---|
| 193 | return True |
---|
| 194 | return False |
---|
| 195 | |
---|
[11596] | 196 | def constructMatricNumber(self, student): |
---|
[11593] | 197 | faccode = student.faccode |
---|
| 198 | depcode = student.depcode |
---|
[13609] | 199 | certcode = student.certcode |
---|
[13664] | 200 | degree = getattr( |
---|
| 201 | getattr(student.get('studycourse', None), 'certificate', None), |
---|
| 202 | 'degree', None) |
---|
[11593] | 203 | year = unicode(student.entry_session)[2:] |
---|
[13359] | 204 | if not student.state in (PAID, ) or not student.is_fresh or \ |
---|
[14615] | 205 | student.current_mode in ('found', 'ijmbe'): |
---|
[13359] | 206 | return _('Matriculation number cannot be set.'), None |
---|
[13755] | 207 | #if student.current_mode not in ('mug_ft', 'mde_ft') and \ |
---|
| 208 | # not self._concessionalPaymentMade(student): |
---|
| 209 | # return _('Matriculation number cannot be set.'), None |
---|
[13571] | 210 | if student.is_postgrad: |
---|
[13609] | 211 | next_integer = grok.getSite()['configuration'].next_matric_integer_3 |
---|
[13664] | 212 | if not degree or next_integer == 0: |
---|
[13609] | 213 | return _('Matriculation number cannot be set.'), None |
---|
[13846] | 214 | if student.faccode in ('IOE'): |
---|
| 215 | return None, "AAU/SPS/%s/%s/%s/%05d" % ( |
---|
| 216 | faccode, year, degree, next_integer) |
---|
[13609] | 217 | return None, "AAU/SPS/%s/%s/%s/%s/%05d" % ( |
---|
[13664] | 218 | faccode, depcode, year, degree, next_integer) |
---|
[15382] | 219 | if student.current_mode in ('ug_dsh', 'de_dsh'): |
---|
[15368] | 220 | next_integer = grok.getSite()['configuration'].next_matric_integer |
---|
| 221 | if next_integer == 0: |
---|
| 222 | return _('Matriculation number cannot be set.'), None |
---|
[15376] | 223 | return None, "DSH/%s/%s/%s/%05d" % ( |
---|
[15368] | 224 | faccode, depcode, year, next_integer) |
---|
[13359] | 225 | if student.current_mode in ('ug_pt', 'de_pt'): |
---|
| 226 | next_integer = grok.getSite()['configuration'].next_matric_integer |
---|
| 227 | if next_integer == 0: |
---|
| 228 | return _('Matriculation number cannot be set.'), None |
---|
[12975] | 229 | return None, "PTP/%s/%s/%s/%05d" % ( |
---|
| 230 | faccode, depcode, year, next_integer) |
---|
[13793] | 231 | if student.current_mode in ('dp_ft',): |
---|
| 232 | next_integer = grok.getSite()['configuration'].next_matric_integer_4 |
---|
| 233 | if next_integer == 0: |
---|
| 234 | return _('Matriculation number cannot be set.'), None |
---|
| 235 | return None, "IOE/DIP/%s/%05d" % (year, next_integer) |
---|
[13359] | 236 | next_integer = grok.getSite()['configuration'].next_matric_integer_2 |
---|
| 237 | if next_integer == 0: |
---|
| 238 | return _('Matriculation number cannot be set.'), None |
---|
[16822] | 239 | if student.faccode in ('FBM', 'FCS', 'FMLS'): |
---|
[13359] | 240 | return None, "CMS/%s/%s/%s/%05d" % ( |
---|
| 241 | faccode, depcode, year, next_integer) |
---|
| 242 | return None, "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer) |
---|
[12975] | 243 | |
---|
[8270] | 244 | def getReturningData(self, student): |
---|
| 245 | """ This method defines what happens after school fee payment |
---|
[8319] | 246 | of returning students depending on the student's senate verdict. |
---|
[8270] | 247 | """ |
---|
[8319] | 248 | prev_level = student['studycourse'].current_level |
---|
| 249 | cur_verdict = student['studycourse'].current_verdict |
---|
[14958] | 250 | if cur_verdict in ('A','B','L','M','N','Z',): |
---|
[8319] | 251 | # Successful student |
---|
| 252 | new_level = divmod(int(prev_level),100)[0]*100 + 100 |
---|
[14958] | 253 | elif cur_verdict == 'C': |
---|
| 254 | # Student on probation |
---|
| 255 | new_level = int(prev_level) + 10 |
---|
[8319] | 256 | else: |
---|
| 257 | # Student is somehow in an undefined state. |
---|
| 258 | # Level has to be set manually. |
---|
| 259 | new_level = prev_level |
---|
[8270] | 260 | new_session = student['studycourse'].current_session + 1 |
---|
| 261 | return new_session, new_level |
---|
| 262 | |
---|
[13454] | 263 | def _isPaymentDisabled(self, p_session, category, student): |
---|
| 264 | academic_session = self._getSessionConfiguration(p_session) |
---|
[14246] | 265 | if category.startswith('schoolfee'): |
---|
[17602] | 266 | if 'all_returning' in academic_session.payment_disabled and \ |
---|
| 267 | student.state == RETURNING: |
---|
| 268 | return True |
---|
[14246] | 269 | if 'sf_all' in academic_session.payment_disabled: |
---|
| 270 | return True |
---|
| 271 | if 'sf_pg' in academic_session.payment_disabled and \ |
---|
| 272 | student.is_postgrad: |
---|
| 273 | return True |
---|
[14571] | 274 | if 'sf_ug_pt' in academic_session.payment_disabled and \ |
---|
| 275 | student.current_mode in ('ug_pt', 'de_pt'): |
---|
[14246] | 276 | return True |
---|
| 277 | if 'sf_found' in academic_session.payment_disabled and \ |
---|
| 278 | student.current_mode == 'found': |
---|
| 279 | return True |
---|
[13794] | 280 | if category.startswith('clearance') and \ |
---|
| 281 | 'cl_regular' in academic_session.payment_disabled and \ |
---|
| 282 | student.current_mode in ('ug_ft', 'de_ft', 'mug_ft', 'mde_ft'): |
---|
| 283 | return True |
---|
[13454] | 284 | if category == 'hostel_maintenance' and \ |
---|
| 285 | 'maint_all' in academic_session.payment_disabled: |
---|
| 286 | return True |
---|
| 287 | return False |
---|
| 288 | |
---|
[9154] | 289 | def setPaymentDetails(self, category, student, |
---|
[15667] | 290 | previous_session=None, previous_level=None, combi=[]): |
---|
[8600] | 291 | """Create Payment object and set the payment data of a student for |
---|
| 292 | the payment category specified. |
---|
| 293 | |
---|
| 294 | """ |
---|
[8306] | 295 | details = {} |
---|
[8600] | 296 | p_item = u'' |
---|
| 297 | amount = 0.0 |
---|
| 298 | error = u'' |
---|
[9154] | 299 | if previous_session: |
---|
[14544] | 300 | if previous_session < student['studycourse'].entry_session: |
---|
| 301 | return _('The previous session must not fall below ' |
---|
| 302 | 'your entry session.'), None |
---|
| 303 | if category == 'schoolfee': |
---|
| 304 | # School fee is always paid for the following session |
---|
| 305 | if previous_session > student['studycourse'].current_session: |
---|
| 306 | return _('This is not a previous session.'), None |
---|
| 307 | else: |
---|
| 308 | if previous_session > student['studycourse'].current_session - 1: |
---|
| 309 | return _('This is not a previous session.'), None |
---|
| 310 | p_session = previous_session |
---|
| 311 | p_level = previous_level |
---|
| 312 | p_current = False |
---|
| 313 | else: |
---|
| 314 | p_session = student['studycourse'].current_session |
---|
| 315 | p_level = student['studycourse'].current_level |
---|
| 316 | p_current = True |
---|
[9527] | 317 | academic_session = self._getSessionConfiguration(p_session) |
---|
| 318 | if academic_session == None: |
---|
[8600] | 319 | return _(u'Session configuration object is not available.'), None |
---|
[8677] | 320 | # Determine fee. |
---|
[7151] | 321 | if category == 'transfer': |
---|
[8600] | 322 | amount = academic_session.transfer_fee |
---|
[14296] | 323 | elif category == 'transcript_local': |
---|
| 324 | amount = academic_session.transcript_fee_local |
---|
| 325 | elif category == 'transcript_inter': |
---|
| 326 | amount = academic_session.transcript_fee_inter |
---|
[7151] | 327 | elif category == 'bed_allocation': |
---|
[17266] | 328 | acco_details = self.getAccommodationDetails(student) |
---|
| 329 | p_session = acco_details['booking_session'] |
---|
| 330 | p_item = acco_details['bt'] |
---|
[8600] | 331 | amount = academic_session.booking_fee |
---|
[7151] | 332 | elif category == 'hostel_maintenance': |
---|
[13418] | 333 | amount = 0.0 |
---|
[17266] | 334 | booking_session = grok.getSite()['hostels'].accommodation_session |
---|
| 335 | bedticket = student['accommodation'].get(str(booking_session), None) |
---|
[13502] | 336 | if bedticket is not None and bedticket.bed is not None: |
---|
[17266] | 337 | p_session = booking_session |
---|
[13474] | 338 | p_item = bedticket.display_coordinates |
---|
[13418] | 339 | if bedticket.bed.__parent__.maint_fee > 0: |
---|
| 340 | amount = bedticket.bed.__parent__.maint_fee |
---|
| 341 | else: |
---|
| 342 | # fallback |
---|
| 343 | amount = academic_session.maint_fee |
---|
| 344 | else: |
---|
[13506] | 345 | return _(u'No bed allocated.'), None |
---|
[13636] | 346 | elif student.current_mode == 'found' and category not in ( |
---|
| 347 | 'schoolfee', 'clearance', 'late_registration'): |
---|
| 348 | return _('Not allowed.'), None |
---|
[13400] | 349 | elif category.startswith('clearance'): |
---|
[13594] | 350 | if student.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED): |
---|
| 351 | return _(u'Acceptance Fee payments not allowed.'), None |
---|
[17431] | 352 | try: |
---|
| 353 | certificate = student['studycourse'].certificate |
---|
| 354 | p_item = certificate.code |
---|
| 355 | except (AttributeError, TypeError): |
---|
| 356 | return _('Study course data are incomplete.'), None |
---|
[13855] | 357 | if student.current_mode in ( |
---|
| 358 | 'ug_ft', 'ug_pt', 'de_ft', 'de_pt', |
---|
| 359 | 'transfer', 'mug_ft', 'mde_ft') \ |
---|
| 360 | and category != 'clearance_incl': |
---|
| 361 | return _("Additional fees must be included."), None |
---|
[15393] | 362 | elif student.current_mode == 'special_pg_ft': |
---|
[13853] | 363 | if category != 'clearance': |
---|
[13854] | 364 | return _("No additional fees required."), None |
---|
[17431] | 365 | try: |
---|
[17444] | 366 | acceptancefees = ACCEPTANCEFEES[student.certcode] |
---|
[17431] | 367 | except KeyError: |
---|
| 368 | return _('Acceptance fees not yet fixed.'), None |
---|
| 369 | if category == 'clearance_incl': |
---|
[17444] | 370 | for item in acceptancefees[1]: |
---|
[17431] | 371 | try: |
---|
| 372 | amount += int(item) |
---|
| 373 | except: |
---|
| 374 | pass |
---|
[11653] | 375 | else: |
---|
[17444] | 376 | amount = float(acceptancefees[0]) |
---|
[11004] | 377 | elif category == 'late_registration': |
---|
[14117] | 378 | if student.is_postgrad: |
---|
| 379 | amount = academic_session.late_pg_registration_fee |
---|
| 380 | else: |
---|
| 381 | amount = academic_session.late_registration_fee |
---|
[16667] | 382 | elif category == 'ict': |
---|
| 383 | if student.is_fresh: |
---|
| 384 | amount = 2200 |
---|
| 385 | else: |
---|
| 386 | amount = 1200 |
---|
[13400] | 387 | elif category.startswith('schoolfee'): |
---|
[8600] | 388 | try: |
---|
[8753] | 389 | certificate = student['studycourse'].certificate |
---|
| 390 | p_item = certificate.code |
---|
[8600] | 391 | except (AttributeError, TypeError): |
---|
| 392 | return _('Study course data are incomplete.'), None |
---|
[17431] | 393 | try: |
---|
[17446] | 394 | if student.entry_session < 2013: |
---|
[17447] | 395 | schoolfees = SCHOOLFEES[12][student.certcode] |
---|
[17446] | 396 | elif student.entry_session < 2014: |
---|
[17447] | 397 | schoolfees = SCHOOLFEES[13][student.certcode] |
---|
[17455] | 398 | elif student.entry_session < 2015: |
---|
[17447] | 399 | schoolfees = SCHOOLFEES[14][student.certcode] |
---|
[17446] | 400 | elif student.entry_session < 2020: |
---|
[17455] | 401 | schoolfees = SCHOOLFEES[15][student.certcode] |
---|
[17445] | 402 | elif student.entry_session < 2021: |
---|
[17447] | 403 | schoolfees = SCHOOLFEES[20][student.certcode] |
---|
[17445] | 404 | elif student.entry_session < 2022: |
---|
[17447] | 405 | schoolfees = SCHOOLFEES[21][student.certcode] |
---|
[17580] | 406 | elif student.entry_session < 2023: |
---|
| 407 | schoolfees = SCHOOLFEES[22][student.certcode] |
---|
[17878] | 408 | elif student.entry_session < 2024: |
---|
| 409 | schoolfees = SCHOOLFEES[23][student.certcode] |
---|
[17444] | 410 | else: |
---|
[17878] | 411 | schoolfees = SCHOOLFEES[24][student.certcode] |
---|
[17431] | 412 | except KeyError: |
---|
| 413 | return _('School fees not yet fixed.'), None |
---|
[17510] | 414 | #if student.is_postgrad and category != 'schoolfee': |
---|
| 415 | # return _("No additional fees required."), None |
---|
[14544] | 416 | if not previous_session and student.current_mode in ( |
---|
[13855] | 417 | 'ug_ft', 'ug_pt', 'de_ft', 'de_pt', |
---|
| 418 | 'transfer', 'mug_ft', 'mde_ft') \ |
---|
| 419 | and not category in ( |
---|
| 420 | 'schoolfee_incl', 'schoolfee_1', 'schoolfee_2'): |
---|
[14244] | 421 | return _("You must choose a payment which includes " |
---|
[13855] | 422 | "additional fees."), None |
---|
[13780] | 423 | if category in ('schoolfee_1', 'schoolfee_2'): |
---|
[17507] | 424 | #if student.current_mode == 'ug_pt': |
---|
| 425 | # return _("Part-time students are not allowed " |
---|
| 426 | # "to pay by instalments."), None |
---|
[14241] | 427 | if student.entry_session < 2015: |
---|
| 428 | return _("You are not allowed " |
---|
| 429 | "to pay by instalments."), None |
---|
[17431] | 430 | additional = 0.0 |
---|
[17444] | 431 | for item in schoolfees[1]: |
---|
[17431] | 432 | try: |
---|
| 433 | additional += int(item) |
---|
| 434 | except: |
---|
[17494] | 435 | # 100_ indicates first year payment only |
---|
| 436 | if student.state == CLEARED: |
---|
| 437 | try: |
---|
| 438 | additional += int(item.split('_')[1]) |
---|
| 439 | except: |
---|
| 440 | pass |
---|
[17444] | 441 | amount = float(schoolfees[0]) |
---|
[17431] | 442 | additional -= amount |
---|
[14544] | 443 | if previous_session: |
---|
| 444 | # Students can pay for previous sessions in all |
---|
| 445 | # workflow states. Fresh students are excluded by the |
---|
| 446 | # update method of the PreviousPaymentAddFormPage. |
---|
[17481] | 447 | # Cut school fee by 50% |
---|
| 448 | if category in ('schoolfee_1', 'schoolfee_2') and amount: |
---|
| 449 | amount /= 2 |
---|
[17057] | 450 | pass |
---|
| 451 | elif student.state == CLEARED: |
---|
[13512] | 452 | # Cut school fee by 50% |
---|
[17057] | 453 | if category in ('schoolfee_1', 'schoolfee_2') and amount: |
---|
[17431] | 454 | amount /= 2 |
---|
[14396] | 455 | elif student.state == RETURNING and category != 'schoolfee_2': |
---|
[13482] | 456 | if not student.father_name: |
---|
| 457 | return _("Personal data form is not properly filled."), None |
---|
[13374] | 458 | # In case of returning school fee payment the payment session |
---|
| 459 | # and level contain the values of the session the student |
---|
| 460 | # has paid for. |
---|
| 461 | p_session, p_level = self.getReturningData(student) |
---|
[8961] | 462 | try: |
---|
| 463 | academic_session = grok.getSite()[ |
---|
| 464 | 'configuration'][str(p_session)] |
---|
| 465 | except KeyError: |
---|
| 466 | return _(u'Session configuration object is not available.'), None |
---|
[14954] | 467 | # Cut school fee by 50% |
---|
| 468 | if category == 'schoolfee_1' and amount: |
---|
[17431] | 469 | amount /= 2 |
---|
[17057] | 470 | elif category == 'schoolfee_2' and amount: |
---|
[17431] | 471 | amount /= 2 |
---|
[8600] | 472 | else: |
---|
[8753] | 473 | return _('Wrong state.'), None |
---|
[13417] | 474 | if amount in (0.0, None): |
---|
| 475 | return _(u'Amount could not be determined.'), None |
---|
[17431] | 476 | # Add additional fees |
---|
| 477 | if category in ('schoolfee_incl', 'schoolfee_1'): |
---|
| 478 | amount += additional |
---|
[15763] | 479 | # Add non-indigenous fee and session specific penalty fees |
---|
[13534] | 480 | if student.is_postgrad: |
---|
| 481 | amount += academic_session.penalty_pg |
---|
[17500] | 482 | if student.lga and not student.lga.startswith('edo') \ |
---|
| 483 | and student.entry_session < 2022: |
---|
[15763] | 484 | amount += 20000.0 |
---|
[13534] | 485 | else: |
---|
| 486 | amount += academic_session.penalty_ug |
---|
[14248] | 487 | elif not student.is_postgrad: |
---|
| 488 | fee_name = category + '_fee' |
---|
| 489 | amount = getattr(academic_session, fee_name, 0.0) |
---|
[8600] | 490 | if amount in (0.0, None): |
---|
| 491 | return _(u'Amount could not be determined.'), None |
---|
[8677] | 492 | # Create ticket. |
---|
[8600] | 493 | for key in student['payments'].keys(): |
---|
| 494 | ticket = student['payments'][key] |
---|
| 495 | if ticket.p_state == 'paid' and\ |
---|
| 496 | ticket.p_category == category and \ |
---|
[15096] | 497 | not ticket.p_category.startswith('transcript') and \ |
---|
[8600] | 498 | ticket.p_item == p_item and \ |
---|
| 499 | ticket.p_session == p_session: |
---|
| 500 | return _('This type of payment has already been made.'), None |
---|
[13786] | 501 | # Additional condition in AAUE |
---|
| 502 | if category in ('schoolfee', 'schoolfee_incl', 'schoolfee_1'): |
---|
| 503 | if ticket.p_state == 'paid' and \ |
---|
| 504 | ticket.p_category in ('schoolfee', |
---|
| 505 | 'schoolfee_incl', |
---|
| 506 | 'schoolfee_1') and \ |
---|
| 507 | ticket.p_item == p_item and \ |
---|
| 508 | ticket.p_session == p_session: |
---|
| 509 | return _( |
---|
| 510 | 'Another school fee payment for this ' |
---|
| 511 | 'session has already been made.'), None |
---|
| 512 | |
---|
[11455] | 513 | if self._isPaymentDisabled(p_session, category, student): |
---|
[13798] | 514 | return _('This category of payments has been disabled.'), None |
---|
[8712] | 515 | payment = createObject(u'waeup.StudentOnlinePayment') |
---|
[8954] | 516 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
[8600] | 517 | payment.p_id = "p%s" % timestamp |
---|
| 518 | payment.p_category = category |
---|
| 519 | payment.p_item = p_item |
---|
| 520 | payment.p_session = p_session |
---|
| 521 | payment.p_level = p_level |
---|
[9154] | 522 | payment.p_current = p_current |
---|
[8600] | 523 | payment.amount_auth = amount |
---|
| 524 | return None, payment |
---|
[7621] | 525 | |
---|
[10922] | 526 | def _admissionText(self, student, portal_language): |
---|
| 527 | inst_name = grok.getSite()['configuration'].name |
---|
| 528 | entry_session = student['studycourse'].entry_session |
---|
| 529 | entry_session = academic_sessions_vocab.getTerm(entry_session).title |
---|
| 530 | text = trans(_( |
---|
[10953] | 531 | 'This is to inform you that you have been offered provisional' |
---|
| 532 | ' admission into ${a} for the ${b} academic session as follows:', |
---|
[10922] | 533 | mapping = {'a': inst_name, 'b': entry_session}), |
---|
| 534 | portal_language) |
---|
| 535 | return text |
---|
| 536 | |
---|
[17892] | 537 | def deactivated_warnCreditsOOR(self, studylevel, course=None): |
---|
[14733] | 538 | studycourse = studylevel.__parent__ |
---|
| 539 | certificate = getattr(studycourse,'certificate', None) |
---|
| 540 | current_level = studycourse.current_level |
---|
| 541 | if None in (current_level, certificate): |
---|
| 542 | return |
---|
| 543 | end_level = certificate.end_level |
---|
| 544 | if current_level >= end_level: |
---|
| 545 | limit = 52 |
---|
| 546 | else: |
---|
| 547 | limit = 48 |
---|
| 548 | if course and studylevel.total_credits + course.credits > limit: |
---|
[14585] | 549 | return _('Maximum credits exceeded.') |
---|
[14733] | 550 | elif studylevel.total_credits > limit: |
---|
[14585] | 551 | return _('Maximum credits exceeded.') |
---|
| 552 | return |
---|
[10051] | 553 | |
---|
[17892] | 554 | def warnCreditsOOR(self, studylevel, course=None): |
---|
| 555 | if course and studylevel.total_credits + course.credits > 48: |
---|
| 556 | return _('Maximum credits exceeded.') |
---|
| 557 | elif studylevel.total_credits > 48: |
---|
| 558 | return _('Maximum credits exceeded.') |
---|
| 559 | return |
---|
| 560 | |
---|
[13353] | 561 | def getBedCoordinates(self, bedticket): |
---|
| 562 | """Return descriptive bed coordinates. |
---|
| 563 | This method can be used to customize the `display_coordinates` |
---|
| 564 | property method in order to display a |
---|
| 565 | customary description of the bed space. |
---|
| 566 | """ |
---|
| 567 | bc = bedticket.bed_coordinates.split(',') |
---|
| 568 | if len(bc) == 4: |
---|
| 569 | return bc[0] |
---|
| 570 | return bedticket.bed_coordinates |
---|
| 571 | |
---|
[17739] | 572 | ACCOMMODATION_SPAN = 999 |
---|
| 573 | |
---|
[17559] | 574 | def getAccommodationDetails(self, student): |
---|
[13415] | 575 | """Determine the accommodation data of a student. |
---|
[17530] | 576 | We are usimng the base package method again. |
---|
[13415] | 577 | """ |
---|
| 578 | d = {} |
---|
| 579 | d['error'] = u'' |
---|
| 580 | hostels = grok.getSite()['hostels'] |
---|
| 581 | d['booking_session'] = hostels.accommodation_session |
---|
| 582 | d['allowed_states'] = hostels.accommodation_states |
---|
| 583 | d['startdate'] = hostels.startdate |
---|
| 584 | d['enddate'] = hostels.enddate |
---|
| 585 | d['expired'] = hostels.expired |
---|
| 586 | # Determine bed type |
---|
[13416] | 587 | bt = 'all' |
---|
[13415] | 588 | if student.sex == 'f': |
---|
| 589 | sex = 'female' |
---|
| 590 | else: |
---|
| 591 | sex = 'male' |
---|
| 592 | special_handling = 'regular' |
---|
| 593 | d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt) |
---|
| 594 | return d |
---|
| 595 | |
---|
[13753] | 596 | def checkAccommodationRequirements(self, student, acc_details): |
---|
[14238] | 597 | msg = super(CustomStudentsUtils, self).checkAccommodationRequirements( |
---|
[13753] | 598 | student, acc_details) |
---|
[14238] | 599 | if msg: |
---|
| 600 | return msg |
---|
[13753] | 601 | if student.current_mode not in ('ug_ft', 'de_ft', 'mug_ft', 'mde_ft'): |
---|
| 602 | return _('You are not eligible to book accommodation.') |
---|
| 603 | return |
---|
| 604 | |
---|
[8444] | 605 | # AAUE prefix |
---|
[14593] | 606 | STUDENT_ID_PREFIX = u'E' |
---|
| 607 | |
---|
[15925] | 608 | STUDENT_EXPORTER_NAMES = ( |
---|
| 609 | 'students', |
---|
| 610 | 'studentstudycourses', |
---|
[16896] | 611 | 'studentstudycourses_1', |
---|
[15925] | 612 | 'studentstudylevels', |
---|
[16896] | 613 | #'studentstudylevels_1', |
---|
[15925] | 614 | 'coursetickets', |
---|
[16896] | 615 | #'coursetickets_1', |
---|
[15925] | 616 | 'studentpayments', |
---|
| 617 | 'bedtickets', |
---|
| 618 | 'unpaidpayments', |
---|
| 619 | 'sfpaymentsoverview', |
---|
| 620 | 'studylevelsoverview', |
---|
| 621 | 'combocard', |
---|
| 622 | 'bursary', |
---|
[15874] | 623 | 'levelreportdata', |
---|
[15925] | 624 | 'outstandingcourses', |
---|
[15897] | 625 | 'sessionpaymentsoverview', |
---|
[15925] | 626 | 'accommodationpayments', |
---|
[16033] | 627 | 'transcriptdata', |
---|
| 628 | 'trimmedpayments', |
---|
| 629 | 'trimmed', |
---|
[16859] | 630 | 'outstandingcourses_2' |
---|
[16033] | 631 | ) |
---|
[15948] | 632 | |
---|
| 633 | # Maximum size of upload files in kB |
---|
| 634 | MAX_KB = 500 |
---|