Changeset 15498 for main/kofacustom.dspg/trunk/src
- Timestamp:
- 15 Jul 2019, 19:44:05 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.dspg/trunk/src/kofacustom/dspg/applicants/browser.py
r14865 r15498 19 19 """ 20 20 import grok 21 from zope.component import getUtility 21 from zope.component import getUtility, queryUtility 22 22 from zope.i18n import translate 23 23 from hurry.workflow.interfaces import IWorkflowState … … 25 25 from zope.formlib.textwidgets import BytesDisplayWidget 26 26 from waeup.kofa.interfaces import IExtFileStore, IKofaUtils 27 from waeup.kofa.browser.pages import doll_up 27 28 from waeup.kofa.applicants.interfaces import ( 28 IApplicant, IApplicantEdit) 29 IApplicant, IApplicantEdit, 30 IApplicantsContainer,) 29 31 from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage, 30 32 ApplicantManageFormPage, ApplicantEditFormPage, 31 ApplicantsContainerPage, ApplicationFeePaymentAddPage) 33 ApplicantsContainerPage, ApplicationFeePaymentAddPage, 34 ExportJobContainerOverview, 35 ExportJobContainerJobStart, 36 ExportJobContainerDownload) 37 from waeup.kofa.browser.viewlets import ManageActionButton 32 38 from waeup.kofa.applicants.viewlets import ( 33 39 PaymentReceiptActionButton, PDFActionButton) … … 63 69 ] 64 70 71 ##### Bursary exports 72 73 class BursaryExportPaymentsActionButton(ManageActionButton): 74 """ 'Export payment data' button for faculties. 75 """ 76 grok.context(IApplicantsContainer) 77 grok.view(ApplicantsContainerPage) 78 grok.require('waeup.exportBursaryData') 79 icon = 'actionicon_down.png' 80 text = _('Export payment data') 81 target = 'bursary_exports/index2.html' 82 grok.order(4) 83 84 class BursaryExportJobContainerOverview(ExportJobContainerOverview): 85 """Page that lists active applicant data export jobs and provides links 86 to discard or download CSV files. 87 """ 88 grok.require('waeup.exportBursaryData') 89 grok.name('index2.html') 90 91 def update(self, CREATE=None, DISCARD=None, job_id=None): 92 if CREATE: 93 self.redirect(self.url('@@start_bursary_export')) 94 return 95 if DISCARD and job_id: 96 entry = self.context.entry_from_job_id(job_id) 97 self.context.delete_export_entry(entry) 98 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 99 self.context.logger.info( 100 '%s - discarded: job_id=%s' % (ob_class, job_id)) 101 self.flash(_('Discarded export') + ' %s' % job_id) 102 self.entries = doll_up(self, user=self.request.principal.id) 103 return 104 105 class BursaryExportJobContainerJobStart(ExportJobContainerJobStart): 106 """View that starts export job. 107 """ 108 grok.require('waeup.exportBursaryData') 109 grok.name('start_bursary_export') 110 111 def update(self): 112 utils = queryUtility(IKofaUtils) 113 if not utils.expensive_actions_allowed(): 114 self.flash(_( 115 "Currently, exporters cannot be started due to high " 116 "system load. Please try again later."), type='danger') 117 self.entries = doll_up(self, user=None) 118 return 119 120 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 121 container_code = self.context.__parent__.code 122 # Start payments exporter 123 exporter = 'applicantpayments' 124 job_id = self.context.start_export_job(exporter, 125 self.request.principal.id, 126 container=container_code) 127 self.context.logger.info( 128 '%s - exported: %s (%s), job_id=%s' 129 % (ob_class, exporter, container_code, job_id)) 130 131 self.flash(_('Exports started.')) 132 self.redirect(self.url(self.context)) 133 return 134 135 def render(self): 136 return 137 138 class BursaryExportJobContainerDownload(ExportJobContainerDownload): 139 """Page that downloads a students export csv file. 140 141 """ 142 grok.require('waeup.exportBursaryData') 143 grok.context(IApplicantsContainer) 144 65 145 class CustomApplicantsContainerPage(ApplicantsContainerPage): 66 146 """The standard view for regular applicant containers.
Note: See TracChangeset for help on using the changeset viewer.