Ignore:
Timestamp:
4 Sep 2015, 17:17:03 (9 years ago)
Author:
Henrik Bettermann
Message:

Uups, that was the wrong utility class.

File:
1 edited

Legend:

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

    r12566 r13244  
    4747        new_session = student['studycourse'].current_session + 1
    4848        return new_session, new_level
     49
     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
    4984
    5085    def _paymentMade(self, student, session):
Note: See TracChangeset for help on using the changeset viewer.