[7419] | 1 | ## $Id: utils.py 14918 2017-11-30 12:57:05Z 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 |
---|
[8600] | 19 | from time import time |
---|
[14918] | 20 | from zope.component import createObject, queryUtility |
---|
| 21 | from zope.catalog.interfaces import ICatalog |
---|
[10922] | 22 | from waeup.kofa.interfaces import ( |
---|
[13594] | 23 | ADMITTED, CLEARANCE, REQUESTED, CLEARED, RETURNING, PAID, |
---|
| 24 | academic_sessions_vocab) |
---|
[8823] | 25 | from kofacustom.nigeria.students.utils import NigeriaStudentsUtils |
---|
[8247] | 26 | from waeup.kofa.accesscodes import create_accesscode |
---|
[10922] | 27 | from waeup.kofa.students.utils import trans |
---|
[13720] | 28 | from waeup.aaue.interswitch.browser import gateway_net_amt, GATEWAY_AMT |
---|
[8444] | 29 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
[6902] | 30 | |
---|
[14663] | 31 | MINIMUM_UNITS_THRESHOLD = 15 |
---|
| 32 | |
---|
[8823] | 33 | class CustomStudentsUtils(NigeriaStudentsUtils): |
---|
[7151] | 34 | """A collection of customized methods. |
---|
| 35 | |
---|
| 36 | """ |
---|
| 37 | |
---|
[14242] | 38 | PORTRAIT_CHANGE_STATES = (ADMITTED,) |
---|
[13348] | 39 | |
---|
[14918] | 40 | def GPABoundaries(self, faccode=None, depcode=None, |
---|
| 41 | certcode=None, student=None): |
---|
| 42 | if student and student.current_mode.startswith('dp'): |
---|
| 43 | return ((1.5, 'Fail'), |
---|
| 44 | (2.4, 'Pass'), |
---|
| 45 | (3.5, 'Merit'), |
---|
| 46 | (4.5, 'Credit'), |
---|
| 47 | (5, 'Distinction')) |
---|
| 48 | elif student: |
---|
| 49 | return ((1, 'FRNS / NER / NYV'), |
---|
| 50 | (1.5, 'Pass'), |
---|
| 51 | (2.4, '3rd Class Honours'), |
---|
| 52 | (3.5, '2nd Class Honours Lower Division'), |
---|
| 53 | (4.5, '2nd Class Honours Upper Division'), |
---|
| 54 | (5, '1st Class Honours')) |
---|
| 55 | # Session Results Presentations depend on certificate |
---|
| 56 | results = None |
---|
| 57 | if certcode: |
---|
| 58 | cat = queryUtility(ICatalog, name='certificates_catalog') |
---|
| 59 | results = list( |
---|
| 60 | cat.searchResults(code=(certcode, certcode))) |
---|
| 61 | if results and results[0].study_mode.startswith('dp'): |
---|
| 62 | return ((1.5, 'Fail'), |
---|
| 63 | (2.4, 'Pass'), |
---|
| 64 | (3.5, 'Merit'), |
---|
| 65 | (4.5, 'Credit'), |
---|
| 66 | (5, 'Distinction')) |
---|
| 67 | else: |
---|
| 68 | return ((1, 'FRNS / NER / NYV'), |
---|
| 69 | (1.5, 'Pass'), |
---|
| 70 | (2.4, '3rd Class Honours'), |
---|
| 71 | (3.5, '2nd Class Honours Lower Division'), |
---|
| 72 | (4.5, '2nd Class Honours Upper Division'), |
---|
| 73 | (5, '1st Class Honours')) |
---|
[14899] | 74 | |
---|
[14462] | 75 | def getClassFromCGPA(self, gpa, student): |
---|
[14918] | 76 | gpa_boundaries = self.GPABoundaries(student=student) |
---|
[14899] | 77 | if gpa < gpa_boundaries[0][0]: |
---|
| 78 | # FRNS / Fail |
---|
| 79 | return 0, gpa_boundaries[0][1] |
---|
| 80 | if student.entry_session < 2013 and \ |
---|
| 81 | not student.current_mode.startswith('dp'): |
---|
| 82 | if gpa < gpa_boundaries[1][0]: |
---|
[14462] | 83 | # Pass |
---|
[14899] | 84 | return 1, gpa_boundaries[1][1] |
---|
[14462] | 85 | else: |
---|
[14899] | 86 | if gpa < gpa_boundaries[1][0]: |
---|
[14462] | 87 | # FRNS (Pass degree has been phased out in 2013) |
---|
[14899] | 88 | return 0, gpa_boundaries[0][1] |
---|
| 89 | if gpa < gpa_boundaries[2][0]: |
---|
| 90 | # 3rd / Pass |
---|
| 91 | return 2, gpa_boundaries[2][1] |
---|
| 92 | if gpa < gpa_boundaries[3][0]: |
---|
| 93 | # 2nd L / Merit |
---|
| 94 | return 3, gpa_boundaries[3][1] |
---|
| 95 | if gpa < gpa_boundaries[4][0]: |
---|
| 96 | # 2nd U / Credit |
---|
| 97 | return 4, gpa_boundaries[4][1] |
---|
| 98 | if gpa <= gpa_boundaries[5][0]: |
---|
| 99 | # 1st / Distinction |
---|
| 100 | return 5, gpa_boundaries[5][1] |
---|
[14462] | 101 | return 'N/A' |
---|
| 102 | |
---|
[14160] | 103 | def getDegreeClassNumber(self, level_obj): |
---|
[14415] | 104 | """Get degree class number (used for SessionResultsPresentation |
---|
| 105 | reports). |
---|
| 106 | """ |
---|
[14459] | 107 | certificate = getattr(level_obj.__parent__,'certificate', None) |
---|
[14160] | 108 | end_level = getattr(certificate, 'end_level', None) |
---|
[14459] | 109 | if end_level and level_obj.level >= end_level: |
---|
[14464] | 110 | if level_obj.level > end_level: |
---|
| 111 | # spill-over level |
---|
[14476] | 112 | if level_obj.gpa_params[1] == 0: |
---|
[14464] | 113 | # no credits taken |
---|
| 114 | return 0 |
---|
[14663] | 115 | elif level_obj.gpa_params[1] < MINIMUM_UNITS_THRESHOLD: |
---|
[14537] | 116 | # credits taken below limit |
---|
| 117 | return 0 |
---|
[14160] | 118 | failed_courses = level_obj.passed_params[4] |
---|
[14411] | 119 | not_taken_courses = level_obj.passed_params[5] |
---|
[14160] | 120 | if '_m' in failed_courses: |
---|
| 121 | return 0 |
---|
[14441] | 122 | if len(not_taken_courses) \ |
---|
[14506] | 123 | and not not_taken_courses == 'Nil': |
---|
[14411] | 124 | return 0 |
---|
[14663] | 125 | elif level_obj.gpa_params[1] < MINIMUM_UNITS_THRESHOLD: |
---|
[14464] | 126 | # credits taken below limit |
---|
| 127 | return 0 |
---|
[14487] | 128 | if level_obj.level_verdict in ('FRNS', 'NER', 'NYV'): |
---|
[14464] | 129 | return 0 |
---|
[14160] | 130 | # use gpa_boundaries above |
---|
[14462] | 131 | return self.getClassFromCGPA( |
---|
| 132 | level_obj.cumulative_params[0], level_obj.student)[0] |
---|
[14160] | 133 | |
---|
[13359] | 134 | def increaseMatricInteger(self, student): |
---|
| 135 | """Increase counter for matric numbers. |
---|
| 136 | This counter can be a centrally stored attribute or an attribute of |
---|
| 137 | faculties, departments or certificates. In the base package the counter |
---|
| 138 | is as an attribute of the site configuration container. |
---|
| 139 | """ |
---|
| 140 | if student.current_mode in ('ug_pt', 'de_pt'): |
---|
| 141 | grok.getSite()['configuration'].next_matric_integer += 1 |
---|
| 142 | return |
---|
[13609] | 143 | elif student.is_postgrad: |
---|
| 144 | grok.getSite()['configuration'].next_matric_integer_3 += 1 |
---|
| 145 | return |
---|
[13793] | 146 | elif student.current_mode in ('dp_ft',): |
---|
| 147 | grok.getSite()['configuration'].next_matric_integer_4 += 1 |
---|
| 148 | return |
---|
[13359] | 149 | grok.getSite()['configuration'].next_matric_integer_2 += 1 |
---|
| 150 | return |
---|
| 151 | |
---|
[13749] | 152 | def _concessionalPaymentMade(self, student): |
---|
| 153 | if len(student['payments']): |
---|
| 154 | for ticket in student['payments'].values(): |
---|
| 155 | if ticket.p_state == 'paid' and \ |
---|
| 156 | ticket.p_category == 'concessional': |
---|
| 157 | return True |
---|
| 158 | return False |
---|
| 159 | |
---|
[11596] | 160 | def constructMatricNumber(self, student): |
---|
[11593] | 161 | faccode = student.faccode |
---|
| 162 | depcode = student.depcode |
---|
[13609] | 163 | certcode = student.certcode |
---|
[13664] | 164 | degree = getattr( |
---|
| 165 | getattr(student.get('studycourse', None), 'certificate', None), |
---|
| 166 | 'degree', None) |
---|
[11593] | 167 | year = unicode(student.entry_session)[2:] |
---|
[13359] | 168 | if not student.state in (PAID, ) or not student.is_fresh or \ |
---|
[14615] | 169 | student.current_mode in ('found', 'ijmbe'): |
---|
[13359] | 170 | return _('Matriculation number cannot be set.'), None |
---|
[13755] | 171 | #if student.current_mode not in ('mug_ft', 'mde_ft') and \ |
---|
| 172 | # not self._concessionalPaymentMade(student): |
---|
| 173 | # return _('Matriculation number cannot be set.'), None |
---|
[13571] | 174 | if student.is_postgrad: |
---|
[13609] | 175 | next_integer = grok.getSite()['configuration'].next_matric_integer_3 |
---|
[13664] | 176 | if not degree or next_integer == 0: |
---|
[13609] | 177 | return _('Matriculation number cannot be set.'), None |
---|
[13846] | 178 | if student.faccode in ('IOE'): |
---|
| 179 | return None, "AAU/SPS/%s/%s/%s/%05d" % ( |
---|
| 180 | faccode, year, degree, next_integer) |
---|
[13609] | 181 | return None, "AAU/SPS/%s/%s/%s/%s/%05d" % ( |
---|
[13664] | 182 | faccode, depcode, year, degree, next_integer) |
---|
[13359] | 183 | if student.current_mode in ('ug_pt', 'de_pt'): |
---|
| 184 | next_integer = grok.getSite()['configuration'].next_matric_integer |
---|
| 185 | if next_integer == 0: |
---|
| 186 | return _('Matriculation number cannot be set.'), None |
---|
[12975] | 187 | return None, "PTP/%s/%s/%s/%05d" % ( |
---|
| 188 | faccode, depcode, year, next_integer) |
---|
[13793] | 189 | if student.current_mode in ('dp_ft',): |
---|
| 190 | next_integer = grok.getSite()['configuration'].next_matric_integer_4 |
---|
| 191 | if next_integer == 0: |
---|
| 192 | return _('Matriculation number cannot be set.'), None |
---|
| 193 | return None, "IOE/DIP/%s/%05d" % (year, next_integer) |
---|
[13359] | 194 | next_integer = grok.getSite()['configuration'].next_matric_integer_2 |
---|
| 195 | if next_integer == 0: |
---|
| 196 | return _('Matriculation number cannot be set.'), None |
---|
| 197 | if student.faccode in ('FBM', 'FCS'): |
---|
| 198 | return None, "CMS/%s/%s/%s/%05d" % ( |
---|
| 199 | faccode, depcode, year, next_integer) |
---|
| 200 | return None, "%s/%s/%s/%05d" % (faccode, depcode, year, next_integer) |
---|
[12975] | 201 | |
---|
[8270] | 202 | def getReturningData(self, student): |
---|
| 203 | """ This method defines what happens after school fee payment |
---|
[8319] | 204 | of returning students depending on the student's senate verdict. |
---|
[8270] | 205 | """ |
---|
[8319] | 206 | prev_level = student['studycourse'].current_level |
---|
| 207 | cur_verdict = student['studycourse'].current_verdict |
---|
[14089] | 208 | if cur_verdict in ('A','B','C', 'L','M','N','Z',): |
---|
[8319] | 209 | # Successful student |
---|
| 210 | new_level = divmod(int(prev_level),100)[0]*100 + 100 |
---|
[14089] | 211 | #elif cur_verdict == 'C': |
---|
| 212 | # # Student on probation |
---|
| 213 | # new_level = int(prev_level) + 10 |
---|
[8319] | 214 | else: |
---|
| 215 | # Student is somehow in an undefined state. |
---|
| 216 | # Level has to be set manually. |
---|
| 217 | new_level = prev_level |
---|
[8270] | 218 | new_session = student['studycourse'].current_session + 1 |
---|
| 219 | return new_session, new_level |
---|
| 220 | |
---|
[13454] | 221 | def _isPaymentDisabled(self, p_session, category, student): |
---|
| 222 | academic_session = self._getSessionConfiguration(p_session) |
---|
[14246] | 223 | if category.startswith('schoolfee'): |
---|
| 224 | if 'sf_all' in academic_session.payment_disabled: |
---|
| 225 | return True |
---|
| 226 | if 'sf_pg' in academic_session.payment_disabled and \ |
---|
| 227 | student.is_postgrad: |
---|
| 228 | return True |
---|
[14571] | 229 | if 'sf_ug_pt' in academic_session.payment_disabled and \ |
---|
| 230 | student.current_mode in ('ug_pt', 'de_pt'): |
---|
[14246] | 231 | return True |
---|
| 232 | if 'sf_found' in academic_session.payment_disabled and \ |
---|
| 233 | student.current_mode == 'found': |
---|
| 234 | return True |
---|
[13794] | 235 | if category.startswith('clearance') and \ |
---|
| 236 | 'cl_regular' in academic_session.payment_disabled and \ |
---|
| 237 | student.current_mode in ('ug_ft', 'de_ft', 'mug_ft', 'mde_ft'): |
---|
| 238 | return True |
---|
[13454] | 239 | if category == 'hostel_maintenance' and \ |
---|
| 240 | 'maint_all' in academic_session.payment_disabled: |
---|
| 241 | return True |
---|
| 242 | return False |
---|
| 243 | |
---|
[9154] | 244 | def setPaymentDetails(self, category, student, |
---|
| 245 | previous_session=None, previous_level=None): |
---|
[8600] | 246 | """Create Payment object and set the payment data of a student for |
---|
| 247 | the payment category specified. |
---|
| 248 | |
---|
| 249 | """ |
---|
[8306] | 250 | details = {} |
---|
[8600] | 251 | p_item = u'' |
---|
| 252 | amount = 0.0 |
---|
| 253 | error = u'' |
---|
[9154] | 254 | if previous_session: |
---|
[14544] | 255 | if previous_session < student['studycourse'].entry_session: |
---|
| 256 | return _('The previous session must not fall below ' |
---|
| 257 | 'your entry session.'), None |
---|
| 258 | if category == 'schoolfee': |
---|
| 259 | # School fee is always paid for the following session |
---|
| 260 | if previous_session > student['studycourse'].current_session: |
---|
| 261 | return _('This is not a previous session.'), None |
---|
| 262 | else: |
---|
| 263 | if previous_session > student['studycourse'].current_session - 1: |
---|
| 264 | return _('This is not a previous session.'), None |
---|
| 265 | p_session = previous_session |
---|
| 266 | p_level = previous_level |
---|
| 267 | p_current = False |
---|
| 268 | else: |
---|
| 269 | p_session = student['studycourse'].current_session |
---|
| 270 | p_level = student['studycourse'].current_level |
---|
| 271 | p_current = True |
---|
[9527] | 272 | academic_session = self._getSessionConfiguration(p_session) |
---|
| 273 | if academic_session == None: |
---|
[8600] | 274 | return _(u'Session configuration object is not available.'), None |
---|
[8677] | 275 | # Determine fee. |
---|
[7151] | 276 | if category == 'transfer': |
---|
[8600] | 277 | amount = academic_session.transfer_fee |
---|
[14296] | 278 | elif category == 'transcript_local': |
---|
| 279 | amount = academic_session.transcript_fee_local |
---|
| 280 | elif category == 'transcript_inter': |
---|
| 281 | amount = academic_session.transcript_fee_inter |
---|
[7151] | 282 | elif category == 'bed_allocation': |
---|
[8600] | 283 | amount = academic_session.booking_fee |
---|
[14378] | 284 | elif category == 'restitution': |
---|
[14660] | 285 | if student.entry_session >= 2016 \ |
---|
| 286 | or student.current_mode not in ('ug_ft', 'dp_ft'): |
---|
[14378] | 287 | return _(u'Restitution fee payment not required.'), None |
---|
| 288 | amount = academic_session.restitution_fee |
---|
[7151] | 289 | elif category == 'hostel_maintenance': |
---|
[13418] | 290 | amount = 0.0 |
---|
| 291 | bedticket = student['accommodation'].get( |
---|
| 292 | str(student.current_session), None) |
---|
[13502] | 293 | if bedticket is not None and bedticket.bed is not None: |
---|
[13474] | 294 | p_item = bedticket.display_coordinates |
---|
[13418] | 295 | if bedticket.bed.__parent__.maint_fee > 0: |
---|
| 296 | amount = bedticket.bed.__parent__.maint_fee |
---|
| 297 | else: |
---|
| 298 | # fallback |
---|
| 299 | amount = academic_session.maint_fee |
---|
| 300 | else: |
---|
[13506] | 301 | return _(u'No bed allocated.'), None |
---|
[13636] | 302 | elif student.current_mode == 'found' and category not in ( |
---|
| 303 | 'schoolfee', 'clearance', 'late_registration'): |
---|
| 304 | return _('Not allowed.'), None |
---|
[13400] | 305 | elif category.startswith('clearance'): |
---|
[13594] | 306 | if student.state not in (ADMITTED, CLEARANCE, REQUESTED, CLEARED): |
---|
| 307 | return _(u'Acceptance Fee payments not allowed.'), None |
---|
[13855] | 308 | if student.current_mode in ( |
---|
| 309 | 'ug_ft', 'ug_pt', 'de_ft', 'de_pt', |
---|
| 310 | 'transfer', 'mug_ft', 'mde_ft') \ |
---|
| 311 | and category != 'clearance_incl': |
---|
| 312 | return _("Additional fees must be included."), None |
---|
[14518] | 313 | if student.current_mode == 'ijmbe': |
---|
| 314 | amount = academic_session.clearance_fee_ijmbe |
---|
| 315 | elif student.faccode == 'FP': |
---|
[11653] | 316 | amount = academic_session.clearance_fee_fp |
---|
[13377] | 317 | elif student.current_mode.endswith('_pt'): |
---|
[13678] | 318 | if student.is_postgrad: |
---|
| 319 | amount = academic_session.clearance_fee_pg_pt |
---|
| 320 | else: |
---|
| 321 | amount = academic_session.clearance_fee_ug_pt |
---|
[13466] | 322 | elif student.faccode == 'FCS': |
---|
| 323 | # Students in clinical medical sciences pay the medical |
---|
| 324 | # acceptance fee |
---|
[13377] | 325 | amount = academic_session.clearance_fee_med |
---|
[13678] | 326 | elif student.is_postgrad: # and not part-time |
---|
[13853] | 327 | if category != 'clearance': |
---|
[13854] | 328 | return _("No additional fees required."), None |
---|
[13526] | 329 | amount = academic_session.clearance_fee_pg |
---|
[11653] | 330 | else: |
---|
| 331 | amount = academic_session.clearance_fee |
---|
[8753] | 332 | p_item = student['studycourse'].certificate.code |
---|
[13689] | 333 | if amount in (0.0, None): |
---|
| 334 | return _(u'Amount could not be determined.'), None |
---|
[14239] | 335 | # Add Matric Gown Fee and Lapel Fee |
---|
[13689] | 336 | if category == 'clearance_incl': |
---|
[13414] | 337 | amount += gateway_net_amt(academic_session.matric_gown_fee) + \ |
---|
| 338 | gateway_net_amt(academic_session.lapel_fee) |
---|
[11004] | 339 | elif category == 'late_registration': |
---|
[14117] | 340 | if student.is_postgrad: |
---|
| 341 | amount = academic_session.late_pg_registration_fee |
---|
| 342 | else: |
---|
| 343 | amount = academic_session.late_registration_fee |
---|
[13400] | 344 | elif category.startswith('schoolfee'): |
---|
[8600] | 345 | try: |
---|
[8753] | 346 | certificate = student['studycourse'].certificate |
---|
| 347 | p_item = certificate.code |
---|
[8600] | 348 | except (AttributeError, TypeError): |
---|
| 349 | return _('Study course data are incomplete.'), None |
---|
[13853] | 350 | if student.is_postgrad and category != 'schoolfee': |
---|
[13854] | 351 | return _("No additional fees required."), None |
---|
[14544] | 352 | if not previous_session and student.current_mode in ( |
---|
[13855] | 353 | 'ug_ft', 'ug_pt', 'de_ft', 'de_pt', |
---|
| 354 | 'transfer', 'mug_ft', 'mde_ft') \ |
---|
| 355 | and not category in ( |
---|
| 356 | 'schoolfee_incl', 'schoolfee_1', 'schoolfee_2'): |
---|
[14244] | 357 | return _("You must choose a payment which includes " |
---|
[13855] | 358 | "additional fees."), None |
---|
[13780] | 359 | if category in ('schoolfee_1', 'schoolfee_2'): |
---|
| 360 | if student.current_mode == 'ug_pt': |
---|
| 361 | return _("Part-time students are not allowed " |
---|
| 362 | "to pay by instalments."), None |
---|
[14241] | 363 | if student.entry_session < 2015: |
---|
| 364 | return _("You are not allowed " |
---|
| 365 | "to pay by instalments."), None |
---|
[14544] | 366 | if previous_session: |
---|
| 367 | # Students can pay for previous sessions in all |
---|
| 368 | # workflow states. Fresh students are excluded by the |
---|
| 369 | # update method of the PreviousPaymentAddFormPage. |
---|
| 370 | if previous_level == 100: |
---|
| 371 | amount = getattr(certificate, 'school_fee_1', 0.0) |
---|
| 372 | else: |
---|
| 373 | if student.entry_session >= 2015: |
---|
| 374 | amount = getattr(certificate, 'school_fee_2', 0.0) |
---|
| 375 | else: |
---|
| 376 | amount = getattr(certificate, 'school_fee_3', 0.0) |
---|
| 377 | elif student.state == CLEARED and category != 'schoolfee_2': |
---|
[14229] | 378 | amount = getattr(certificate, 'school_fee_1', 0.0) |
---|
[13512] | 379 | # Cut school fee by 50% |
---|
[14241] | 380 | if category == 'schoolfee_1' and amount: |
---|
| 381 | amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT |
---|
| 382 | elif student.is_fresh and category == 'schoolfee_2': |
---|
| 383 | amount = getattr(certificate, 'school_fee_1', 0.0) |
---|
| 384 | # Cut school fee by 50% |
---|
| 385 | if amount: |
---|
| 386 | amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT |
---|
[14396] | 387 | elif student.state == RETURNING and category != 'schoolfee_2': |
---|
[13482] | 388 | if not student.father_name: |
---|
| 389 | return _("Personal data form is not properly filled."), None |
---|
[13374] | 390 | # In case of returning school fee payment the payment session |
---|
| 391 | # and level contain the values of the session the student |
---|
| 392 | # has paid for. |
---|
| 393 | p_session, p_level = self.getReturningData(student) |
---|
[8961] | 394 | try: |
---|
| 395 | academic_session = grok.getSite()[ |
---|
| 396 | 'configuration'][str(p_session)] |
---|
| 397 | except KeyError: |
---|
| 398 | return _(u'Session configuration object is not available.'), None |
---|
[14241] | 399 | if student.entry_session >= 2015: |
---|
[14229] | 400 | amount = getattr(certificate, 'school_fee_2', 0.0) |
---|
[14241] | 401 | # Cut school fee by 50% |
---|
[14396] | 402 | if category == 'schoolfee_1' and amount: |
---|
[14241] | 403 | amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT |
---|
[13374] | 404 | else: |
---|
[14229] | 405 | amount = getattr(certificate, 'school_fee_3', 0.0) |
---|
[14241] | 406 | elif category == 'schoolfee_2': |
---|
| 407 | amount = getattr(certificate, 'school_fee_2', 0.0) |
---|
| 408 | # Cut school fee by 50% |
---|
| 409 | if amount: |
---|
| 410 | amount = gateway_net_amt(amount) / 2 + GATEWAY_AMT |
---|
[8600] | 411 | else: |
---|
[8753] | 412 | return _('Wrong state.'), None |
---|
[13417] | 413 | if amount in (0.0, None): |
---|
| 414 | return _(u'Amount could not be determined.'), None |
---|
[14244] | 415 | # Add Student Union Fee , Student Id Card Fee and Welfare Assurance |
---|
[13512] | 416 | if category in ('schoolfee_incl', 'schoolfee_1'): |
---|
[13414] | 417 | amount += gateway_net_amt(academic_session.welfare_fee) + \ |
---|
| 418 | gateway_net_amt(academic_session.union_fee) |
---|
[14244] | 419 | if student.entry_session == 2016 \ |
---|
| 420 | and student.entry_mode == 'ug_ft' \ |
---|
| 421 | and student.state == CLEARED: |
---|
| 422 | amount += gateway_net_amt(academic_session.id_card_fee) |
---|
[13534] | 423 | # Add non-indigenous fee and session specific penalty fees |
---|
| 424 | if student.is_postgrad: |
---|
| 425 | amount += academic_session.penalty_pg |
---|
[14246] | 426 | if student.lga and not student.lga.startswith('edo'): |
---|
[13534] | 427 | amount += 20000.0 |
---|
| 428 | else: |
---|
| 429 | amount += academic_session.penalty_ug |
---|
[14248] | 430 | elif not student.is_postgrad: |
---|
| 431 | fee_name = category + '_fee' |
---|
| 432 | amount = getattr(academic_session, fee_name, 0.0) |
---|
[8600] | 433 | if amount in (0.0, None): |
---|
| 434 | return _(u'Amount could not be determined.'), None |
---|
[8677] | 435 | # Create ticket. |
---|
[8600] | 436 | for key in student['payments'].keys(): |
---|
| 437 | ticket = student['payments'][key] |
---|
| 438 | if ticket.p_state == 'paid' and\ |
---|
| 439 | ticket.p_category == category and \ |
---|
| 440 | ticket.p_item == p_item and \ |
---|
| 441 | ticket.p_session == p_session: |
---|
| 442 | return _('This type of payment has already been made.'), None |
---|
[13786] | 443 | # Additional condition in AAUE |
---|
| 444 | if category in ('schoolfee', 'schoolfee_incl', 'schoolfee_1'): |
---|
| 445 | if ticket.p_state == 'paid' and \ |
---|
| 446 | ticket.p_category in ('schoolfee', |
---|
| 447 | 'schoolfee_incl', |
---|
| 448 | 'schoolfee_1') and \ |
---|
| 449 | ticket.p_item == p_item and \ |
---|
| 450 | ticket.p_session == p_session: |
---|
| 451 | return _( |
---|
| 452 | 'Another school fee payment for this ' |
---|
| 453 | 'session has already been made.'), None |
---|
| 454 | |
---|
[11455] | 455 | if self._isPaymentDisabled(p_session, category, student): |
---|
[13798] | 456 | return _('This category of payments has been disabled.'), None |
---|
[8712] | 457 | payment = createObject(u'waeup.StudentOnlinePayment') |
---|
[8954] | 458 | timestamp = ("%d" % int(time()*10000))[1:] |
---|
[8600] | 459 | payment.p_id = "p%s" % timestamp |
---|
| 460 | payment.p_category = category |
---|
| 461 | payment.p_item = p_item |
---|
| 462 | payment.p_session = p_session |
---|
| 463 | payment.p_level = p_level |
---|
[9154] | 464 | payment.p_current = p_current |
---|
[8600] | 465 | payment.amount_auth = amount |
---|
| 466 | return None, payment |
---|
[7621] | 467 | |
---|
[10922] | 468 | def _admissionText(self, student, portal_language): |
---|
| 469 | inst_name = grok.getSite()['configuration'].name |
---|
| 470 | entry_session = student['studycourse'].entry_session |
---|
| 471 | entry_session = academic_sessions_vocab.getTerm(entry_session).title |
---|
| 472 | text = trans(_( |
---|
[10953] | 473 | 'This is to inform you that you have been offered provisional' |
---|
| 474 | ' admission into ${a} for the ${b} academic session as follows:', |
---|
[10922] | 475 | mapping = {'a': inst_name, 'b': entry_session}), |
---|
| 476 | portal_language) |
---|
| 477 | return text |
---|
| 478 | |
---|
[14585] | 479 | def warnCreditsOOR(self, studylevel, course=None): |
---|
[14733] | 480 | studycourse = studylevel.__parent__ |
---|
| 481 | certificate = getattr(studycourse,'certificate', None) |
---|
| 482 | current_level = studycourse.current_level |
---|
| 483 | if None in (current_level, certificate): |
---|
| 484 | return |
---|
| 485 | end_level = certificate.end_level |
---|
| 486 | if current_level >= end_level: |
---|
| 487 | limit = 52 |
---|
| 488 | else: |
---|
| 489 | limit = 48 |
---|
| 490 | if course and studylevel.total_credits + course.credits > limit: |
---|
[14585] | 491 | return _('Maximum credits exceeded.') |
---|
[14733] | 492 | elif studylevel.total_credits > limit: |
---|
[14585] | 493 | return _('Maximum credits exceeded.') |
---|
| 494 | return |
---|
[10051] | 495 | |
---|
[13353] | 496 | def getBedCoordinates(self, bedticket): |
---|
| 497 | """Return descriptive bed coordinates. |
---|
| 498 | This method can be used to customize the `display_coordinates` |
---|
| 499 | property method in order to display a |
---|
| 500 | customary description of the bed space. |
---|
| 501 | """ |
---|
| 502 | bc = bedticket.bed_coordinates.split(',') |
---|
| 503 | if len(bc) == 4: |
---|
| 504 | return bc[0] |
---|
| 505 | return bedticket.bed_coordinates |
---|
| 506 | |
---|
[13415] | 507 | def getAccommodationDetails(self, student): |
---|
| 508 | """Determine the accommodation data of a student. |
---|
| 509 | """ |
---|
| 510 | d = {} |
---|
| 511 | d['error'] = u'' |
---|
| 512 | hostels = grok.getSite()['hostels'] |
---|
| 513 | d['booking_session'] = hostels.accommodation_session |
---|
| 514 | d['allowed_states'] = hostels.accommodation_states |
---|
| 515 | d['startdate'] = hostels.startdate |
---|
| 516 | d['enddate'] = hostels.enddate |
---|
| 517 | d['expired'] = hostels.expired |
---|
| 518 | # Determine bed type |
---|
[13416] | 519 | bt = 'all' |
---|
[13415] | 520 | if student.sex == 'f': |
---|
| 521 | sex = 'female' |
---|
| 522 | else: |
---|
| 523 | sex = 'male' |
---|
| 524 | special_handling = 'regular' |
---|
| 525 | d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt) |
---|
| 526 | return d |
---|
| 527 | |
---|
[13753] | 528 | def checkAccommodationRequirements(self, student, acc_details): |
---|
[14238] | 529 | msg = super(CustomStudentsUtils, self).checkAccommodationRequirements( |
---|
[13753] | 530 | student, acc_details) |
---|
[14238] | 531 | if msg: |
---|
| 532 | return msg |
---|
[13753] | 533 | if student.current_mode not in ('ug_ft', 'de_ft', 'mug_ft', 'mde_ft'): |
---|
| 534 | return _('You are not eligible to book accommodation.') |
---|
| 535 | return |
---|
| 536 | |
---|
[8444] | 537 | # AAUE prefix |
---|
[14593] | 538 | STUDENT_ID_PREFIX = u'E' |
---|
| 539 | |
---|
| 540 | STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses', |
---|
| 541 | 'studentstudylevels', 'coursetickets', |
---|
| 542 | 'studentpayments', 'studentunpaidpayments', |
---|
| 543 | 'bedtickets', 'paymentsoverview', |
---|
| 544 | 'studylevelsoverview', 'combocard', 'bursary', |
---|
| 545 | 'levelreportdata') |
---|