Ignore:
Timestamp:
25 Jan 2023, 08:52:51 (22 months ago)
Author:
Henrik Bettermann
Message:

Allow beds to be blocked so that no student can be allocated to such a bed space (in contrast to reserved beds)

File:
1 edited

Legend:

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

    r15633 r17313  
    266266    grok.name('addhostel')
    267267    #grok.template('hosteladdpage')
    268     form_fields = grok.AutoFields(IHostel).omit('beds_reserved', 'hostel_id')
     268    form_fields = grok.AutoFields(IHostel).omit('hostel_id')
    269269    label = _('Add hostel')
    270270    pnav = 5
     
    294294    grok.require('waeup.viewHostels')
    295295    grok.template('hostelpage')
    296     form_fields = grok.AutoFields(IHostel).omit('beds_reserved')
     296    form_fields = grok.AutoFields(IHostel)
    297297    pnav = 5
    298298
     
    315315    grok.name('manage')
    316316    grok.require('waeup.manageHostels')
    317     form_fields = grok.AutoFields(IHostel).omit('hostel_id', 'beds_reserved')
     317    form_fields = grok.AutoFields(IHostel).omit('hostel_id')
    318318    grok.template('hostelmanagepage')
    319319    label = _('Manage hostel')
     
    322322    tabtwoactions = [_('Update all beds'),
    323323        _('Switch reservation of selected beds'),
     324        _('Switch blockade of selected beds'),
    324325        _('Release selected beds'),
    325326        _('Clear hostel')]
     
    337338
    338339    @action(_('Update all beds'), style='primary',
    339             warning=_('Attention: The updater removes all reservation flags of existing beds.'
    340                         ' You really want to update?'))
     340            warning=_('Attention: The updater removes all reservation and '
     341                        'blockade flags of existing beds. '
     342                        'You really want to update?'))
    341343    def updateBeds(self, **data):
    342344        if not grok.getSite()['configuration'].maintmode_enabled_by:
     
    364366        return
    365367
    366     @action(_('Switch reservation of selected beds'))
    367     def switchReservations(self, **data):
     368    def _switchBeds(self, switch_type):
    368369        form = self.request.form
    369370        if 'val_id' in form:
     
    380381        preferred_language = self.request.cookies.get('kofa.language')
    381382        for bed_id in child_id:
    382             message = self.context[bed_id].switchReservation()
     383            message = self.context[bed_id].switchBed(switch_type)
    383384            switched.append('%s (%s)' % (bed_id,message))
    384385            m_translated = translate(message, 'waeup.kofa',
     
    396397            self.context.writeLogMessage(self, 'switched: %s' % message)
    397398            self.redirect(self.url(self.context, '@@manage')+'#tab2')
     399            return
     400
     401
     402    @action(_('Switch reservation of selected beds'))
     403    def switchReservations(self, **data):
     404        self._switchBeds('reserved')
     405        return
     406
     407    @action(_('Switch blockade of selected beds'))
     408    def switchBockade(self, **data):
     409        self._switchBeds('blocked')
    398410        return
    399411
     
    456468
    457469    def update(self):
     470        if self.context.bed_type.endswith('blocked'):
     471            # No student can reside in a blocked bed.
     472            self.redirect(self.url(self.context.__parent__, '@@manage')+'#tab2')
    458473        if self.context.owner != NOT_OCCUPIED:
    459474            # Don't use this form for exchanging students.
Note: See TracChangeset for help on using the changeset viewer.