Ignore:
Timestamp:
14 Oct 2015, 13:15:03 (9 years ago)
Author:
Henrik Bettermann
Message:

Log bed release already in releaseExpiredAllocations method.

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

Legend:

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

    r13316 r13318  
    6060        cat = queryUtility(ICatalog, name='beds_catalog')
    6161        results = cat.searchResults(owner=(None, None))
    62         counter = 0
     62        released = []
    6363        for bed in results:
    64             success = bed.releaseBedIfMaintenanceNotPaid(n=n)
    65             if success:
    66                 counter += 1
    67         return counter
     64            student_id = bed.releaseBedIfMaintenanceNotPaid(n=n)
     65            if student_id:
     66                released.append('%s (%s)' % (bed.bed_id,student_id))
     67        if len(released):
     68            message = ', '.join(released)
     69            self.writeLogMessage(self, 'released: %s' % message)
     70        return released
    6871
    6972    @property
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/hostel.py

    r13316 r13318  
    285285        days_ago = getattr(jetzt - bedticket.booking_date, 'days')
    286286        if days_ago > n:
     287            old_owner = self.owner
    287288            self.owner = NOT_OCCUPIED
    288289            notify(grok.ObjectModifiedEvent(self))
     
    292293            bedticket.bed_coordinates = u'-- booking expired (%s) --' % (
    293294                timestamp,)
    294             return True
     295            return old_owner
    295296        return
    296297
  • main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py

    r13316 r13318  
    192192        self.assertEqual(len(results), 1)
    193193        released = self.app['hostels'].releaseExpiredAllocations(7)
    194         self.assertEqual(released, 0)
     194        self.assertEqual(released, [])
    195195        delta = timedelta(days=10)
    196196        bedticket.booking_date = datetime.utcnow() - delta
    197197        released = self.app['hostels'].releaseExpiredAllocations(7)
    198         self.assertEqual(released, 1)
     198        self.assertEqual(len(released), 1)
     199        self.assertEqual(released, ['hall_block_room_bed (K1000000)'])
    199200        results = cat.searchResults(owner=(self.student_id, self.student_id))
    200201        self.assertEqual(len(results), 0)
     
    204205            self.app['hostels']['hall-x']['hall_block_room_bed'].owner,
    205206            NOT_OCCUPIED)
     207        # Releasing is logged.
     208        logcontent = open(self.logfile).read()
     209        self.assertTrue(
     210            'hostels.container.HostelsContainer - hostels - '
     211            'released: hall_block_room_bed (K1000000)'
     212            in logcontent)
    206213        return
    207214
Note: See TracChangeset for help on using the changeset viewer.