Ignore:
Timestamp:
19 Sep 2012, 15:29:28 (12 years ago)
Author:
Henrik Bettermann
Message:

Customize getAccommodationDetails.

Location:
main/waeup.fceokene/trunk/src/waeup/fceokene/students
Files:
1 added
1 edited

Legend:

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

    r9190 r9207  
    222222        return None, payment
    223223
     224    def getAccommodationDetails(self, student):
     225        """Determine the accommodation data of a student.
     226        """
     227        d = {}
     228        d['error'] = u''
     229        hostels = grok.getSite()['hostels']
     230        d['booking_session'] = hostels.accommodation_session
     231        d['allowed_states'] = hostels.accommodation_states
     232        d['startdate'] = hostels.startdate
     233        d['enddate'] = hostels.enddate
     234        d['expired'] = hostels.expired
     235        # Determine bed type
     236        studycourse = student['studycourse']
     237        certificate = getattr(studycourse,'certificate',None)
     238        current_level = studycourse.current_level
     239        if None in (current_level, certificate):
     240            return d
     241        end_level = certificate.end_level
     242        if current_level == 10:
     243            bt = 'pr'
     244        elif current_level == 100:
     245            bt = 'fr'
     246        elif current_level >= 300:
     247            bt = 'fi'
     248        else:
     249            bt = 're'
     250        if student.sex == 'f':
     251            sex = 'female'
     252        else:
     253            sex = 'male'
     254        special_handling = 'regular'
     255        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
     256        return d
     257
    224258    # FCEOkene prefix
    225259    STUDENT_ID_PREFIX = u'K'
Note: See TracChangeset for help on using the changeset viewer.