Changeset 13050


Ignore:
Timestamp:
15 Jun 2015, 14:35:38 (9 years ago)
Author:
Henrik Bettermann
Message:

Clear already booked bed if student used an ac twice or isn't the owner of the ac. I found this bug when writing the documentation.

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

Legend:

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

    r13047 r13050  
    20462046        if len(entries):
    20472047            # If bed space has been manually allocated use this bed
     2048            manual = True
    20482049            bed = [entry for entry in entries][0]
    20492050            # Safety belt for paranoids: Does this bed really exist on portal?
     
    20572058        else:
    20582059            # else search for other available beds
     2060            manual = False
    20592061            entries = cat.searchResults(
    20602062                bed_type=(acc_details['bt'],acc_details['bt']))
     
    20842086                self.flash(_('Activation code has already been used.'),
    20852087                           type="warning")
     2088                if not manual:
     2089                    # Release the previously booked bed
     2090                    bed.owner = NOT_OCCUPIED
     2091                    # Catalog must be informed
     2092                    notify(grok.ObjectModifiedEvent(bed))
    20862093                return
    20872094            else:
     
    20892096                # Here we know that the ac is in state initialized so we do not
    20902097                # expect an exception, but the owner might be different
    2091                 if not invalidate_accesscode(
    2092                     pin,comment,self.context.student.student_id):
     2098                success = invalidate_accesscode(
     2099                    pin, comment, self.context.student.student_id)
     2100                if not success:
    20932101                    self.flash(_('You are not the owner of this access code.'),
    20942102                               type="warning")
     2103                    if not manual:
     2104                        # Release the previously booked bed
     2105                        bed.owner = NOT_OCCUPIED
     2106                        # Catalog must be informed
     2107                        notify(grok.ObjectModifiedEvent(bed))
    20952108                    return
    20962109        # Create bed ticket
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r13047 r13050  
    30063006        self.assertMatches('...Activation Code:...',
    30073007                           self.browser.contents)
    3008         # Student can't used faked ACs ...
     3008        # Student can't use faked ACs ...
    30093009        self.browser.getControl(name="ac_series").value = u'nonsense'
    30103010        self.browser.getControl(name="ac_number").value = sfenumber
     
    30193019        self.assertMatches('...You are not the owner of this access code...',
    30203020                           self.browser.contents)
     3021        # The bed remains empty
     3022        bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
     3023        self.assertTrue(bed.owner == NOT_OCCUPIED)
    30213024        ac.owner = self.student_id
    30223025        self.browser.getControl(name="ac_series").value = sfeseries
     
    30263029                           self.browser.contents)
    30273030        # Bed has been allocated
    3028         bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
    30293031        self.assertTrue(bed.owner == self.student_id)
    30303032        # BedTicketAddPage is now blocked
Note: See TracChangeset for help on using the changeset viewer.