Changeset 13319 for main/waeup.kofa/trunk/src/waeup/kofa/hostels
- Timestamp:
- 14 Oct 2015, 17:07:35 (9 years ago)
- 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
r13177 r13319 24 24 from waeup.kofa.browser.layout import ( 25 25 KofaEditFormPage, KofaAddFormPage, KofaDisplayFormPage, 26 NullValidator )26 NullValidator, UtilityView) 27 27 from waeup.kofa.browser.breadcrumbs import Breadcrumb 28 28 from waeup.kofa.browser.layout import default_primary_nav_template … … 164 164 self.applyData(self.context, **data) 165 165 self.flash(_('Settings have been saved.')) 166 return 167 168 class ReleaseExpiredAllocationsPage(UtilityView, grok.View): 169 """Release all expired allocated beds. 170 """ 171 grok.context(IHostelsContainer) 172 grok.name('releaseexpired') 173 grok.require('waeup.waeup.manageHostels') 174 175 def update(self, n=7): 176 released = self.context.releaseExpiredAllocations(n) 177 if len(released): 178 message = ', '.join(released) 179 self.context.writeLogMessage(self, 'released: %s' % message) 180 flash_msg = _('Successfully released beds: ${a}', mapping = {'a':message}) 181 else: 182 flash_msg = _('No bed released.') 183 self.flash(flash_msg, type='success') 184 self.redirect(self.url(self.context)) 185 return 186 187 def render(self): 166 188 return 167 189 -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/container.py
r13318 r13319 65 65 if student_id: 66 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 67 return released 71 68 -
main/waeup.kofa/trunk/src/waeup/kofa/hostels/tests.py
r13318 r13319 180 180 181 181 def test_release_expired_allocations(self): 182 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 182 183 cat = queryUtility(ICatalog, name='beds_catalog') 183 184 bedticket = BedTicket() … … 191 192 results = cat.searchResults(owner=(self.student_id, self.student_id)) 192 193 self.assertEqual(len(results), 1) 193 released = self.app['hostels'].releaseExpiredAllocations(7)194 self.assert Equal(released, [])194 self.browser.open(self.container_path + '/releaseexpired') 195 self.assertTrue('No bed released' in self.browser.contents) 195 196 delta = timedelta(days=10) 196 197 bedticket.booking_date = datetime.utcnow() - delta 197 released = self.app['hostels'].releaseExpiredAllocations(7) 198 self.assertEqual(len(released), 1) 199 self.assertEqual(released, ['hall_block_room_bed (K1000000)']) 198 self.browser.open(self.container_path + '/releaseexpired') 199 self.assertTrue( 200 'Successfully released beds: hall_block_room_bed (K1000000)' 201 in self.browser.contents) 200 202 results = cat.searchResults(owner=(self.student_id, self.student_id)) 201 203 self.assertEqual(len(results), 0) … … 208 210 logcontent = open(self.logfile).read() 209 211 self.assertTrue( 210 'hostels. container.HostelsContainer- hostels - '212 'hostels.browser.ReleaseExpiredAllocationsPage - hostels - ' 211 213 'released: hall_block_room_bed (K1000000)' 212 214 in logcontent)
Note: See TracChangeset for help on using the changeset viewer.