Ignore:
Timestamp:
5 Sep 2015, 10:18:56 (9 years ago)
Author:
Henrik Bettermann
Message:

We have to customize checkAccommodationRequirements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py

    r13244 r13248  
    4848        return new_session, new_level
    4949
    50     def getAccommodationDetails(self, student):
    51         """Determine the accommodation data of a student.
    52         """
    53         d = {}
    54         d['error'] = u''
    55         hostels = grok.getSite()['hostels']
    56         d['booking_session'] = hostels.accommodation_session
    57         d['allowed_states'] = hostels.accommodation_states
    58         d['startdate'] = hostels.startdate
    59         d['enddate'] = hostels.enddate
    60         d['expired'] = hostels.expired
    61         # Determine bed type
    62         studycourse = student['studycourse']
    63         certificate = getattr(studycourse,'certificate',None)
    64         entry_session = studycourse.entry_session
    65         current_level = studycourse.current_level
    66         if None in (entry_session, current_level, certificate):
    67             return d
    68         end_level = certificate.end_level
    69         if current_level == 10:
    70             bt = 'pr'
    71         elif entry_session == grok.getSite()['hostels'].accommodation_session:
    72             bt = 'fr'
    73         elif current_level >= end_level:
    74             bt = 'fi'
    75         else:
    76             bt = 're'
    77         if student.sex == 'f':
    78             sex = 'female'
    79         else:
    80             sex = 'male'
    81         special_handling = 'regular'
    82         d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
    83         return d
     50    def checkAccommodationRequirements(self, student, acc_details):
     51        if acc_details.get('expired', False):
     52            startdate = acc_details.get('startdate')
     53            enddate = acc_details.get('enddate')
     54            if startdate and enddate:
     55                tz = getUtility(IKofaUtils).tzinfo
     56                startdate = to_timezone(
     57                    startdate, tz).strftime("%d/%m/%Y %H:%M:%S")
     58                enddate = to_timezone(
     59                    enddate, tz).strftime("%d/%m/%Y %H:%M:%S")
     60                return _("Outside booking period: ${a} - ${b}",
     61                         mapping = {'a': startdate, 'b': enddate})
     62            else:
     63                return _("Outside booking period.")
     64        if not acc_details.get('bt'):
     65            return _("Your data are incomplete.")
     66        if not student.state in acc_details['allowed_states']:
     67            return _("You are in the wrong registration state.")
     68        if student['studycourse'].current_session != acc_details[
     69            'booking_session']:
     70            return _('Your current session does not '
     71                     'match accommodation session.')
     72        if str(acc_details['booking_session']) in student['accommodation'].keys():
     73            return _('You already booked a bed space in '
     74                     'current accommodation session.')
     75        return
    8476
    8577    def _paymentMade(self, student, session):
Note: See TracChangeset for help on using the changeset viewer.