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