Changeset 9188 for main/waeup.kofa


Ignore:
Timestamp:
15 Sep 2012, 19:48:34 (12 years ago)
Author:
Henrik Bettermann
Message:

Make provision for booking beds without activation code.

File:
1 edited

Legend:

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

    r9161 r9188  
    14081408    buttonname = _('Create bed ticket')
    14091409    notice = ''
     1410    with_ac = True
    14101411
    14111412    def update(self, SUBMIT=None):
     
    14481449            self.redirect(self.url(self.context))
    14491450            return
    1450         self.ac_series = self.request.form.get('ac_series', None)
    1451         self.ac_number = self.request.form.get('ac_number', None)
     1451        if self.with_ac:
     1452            self.ac_series = self.request.form.get('ac_series', None)
     1453            self.ac_number = self.request.form.get('ac_number', None)
    14521454        if SUBMIT is None:
    14531455            return
    1454         pin = '%s-%s-%s' % (self.ac_prefix, self.ac_series, self.ac_number)
    1455         code = get_access_code(pin)
    1456         if not code:
    1457             self.flash(_('Activation code is invalid.'))
    1458             return
     1456        if self.with_ac:
     1457            pin = '%s-%s-%s' % (self.ac_prefix, self.ac_series, self.ac_number)
     1458            code = get_access_code(pin)
     1459            if not code:
     1460                self.flash(_('Activation code is invalid.'))
     1461                return
    14591462        # Search and book bed
    14601463        cat = queryUtility(ICatalog, name='beds_catalog', default=None)
     
    14621465            owner=(student.student_id,student.student_id))
    14631466        if len(entries):
    1464             # If bed space has bee manually allocated use this bed
     1467            # If bed space has been manually allocated use this bed
    14651468            bed = [entry for entry in entries][0]
    14661469        else:
     
    14781481                    mapping = {'a':acc_details['bt']}))
    14791482                return
    1480         # Mark pin as used (this also fires a pin related transition)
    1481         if code.state == USED:
    1482             self.flash(_('Activation code has already been used.'))
    1483             return
    1484         else:
    1485             comment = _(u'invalidated')
    1486             # Here we know that the ac is in state initialized so we do not
    1487             # expect an exception, but the owner might be different
    1488             if not invalidate_accesscode(
    1489                 pin,comment,self.context.student.student_id):
    1490                 self.flash(_('You are not the owner of this access code.'))
     1483        if self.with_ac:
     1484            # Mark pin as used (this also fires a pin related transition)
     1485            if code.state == USED:
     1486                self.flash(_('Activation code has already been used.'))
    14911487                return
     1488            else:
     1489                comment = _(u'invalidated')
     1490                # Here we know that the ac is in state initialized so we do not
     1491                # expect an exception, but the owner might be different
     1492                if not invalidate_accesscode(
     1493                    pin,comment,self.context.student.student_id):
     1494                    self.flash(_('You are not the owner of this access code.'))
     1495                    return
    14921496        # Create bed ticket
    14931497        bedticket = createObject(u'waeup.BedTicket')
Note: See TracChangeset for help on using the changeset viewer.