Ignore:
Timestamp:
5 Sep 2015, 10:15:24 (9 years ago)
Author:
Henrik Bettermann
Message:

Move accommodation requirements checking into StudentsUtils? to ease customization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r13241 r13247  
    19881988        students_utils = getUtility(IStudentsUtils)
    19891989        acc_details  = students_utils.getAccommodationDetails(student)
    1990         if acc_details.get('expired', False):
    1991             startdate = acc_details.get('startdate')
    1992             enddate = acc_details.get('enddate')
    1993             if startdate and enddate:
    1994                 tz = getUtility(IKofaUtils).tzinfo
    1995                 startdate = to_timezone(
    1996                     startdate, tz).strftime("%d/%m/%Y %H:%M:%S")
    1997                 enddate = to_timezone(
    1998                     enddate, tz).strftime("%d/%m/%Y %H:%M:%S")
    1999                 self.flash(_("Outside booking period: ${a} - ${b}",
    2000                     mapping = {'a': startdate, 'b': enddate}), type="warning")
    2001             else:
    2002                 self.flash(_("Outside booking period."), type="warning")
    2003             self.redirect(self.url(self.context))
    2004             return
    2005         if not acc_details.get('bt'):
    2006             self.flash(_("Your data are incomplete."), type="warning")
    2007             self.redirect(self.url(self.context))
    2008             return
    2009         if not student.state in acc_details['allowed_states']:
    2010             self.flash(_("You are in the wrong registration state."),
    2011                        type="warning")
    2012             self.redirect(self.url(self.context))
    2013             return
    2014         if student['studycourse'].current_session != acc_details[
    2015             'booking_session']:
    2016             self.flash(
    2017                 _('Your current session does not match accommodation session.'),
    2018                 type="warning")
    2019             self.redirect(self.url(self.context))
    2020             return
    2021         if str(acc_details['booking_session']) in self.context.keys():
    2022             self.flash(
    2023                 _('You already booked a bed space in current ' \
    2024                     + 'accommodation session.'), type="warning")
     1990        error_message = students_utils.checkAccommodationRequirements(
     1991            student, acc_details)
     1992        if error_message:
     1993            self.flash(error_message, type="warning")
    20251994            self.redirect(self.url(self.context))
    20261995            return
Note: See TracChangeset for help on using the changeset viewer.