- Timestamp:
- 12 Jun 2012, 09:58:03 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r8685 r8688 62 62 from waeup.kofa.browser.resources import toggleall 63 63 from waeup.kofa.hostels.hostel import NOT_OCCUPIED 64 from waeup.kofa.utils.helpers import get_current_principal 64 from waeup.kofa.utils.helpers import get_current_principal, to_timezone 65 65 66 66 def write_log_message(view, message): … … 1230 1230 students_utils = getUtility(IStudentsUtils) 1231 1231 acc_details = students_utils.getAccommodationDetails(student) 1232 if acc_details.get('expired', False): 1233 startdate = acc_details.get('startdate') 1234 enddate = acc_details.get('enddate') 1235 if startdate and enddate: 1236 tz = getUtility(IKofaUtils).tzinfo 1237 startdate = to_timezone( 1238 startdate, tz).strftime("%d/%m/%Y %H:%M:%S") 1239 enddate = to_timezone( 1240 enddate, tz).strftime("%d/%m/%Y %H:%M:%S") 1241 self.flash(_("Outside booking period: ${a} - ${b}", 1242 mapping = {'a': startdate, 'b': enddate})) 1243 else: 1244 self.flash(_("Outside booking period.")) 1245 self.redirect(self.url(self.context)) 1246 return 1232 1247 if not acc_details: 1233 1248 self.flash(_("Your data are incomplete.")) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r8685 r8688 21 21 import shutil 22 22 import tempfile 23 import pytz 24 from datetime import datetime, timedelta 23 25 from StringIO import StringIO 24 from datetime import datetime25 26 import os 26 27 import grok … … 171 172 self.course, level=100) 172 173 173 # Configure university 174 # Configure university and hostels 174 175 self.app['hostels'].accommodation_states = ['admitted'] 175 176 self.app['hostels'].accommodation_session = 2004 177 delta = timedelta(days=10) 178 self.app['hostels'].startdate = datetime.now(pytz.utc) - delta 179 self.app['hostels'].enddate = datetime.now(pytz.utc) + delta 176 180 self.app['configuration'].carry_over = True 177 181 configuration = createObject('waeup.SessionConfiguration') … … 1749 1753 sfeseries, sfenumber = parts 1750 1754 1751 # Students can use HOS code and book a bed space with it 1755 # Students can use HOS code and book a bed space with it ... 1752 1756 self.browser.open(self.acco_path) 1757 # ... but not if booking period has expired ... 1758 self.app['hostels'].enddate = datetime.now(pytz.utc) 1759 self.browser.getLink("Book accommodation").click() 1760 self.assertMatches('...Outside booking period: ...', 1761 self.browser.contents) 1762 self.app['hostels'].enddate = datetime.now(pytz.utc) + timedelta(days=10) 1763 # ... or student is not the an allowed state ... 1753 1764 self.browser.getLink("Book accommodation").click() 1754 1765 self.assertMatches('...You are in the wrong...', … … 1758 1769 self.assertMatches('...Activation Code:...', 1759 1770 self.browser.contents) 1771 # Student can't used faked ACs ... 1760 1772 self.browser.getControl(name="ac_series").value = u'nonsense' 1761 1773 self.browser.getControl(name="ac_number").value = sfenumber … … 1763 1775 self.assertMatches('...Activation code is invalid...', 1764 1776 self.browser.contents) 1777 # ... or ACs owned by somebody else. 1765 1778 ac.owner = u'Anybody' 1766 1779 self.browser.getControl(name="ac_series").value = sfeseries -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r8685 r8688 323 323 d['booking_session'] = hostels.accommodation_session 324 324 d['allowed_states'] = hostels.accommodation_states 325 d['startdate'] = hostels.startdate 326 d['enddate'] = hostels.enddate 327 d['expired'] = hostels.expired 325 328 # Determine bed type 326 329 studycourse = student['studycourse']
Note: See TracChangeset for help on using the changeset viewer.