Changeset 13445


Ignore:
Timestamp:
12 Nov 2015, 09:03:47 (9 years ago)
Author:
Henrik Bettermann
Message:

Accommodation session must not be changed if hostels are not empty.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/hostels
Files:
2 edited

Legend:

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

    r13426 r13445  
    2222from zope.i18n import translate
    2323from zope.component import getUtility
     24from zope.catalog.interfaces import ICatalog
    2425from waeup.kofa.browser.layout import (
    2526    KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage,
     
    162163    @action(_('Save'), style='primary')
    163164    def save(self, **data):
     165        if data['accommodation_session'] != self.context.accommodation_session:
     166            catalog = getUtility(ICatalog, name='beds_catalog')
     167            beds = catalog.searchResults(bed_type=(None,None))
     168            if len(beds):
     169                self.flash(_('You can\'t change the booking session '
     170                             'before clearing all hostels.'),
     171                           type='warning')
     172                return
    164173        self.applyData(self.context, **data)
    165174        self.flash(_('Settings have been saved.'))
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r13440 r13445  
    215215            self.app['hostels']['hall-x']['hall_block_room_bed'].owner,
    216216            NOT_OCCUPIED)
     217        # Accommodation session can't be changed if hostels are not empty.
     218        self.browser.open(self.manage_container_path)
     219        self.browser.getControl(name="form.accommodation_session").value = ['2005']
     220        self.browser.getControl("Save").click()
     221        self.assertTrue(
     222            'You can\'t change the booking session before clearing all hostels'
     223            in self.browser.contents)
    217224        # Releasing is logged.
    218225        logcontent = open(self.logfile).read()
Note: See TracChangeset for help on using the changeset viewer.