Changeset 13950 for main/waeup.kofa
- Timestamp:
- 17 Jun 2016, 10:02:02 (8 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r13949 r13950 4 4 1.4.2.dev0 (unreleased) 5 5 ======================= 6 7 * Start `ApplicantExporter` and `ApplicantPaymentExporter` at the same 8 time when calling `ExportJobContainerJobStart`. 6 9 7 10 * Add `ApplicantPaymentExporter`. -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r13886 r13950 21 21 import sys 22 22 import grok 23 import transaction 23 24 from datetime import datetime, date 24 25 from zope.event import notify … … 1423 1424 return 1424 1425 1425 class ExportJobContainerJobStart( KofaPage):1426 """ Page that starts an applicants export job.1427 1426 class ExportJobContainerJobStart(UtilityView, grok.View): 1427 """View that starts two export jobs, one for applicants and a second 1428 one for applicant payments. 1428 1429 """ 1429 1430 grok.context(VirtualApplicantsExportJobContainer) … … 1439 1440 self.entries = doll_up(self, user=None) 1440 1441 return 1442 1443 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 1444 container_code = self.context.__parent__.code 1445 # Start first exporter 1441 1446 exporter = 'applicants' 1442 container_code = self.context.__parent__.code1443 1447 job_id = self.context.start_export_job(exporter, 1444 1448 self.request.principal.id, 1445 1449 container=container_code) 1446 1447 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')1448 1450 self.context.logger.info( 1449 1451 '%s - exported: %s (%s), job_id=%s' 1450 1452 % (ob_class, exporter, container_code, job_id)) 1451 self.flash(_('Export started.')) 1453 # Commit transaction so that job is stored in the ZODB 1454 transaction.commit() 1455 # Start second exporter 1456 exporter = 'applicantpayments' 1457 job_id = self.context.start_export_job(exporter, 1458 self.request.principal.id, 1459 container=container_code) 1460 self.context.logger.info( 1461 '%s - exported: %s (%s), job_id=%s' 1462 % (ob_class, exporter, container_code, job_id)) 1463 1464 self.flash(_('Exports started.')) 1452 1465 self.redirect(self.url(self.context)) 1453 1466 return -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser_templates/exportjobsindex.pt
r11254 r13950 55 55 <form method="POST" i18n:domain="waeup.kofa"> 56 56 <input class="btn btn-primary" type="submit" name="CREATE" 57 value="Start new export "57 value="Start new exports" 58 58 /> 59 59 </form> -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
r13886 r13950 1447 1447 layer = FunctionalLayer 1448 1448 1449 def wait_for_export_job _completed(self):1449 def wait_for_export_jobs_completed(self): 1450 1450 # helper function waiting until the current export job is completed 1451 1451 manager = getUtility(IJobManager) 1452 job_id = self.app['datacenter'].running_exports[0][0] 1453 job = manager.get(job_id) 1454 wait_for_result(job) 1455 return job_id 1452 job_ids = [i[0] for i in self.app['datacenter'].running_exports] 1453 jobs = [manager.get(job_id) for job_id in job_ids] 1454 for job in jobs: 1455 wait_for_result(job) 1456 return job_ids 1456 1457 1457 1458 def test_applicants_in_container_export(self): … … 1460 1461 self.browser.open(container_path) 1461 1462 self.browser.getLink("Export applicants").click() 1462 self.browser.getControl("Start new export").click() 1463 1464 # When the job is finished and we reload the page... 1465 job_id = self.wait_for_export_job_completed() 1463 self.browser.getControl("Start new exports").click() 1464 job_ids = self.wait_for_export_jobs_completed() 1465 # Two exports were created 1466 self.assertEqual(len(self.app['datacenter'].running_exports), 2) 1467 # When the jobs are finished and we reload the page... 1466 1468 self.browser.open(container_path + '/exports') 1467 # ... the csv filecan be downloaded ...1468 self.browser.getLink("Download" ).click()1469 # ... the both csv files can be downloaded ... 1470 self.browser.getLink("Download", index=0).click() 1469 1471 self.assertEqual(self.browser.headers['content-type'], 1470 1472 'text/csv; charset=UTF-8') 1471 1473 self.assertTrue( 1472 'filename="WAeUP.Kofa_applicants_%s.csv' % job_id in1474 'filename="WAeUP.Kofa_applicants_%s.csv' % job_ids[0] in 1473 1475 self.browser.headers['content-disposition']) 1474 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 1475 job_id = self.app['datacenter'].running_exports[0][0] 1476 self.browser.open(container_path + '/exports') 1477 self.browser.getLink("Download", index=1).click() 1478 self.assertEqual(self.browser.headers['content-type'], 1479 'text/csv; charset=UTF-8') 1480 self.assertTrue( 1481 'filename="WAeUP.Kofa_applicantpayments_%s.csv' % job_ids[1] in 1482 self.browser.headers['content-disposition']) 1476 1483 # ... and discarded 1477 1484 self.browser.open(container_path + '/exports') 1485 self.browser.getControl("Discard", index=0).click() 1486 self.assertEqual(len(self.app['datacenter'].running_exports), 1) 1478 1487 self.browser.getControl("Discard").click() 1479 1488 self.assertEqual(len(self.app['datacenter'].running_exports), 0) 1480 # Creation, downloading and discarding islogged1489 # Creation, downloading and discarding are logged 1481 1490 logfile = os.path.join( 1482 1491 self.app['datacenter'].storage, 'logs', 'datacenter.log') … … 1485 1494 'zope.mgr - applicants.browser.ExportJobContainerJobStart - ' 1486 1495 'exported: applicants (%s), job_id=%s' 1487 % (container_name_1, job_id ) in logcontent1496 % (container_name_1, job_ids[0]) in logcontent 1488 1497 ) 1489 1498 self.assertTrue( 1490 1499 'zope.mgr - applicants.browser.ExportJobContainerDownload ' 1491 1500 '- downloaded: WAeUP.Kofa_applicants_%s.csv, job_id=%s' 1492 % (job_id , job_id) in logcontent1501 % (job_ids[0], job_ids[0]) in logcontent 1493 1502 ) 1494 1503 self.assertTrue( 1495 1504 'zope.mgr - applicants.browser.ExportJobContainerOverview ' 1496 '- discarded: job_id=%s' % job_id in logcontent1505 '- discarded: job_id=%s' % job_ids[0] in logcontent 1497 1506 ) 1507 self.assertTrue( 1508 'zope.mgr - applicants.browser.ExportJobContainerJobStart - ' 1509 'exported: applicantpayments (%s), job_id=%s' 1510 % (container_name_1, job_ids[1]) in logcontent 1511 ) 1512 self.assertTrue( 1513 'zope.mgr - applicants.browser.ExportJobContainerDownload ' 1514 '- downloaded: WAeUP.Kofa_applicantpayments_%s.csv, job_id=%s' 1515 % (job_ids[1], job_ids[1]) in logcontent 1516 ) 1517 self.assertTrue( 1518 'zope.mgr - applicants.browser.ExportJobContainerOverview ' 1519 '- discarded: job_id=%s' % job_ids[1] in logcontent 1520 )
Note: See TracChangeset for help on using the changeset viewer.