Changeset 9822 for main/waeup.kofa/trunk/src/waeup/kofa/students
- Timestamp:
- 22 Dec 2012, 09:16:05 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r9819 r9822 37 37 KofaForm, NullValidator) 38 38 from waeup.kofa.browser.breadcrumbs import Breadcrumb 39 from waeup.kofa.browser.pages import ContactAdminForm 39 from waeup.kofa.browser.pages import ContactAdminForm, ExportCSVView, doll_up 40 40 from waeup.kofa.browser.resources import ( 41 41 datepicker, datatable, tabs, warning, toggleall) … … 2661 2661 pnav = 1 2662 2662 2663 def doll_up(self):2664 job_entries = self.context.get_running_export_jobs(2665 self.request.principal.id)2666 job_manager = getUtility(IJobManager)2667 entries = []2668 for job_id, exporter_name, user_id in job_entries:2669 job = job_manager.get(job_id)2670 exporter = getUtility(ICSVExporter, name=exporter_name)2671 exporter_title = getattr(exporter, 'title', 'Unknown')2672 args = ', '.join([str(x) for x in job.kwargs.values()])2673 descr = '%s (%s)' % (exporter_title, args)2674 status = job.finished and 'ready' or 'running'2675 status = job.failed and 'FAILED' or status2676 start_time = getattr(job, 'begin_after', None)2677 if start_time:2678 start_time = start_time.astimezone(2679 getUtility(2680 IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z")2681 download_url = self.url(self.context, 'download',2682 data=dict(job_id=job_id))2683 new_entry = dict(2684 job=job_id,2685 descr=descr,2686 creator=user_id,2687 status=status,2688 start_time=start_time,2689 download_url=download_url,2690 show_download_button = (job.finished and not job.failed),2691 show_refresh_button = not job.finished,2692 show_discard_button = job.finished,)2693 entries.append(new_entry)2694 self.entries = entries2695 pass2696 2697 2663 def update(self, CREATE=None, DISCARD=None, job_id=None): 2698 2664 if CREATE: … … 2703 2669 self.context.delete_export_entry(entry) 2704 2670 self.flash(_('Discarded export') + ' %s' % job_id) 2705 self. doll_up()2671 self.entries = doll_up(self, user=self.request.principal.id) 2706 2672 return 2707 2673 … … 2771 2737 return 2772 2738 2773 class ExportJobContainerDownload( grok.View):2739 class ExportJobContainerDownload(ExportCSVView): 2774 2740 """Page that configures a students export job. 2775 2741 """ 2776 2742 grok.context(VirtualExportJobContainer) 2777 2743 grok.require('waeup.showStudents') 2778 grok.name('download')2779 2780 def update(self, job_id=None):2781 self.job_id=job_id2782 return2783 2784 def render(self):2785 job = getUtility(IJobManager).get(self.job_id)2786 self.response.setHeader(2787 'Content-Type', 'text/csv; charset=UTF-8')2788 self.response.setHeader(2789 'Content-Disposition:', 'attachment; filename="%s' % (2790 'students.csv',))2791 return open(job.result, 'rb') -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportjobsindex.pt
r9821 r9822 16 16 </td> 17 17 <td> 18 <span tal:replace=" job/descr">DESCRIPTION</span>18 <span tal:replace="structure job/descr">DESCRIPTION</span> 19 19 </td> 20 20 <td> … … 28 28 </td> 29 29 <td nowrap> 30 <a href="" class="btn" i18n:translate="" 31 tal:condition="job/show_refresh_button"> 32 <img tal:attributes="src static/actionicon_reload.png" /> 33 Reload 34 </a> 35 <a href="" class="btn primary" 36 tal:attributes="href job/download_url" 37 tal:condition="job/show_download_button"> 38 Download</a> 30 39 <form method="POST"> 31 40 <input type="hidden" name="job_id" 32 41 tal:attributes="value job/job" /> 33 <a href="" class="btn primary"34 tal:attributes="href job/download_url"35 tal:condition="job/show_download_button">36 Download</a>37 42 <input type="submit" class="btn secondary" 38 43 name="DISCARD" value="Discard" 39 44 tal:condition="job/show_discard_button" /> 40 <a href="" class="btn" i18n:translate=""41 tal:condition="job/show_refresh_button">42 <img tal:attributes="src static/actionicon_reload.png" />43 Reload44 </a>45 45 </form> 46 46 </td>
Note: See TracChangeset for help on using the changeset viewer.