Index: main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py
===================================================================
--- main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 13247)
+++ main/waeup.uniben/trunk/src/waeup/uniben/students/utils.py	(revision 13248)
@@ -48,38 +48,30 @@
         return new_session, new_level
 
-    def getAccommodationDetails(self, student):
-        """Determine the accommodation data of a student.
-        """
-        d = {}
-        d['error'] = u''
-        hostels = grok.getSite()['hostels']
-        d['booking_session'] = hostels.accommodation_session
-        d['allowed_states'] = hostels.accommodation_states
-        d['startdate'] = hostels.startdate
-        d['enddate'] = hostels.enddate
-        d['expired'] = hostels.expired
-        # Determine bed type
-        studycourse = student['studycourse']
-        certificate = getattr(studycourse,'certificate',None)
-        entry_session = studycourse.entry_session
-        current_level = studycourse.current_level
-        if None in (entry_session, current_level, certificate):
-            return d
-        end_level = certificate.end_level
-        if current_level == 10:
-            bt = 'pr'
-        elif entry_session == grok.getSite()['hostels'].accommodation_session:
-            bt = 'fr'
-        elif current_level >= end_level:
-            bt = 'fi'
-        else:
-            bt = 're'
-        if student.sex == 'f':
-            sex = 'female'
-        else:
-            sex = 'male'
-        special_handling = 'regular'
-        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
-        return d
+    def checkAccommodationRequirements(self, student, acc_details):
+        if acc_details.get('expired', False):
+            startdate = acc_details.get('startdate')
+            enddate = acc_details.get('enddate')
+            if startdate and enddate:
+                tz = getUtility(IKofaUtils).tzinfo
+                startdate = to_timezone(
+                    startdate, tz).strftime("%d/%m/%Y %H:%M:%S")
+                enddate = to_timezone(
+                    enddate, tz).strftime("%d/%m/%Y %H:%M:%S")
+                return _("Outside booking period: ${a} - ${b}",
+                         mapping = {'a': startdate, 'b': enddate})
+            else:
+                return _("Outside booking period.")
+        if not acc_details.get('bt'):
+            return _("Your data are incomplete.")
+        if not student.state in acc_details['allowed_states']:
+            return _("You are in the wrong registration state.")
+        if student['studycourse'].current_session != acc_details[
+            'booking_session']:
+            return _('Your current session does not '
+                     'match accommodation session.')
+        if str(acc_details['booking_session']) in student['accommodation'].keys():
+            return _('You already booked a bed space in '
+                     'current accommodation session.')
+        return
 
     def _paymentMade(self, student, session):
