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