Changeset 13295


Ignore:
Timestamp:
7 Oct 2015, 10:46:18 (9 years ago)
Author:
Henrik Bettermann
Message:

Initiate customization of getAccommodationDetails.

File:
1 edited

Legend:

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

    r13283 r13295  
    8383                     'current accommodation session.')
    8484        return
     85
     86    def getAccommodationDetails(self, student):
     87        """Determine the accommodation data of a student.
     88        """
     89        d = {}
     90        d['error'] = u''
     91        hostels = grok.getSite()['hostels']
     92        d['booking_session'] = hostels.accommodation_session
     93        d['allowed_states'] = hostels.accommodation_states
     94        d['startdate'] = hostels.startdate
     95        d['enddate'] = hostels.enddate
     96        d['expired'] = hostels.expired
     97        # Determine bed type
     98        studycourse = student['studycourse']
     99        certificate = getattr(studycourse,'certificate',None)
     100        entry_session = studycourse.entry_session
     101        current_level = studycourse.current_level
     102        if None in (entry_session, current_level, certificate):
     103            return d
     104        end_level = certificate.end_level
     105        if current_level == 10:
     106            bt = 'pr'
     107        elif entry_session == grok.getSite()['hostels'].accommodation_session:
     108            bt = 'fr'
     109        elif current_level >= end_level:
     110            bt = 'fi'
     111        else:
     112            bt = 're'
     113        if student.sex == 'f':
     114            sex = 'female'
     115        else:
     116            sex = 'male'
     117        special_handling = 'regular'
     118        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
     119        return d
    85120
    86121    def _paymentMade(self, student, session):
Note: See TracChangeset for help on using the changeset viewer.