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