Ignore:
Timestamp:
23 Nov 2018, 11:10:19 (6 years ago)
Author:
Henrik Bettermann
Message:

Add ReleaseExpiredAllocationsActionButton? which has previously only been used by Uniben.

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

Legend:

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

    r13565 r15250  
    124124    target = 'statistics'
    125125
     126class ReleaseExpiredAllocationsActionButton(ManageActionButton):
     127    grok.order(3)
     128    grok.context(IHostelsContainer)
     129    grok.view(HostelsContainerPage)
     130    grok.require('waeup.manageHostels')
     131    icon = 'actionicon_sweep.png'
     132    target = 'releaseexpired'
     133    text = _('Release all expired bed space allocations')
     134
     135    @property
     136    def target_url(self):
     137        if self.target and self.context.allocation_expiration:
     138            return self.view.url(self.view.context, self.target)
     139        return
     140
     141    @property
     142    def onclick(self):
     143        msg = "'All expired bed space allocations will be annulled. " + \
     144              "Are you sure? \\n\\n" + \
     145              "Bed space allocation expires ${a} days after accommodation " + \
     146              "booking if maintenance fee is not " + \
     147              "paid.'"
     148        msg = _(msg, mapping={'a': self.context.allocation_expiration,})
     149        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     150        return "return window.confirm(%s);" % translate(
     151            msg, 'waeup.kofa', target_language=portal_language)
     152
    126153class HostelsContainerManagePage(KofaEditFormPage):
    127154    """The manage page for hostel containers.
     
    190217    grok.require('waeup.manageHostels')
    191218
    192     def update(self, n=7):
     219    def update(self):
     220        n = self.context.allocation_expiration
     221        if not n:
     222            self.flash(
     223                _('Forbidden'), type='danger')
     224            self.redirect(self.url(self.context))
     225            return
    193226        if not grok.getSite()['configuration'].maintmode_enabled_by:
    194227            self.flash(
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/interfaces.py

    r14009 r15250  
    7373        )
    7474
     75    allocation_expiration = schema.Int(
     76        title = _(u'Allocation Expiration Time (days)'),
     77        description = _(
     78            'Number of days after which allocation is being annulled'),
     79        required = False,
     80        )
     81
    7582    def clearAllHostels():
    7683        """Clear all hostels.
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r13533 r15250  
    188188
    189189    def test_release_expired_allocations(self):
     190        self.app['hostels'].allocation_expiration = 7
    190191        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    191192        cat = queryUtility(ICatalog, name='beds_catalog')
Note: See TracChangeset for help on using the changeset viewer.