Ignore:
Timestamp:
9 Nov 2015, 10:05:19 (9 years ago)
Author:
Henrik Bettermann
Message:

Start customizing getAccommodationDetail.

File:
1 edited

Legend:

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

    r13414 r13415  
    239239        return bedticket.bed_coordinates
    240240
     241    def getAccommodationDetails(self, student):
     242        """Determine the accommodation data of a student.
     243        """
     244        d = {}
     245        d['error'] = u''
     246        hostels = grok.getSite()['hostels']
     247        d['booking_session'] = hostels.accommodation_session
     248        d['allowed_states'] = hostels.accommodation_states
     249        d['startdate'] = hostels.startdate
     250        d['enddate'] = hostels.enddate
     251        d['expired'] = hostels.expired
     252        # Determine bed type
     253        studycourse = student['studycourse']
     254        certificate = getattr(studycourse,'certificate',None)
     255        entry_session = studycourse.entry_session
     256        current_level = studycourse.current_level
     257        if None in (entry_session, current_level, certificate):
     258            return d
     259        end_level = certificate.end_level
     260        if current_level == 10:
     261            bt = 'pr'
     262        elif entry_session == grok.getSite()['hostels'].accommodation_session:
     263            bt = 'fr'
     264        elif current_level >= end_level:
     265            bt = 'fi'
     266        else:
     267            bt = 're'
     268        if student.sex == 'f':
     269            sex = 'female'
     270        else:
     271            sex = 'male'
     272        special_handling = 'regular'
     273        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
     274        return d
     275
    241276    # AAUE prefix
    242277    STUDENT_ID_PREFIX = u'E'
Note: See TracChangeset for help on using the changeset viewer.