Ignore:
Timestamp:
2 Dec 2015, 20:15:36 (9 years ago)
Author:
Henrik Bettermann
Message:

Require maintenance mode for bed updates and expired bed allocation releases.

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

    r13494 r13529  
    192192
    193193    def update(self, n=7):
     194        if not grok.getSite()['configuration'].maintmode_enabled_by:
     195            self.flash(
     196                _('Portal must be in maintenance mode for releasing expired '
     197                  'bed allocations.'),
     198                type='danger')
     199            self.redirect(self.url(self.context))
     200            return
    194201        released = self.context.releaseExpiredAllocations(n)
    195202        if len(released):
    196203            message = ', '.join(released)
    197204            self.context.writeLogMessage(self, 'released: %s' % message)
    198             flash_msg = _('Successfully released beds: ${a}', mapping = {'a':message})
     205            flash_msg = _('Successfully released beds: ${a}',
     206                mapping = {'a':message})
    199207        else:
    200208            flash_msg = _('No bed released.')
     
    296304                        ' You really want to update?'))
    297305    def updateBeds(self, **data):
     306        if not grok.getSite()['configuration'].maintmode_enabled_by:
     307            self.flash(
     308                _('Portal must be in maintenance mode for bed updates.'),
     309                type='danger')
     310            self.redirect(self.url(self.context, '@@manage')+'#tab2')
     311            return
    298312        removed, added, modified, modified_beds = self.context.updateBeds()
    299313        message = '%d empty beds removed, %d beds added, %d occupied beds modified (%s)' % (
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r13484 r13529  
    201201        self.assertEqual(len(results), 1)
    202202        self.browser.open(self.container_path + '/releaseexpired')
     203        self.assertTrue('Portal must be in maintenance mode for releasing expired bed allocations'
     204            in self.browser.contents)
     205        grok.getSite()['configuration'].maintmode_enabled_by = u'any_id'
     206        self.browser.open(self.container_path + '/releaseexpired')
    203207        self.assertTrue('No bed released' in self.browser.contents)
    204208        delta = timedelta(days=10)
     
    339343        hall.beds_for_final = ['C']
    340344        hall.beds_for_all = ['D','E']
     345        self.browser.getControl("Update all beds").click()
     346        self.assertTrue('Portal must be in maintenance mode for bed updates'
     347            in self.browser.contents)
     348        grok.getSite()['configuration'].maintmode_enabled_by = u'any_id'
    341349        self.browser.getControl("Update all beds").click()
    342350        expected = '...0 empty beds removed, 10 beds added, 0 occupied beds modified ()...'
     
    507515
    508516    def test_clear_hostels(self):
     517        grok.getSite()['configuration'].maintmode_enabled_by = u'any_id'
    509518        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    510519        self.browser.open(self.container_path)
Note: See TracChangeset for help on using the changeset viewer.