Changeset 14170
- Timestamp:
- 20 Sep 2016, 11:35:42 (8 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r14169 r14170 4 4 1.4.2.dev0 (unreleased) 5 5 ======================= 6 7 * Add export purge button. 6 8 7 9 * Add report purge button. -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py
r13959 r14170 205 205 return 206 206 207 def doll_up(view, user=None ):207 def doll_up(view, user=None, purge=False): 208 208 """Doll up export jobs for displaying in table. 209 209 """ 210 ob_class = view.__implemented__.__name__.replace('waeup.kofa.','') 210 211 job_entries = view.context.get_running_export_jobs(user) 211 212 job_manager = getUtility(IJobManager) … … 234 235 job.failed and time_delta and \ 235 236 time_delta.days < 1 237 if not show_download_button and purge: 238 entry = view.context.entry_from_job_id(job_id) 239 view.context.delete_export_entry(entry) 240 view.context.logger.info( 241 '%s - purged: job_id=%s' % (ob_class, job_id)) 242 continue 236 243 new_entry = dict( 237 244 job=job_id, … … 1854 1861 return sorted(title_name_tuples) 1855 1862 1856 def update(self, CREATE=None, DISCARD=None, exporter=None,1863 def update(self, CREATE=None, DISCARD=None, PURGE=None, exporter=None, 1857 1864 job_id=None, CANCEL=None): 1858 1865 if CANCEL is not None: … … 1876 1883 '%s - discarded: job_id=%s' % (ob_class, job_id)) 1877 1884 self.flash(_('Discarded export') + ' %s' % job_id) 1878 self.entries = doll_up(self, user=None) 1885 self.entries = doll_up(self, user=None, purge=PURGE) 1886 if PURGE: 1887 self.flash(_('Exports successfully purged.')) 1879 1888 return 1880 1889 -
main/waeup.kofa/trunk/src/waeup/kofa/browser/reports.py
r14169 r14170 54 54 entry = self.context.report_entry_from_job_id(job_id) 55 55 self.context.delete_report_entry(entry) 56 self.flash('Report discarded: %s' % job_id)56 self.flash('Report %s discarded' % job_id) 57 57 grok.getSite().logger.info( 58 58 '%s - report %s discarded' % (ob_class, job_id)) -
main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/datacenterexportpage.pt
r14166 r14170 31 31 <div class="form-group"> 32 32 <input type="submit" name="CANCEL" class="btn btn-default" 33 tal:attributes="value view/cancel_button" /> 33 tal:attributes="value view/cancel_button" 34 /> 34 35 </div> 35 36 </form> … … 86 87 <a href="" class="btn btn-primary btn-xs" 87 88 tal:attributes="href job/download_url" 88 tal:condition="job/show_download_button"> 89 tal:condition="job/show_download_button" 90 i18n:translate=""> 89 91 Download</a> 90 92 <input type="hidden" name="job_id" … … 92 94 <input type="submit" class="btn btn-default btn-xs" 93 95 name="DISCARD" value="Discard" 94 tal:condition="job/show_discard_button" /> 96 tal:condition="job/show_discard_button" 97 i18n:translate=""/> 95 98 </form> 96 99 </td> … … 98 101 </tbody> 99 102 </table> 103 104 <form method="POST" i18n:domain="waeup.kofa"> 105 <div class="form-group"> 106 <input type="submit" class="btn btn-primary" 107 name="PURGE" value="Purge outdated exports" 108 data-toggle="tooltip" 109 title="All exports older than 24 hours will be discarded!" 110 i18n:translate="" 111 /> 112 </div> 113 </form> -
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
r14166 r14170 24 24 import os 25 25 import grok 26 from datetime import datetime, timedelta 26 27 from zc.async.testing import wait_for_result 27 28 from zope.component import createObject, getUtility … … 32 33 from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase 33 34 from waeup.kofa.app import University 34 from waeup.kofa.interfaces import IJobManager, IUserAccount 35 from waeup.kofa.interfaces import IJobManager, IUserAccount, IKofaUtils 35 36 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 36 37 from waeup.kofa.university.faculty import Faculty … … 435 436 # we can discard a generated export result 436 437 self.trigger_export() 437 self.wait_for_export_job_completed()438 job_id = self.wait_for_export_job_completed() 438 439 self.browser.open(self.datacenter_path + '/@@export') 439 440 self.browser.getControl("Discard").click() … … 443 444 logcontent = open(logfile).read() 444 445 self.assertTrue( 445 'zope.mgr - browser.pages.ExportCSVPage - discarded: job_id=' 446 in logcontent) 446 'zope.mgr - browser.pages.ExportCSVPage - discarded: job_id=%s' 447 % job_id in logcontent) 448 return 449 450 def test_export_purge(self): 451 self.trigger_export() 452 job_id = self.wait_for_export_job_completed() 453 self.browser.open(self.datacenter_path + '/export') 454 self.browser.getControl("Purge").click() 455 # Flash message always says successful ... 456 self.assertTrue( 457 'Exports successfully purged.' in self.browser.contents) 458 # ... but the export is still there 459 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 460 461 job_id, gen_name, user = self.app['datacenter'].get_running_export_jobs()[0] 462 job = getUtility(IJobManager).get(job_id) 463 tz = getUtility(IKofaUtils).tzinfo 464 delta = timedelta(days=5) 465 setattr(job, '_begin_after', datetime.now(tz) - delta) 466 self.browser.getControl("Purge").click() 467 self.assertEqual(len(self.app['datacenter'].running_exports), 0) 468 logfile = os.path.join( 469 self.app['datacenter'].storage, 'logs', 'datacenter.log') 470 logcontent = open(logfile).read() 471 self.assertTrue('zope.mgr - browser.pages.ExportCSVPage - ' 472 'purged: job_id=%s' % job_id in logcontent) 447 473 return 448 474
Note: See TracChangeset for help on using the changeset viewer.