Ignore:
Timestamp:
22 Dec 2012, 09:16:05 (12 years ago)
Author:
Henrik Bettermann
Message:

Combine ExportCSVPage and ExportJobContainerOverview? as well as ExportCSVView and ExportJobContainerDownload?. Adjust pagetemplates. Do not remove jobs after download. Display jobs of all users on ExportCSVPage.

One test still fails because we do not have a logger for VirtualExportJobContainers?.

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  
    3737    KofaForm, NullValidator)
    3838from waeup.kofa.browser.breadcrumbs import Breadcrumb
    39 from waeup.kofa.browser.pages import ContactAdminForm
     39from waeup.kofa.browser.pages import ContactAdminForm, ExportCSVView, doll_up
    4040from waeup.kofa.browser.resources import (
    4141    datepicker, datatable, tabs, warning, toggleall)
     
    26612661    pnav = 1
    26622662
    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 status
    2676             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 = entries
    2695         pass
    2696 
    26972663    def update(self, CREATE=None, DISCARD=None, job_id=None):
    26982664        if CREATE:
     
    27032669            self.context.delete_export_entry(entry)
    27042670            self.flash(_('Discarded export') + ' %s' % job_id)
    2705         self.doll_up()
     2671        self.entries = doll_up(self, user=self.request.principal.id)
    27062672        return
    27072673
     
    27712737        return
    27722738
    2773 class ExportJobContainerDownload(grok.View):
     2739class ExportJobContainerDownload(ExportCSVView):
    27742740    """Page that configures a students export job.
    27752741    """
    27762742    grok.context(VirtualExportJobContainer)
    27772743    grok.require('waeup.showStudents')
    2778     grok.name('download')
    2779 
    2780     def update(self, job_id=None):
    2781         self.job_id=job_id
    2782         return
    2783 
    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  
    1616      </td>
    1717      <td>
    18         <span tal:replace="job/descr">DESCRIPTION</span>
     18        <span tal:replace="structure job/descr">DESCRIPTION</span>
    1919      </td>
    2020      <td>
     
    2828      </td>
    2929      <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>
    3039        <form method="POST">
    3140          <input type="hidden" name="job_id"
    3241                 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>
    3742          <input type="submit" class="btn secondary"
    3843                 name="DISCARD" value="Discard"
    3944                 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             Reload
    44           </a>
    4545        </form>
    4646      </td>
Note: See TracChangeset for help on using the changeset viewer.