Ignore:
Timestamp:
26 Sep 2013, 09:37:25 (11 years ago)
Author:
Henrik Bettermann
Message:

Implement an VirtualApplicantsExportJobContainer? which allows to export applicants locally. On each container page there is now an'Export applicants' button which directs to the exports overview page. Unlike student exporters, the applicants exporter can't be configured. It just exports all applicants in the container.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r10645 r10655  
    3434    IApplicantRegisterUpdate
    3535    )
    36 from waeup.kofa.applicants.container import ApplicantsContainer
     36from waeup.kofa.applicants.container import (
     37    ApplicantsContainer, VirtualApplicantsExportJobContainer)
    3738from waeup.kofa.applicants.applicant import search
    3839from waeup.kofa.applicants.workflow import (
     
    4849from waeup.kofa.browser.layout import (
    4950    NullValidator, jsaction, action, UtilityView, JSAction)
    50 from waeup.kofa.browser.pages import add_local_role, del_local_roles
     51from waeup.kofa.browser.pages import (
     52    add_local_role, del_local_roles, doll_up, ExportCSVView)
    5153from waeup.kofa.browser.resources import datepicker, tabs, datatable, warning
    5254from waeup.kofa.interfaces import (
     
    273275    """
    274276    grok.context(IApplicantsContainer)
     277
     278
     279class ApplicantsExportsBreadcrumb(Breadcrumb):
     280    """A breadcrumb for exports.
     281    """
     282    grok.context(VirtualApplicantsExportJobContainer)
     283    title = _(u'Applicant Data Exports')
     284    target = None
    275285
    276286class ApplicantBreadcrumb(Breadcrumb):
     
    11621172        self.applicant_id = applicant_id
    11631173        return
     1174
     1175class ExportJobContainerOverview(KofaPage):
     1176    """Page that lists active applicant data export jobs and provides links
     1177    to discard or download CSV files.
     1178
     1179    """
     1180    grok.context(VirtualApplicantsExportJobContainer)
     1181    grok.require('waeup.manageApplication')
     1182    grok.name('index.html')
     1183    grok.template('exportjobsindex')
     1184    label = _('Applicant Data Exports')
     1185    pnav = 3
     1186
     1187    def update(self, CREATE=None, DISCARD=None, job_id=None):
     1188        if CREATE:
     1189            self.redirect(self.url('@@start_export'))
     1190            return
     1191        if DISCARD and job_id:
     1192            entry = self.context.entry_from_job_id(job_id)
     1193            self.context.delete_export_entry(entry)
     1194            ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
     1195            self.context.logger.info(
     1196                '%s - discarded: job_id=%s' % (ob_class, job_id))
     1197            self.flash(_('Discarded export') + ' %s' % job_id)
     1198        self.entries = doll_up(self, user=self.request.principal.id)
     1199        return
     1200
     1201class ExportJobContainerJobStart(KofaPage):
     1202    """Page that starts an applicants export job.
     1203
     1204    """
     1205    grok.context(VirtualApplicantsExportJobContainer)
     1206    grok.require('waeup.manageApplication')
     1207    grok.name('start_export')
     1208
     1209    def update(self):
     1210        exporter = 'applicants'
     1211        container_code = self.context.__parent__.code
     1212        job_id = self.context.start_export_job(exporter,
     1213                                      self.request.principal.id,
     1214                                      container=container_code)
     1215
     1216        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
     1217        self.context.logger.info(
     1218            '%s - exported: %s (%s), job_id=%s'
     1219            % (ob_class, exporter, container_code, job_id))
     1220        self.flash(_('Export started.'))
     1221        self.redirect(self.url(self.context))
     1222        return
     1223
     1224    def render(self):
     1225        return
     1226
     1227class ExportJobContainerDownload(ExportCSVView):
     1228    """Page that downloads a students export csv file.
     1229
     1230    """
     1231    grok.context(VirtualApplicantsExportJobContainer)
     1232    grok.require('waeup.manageApplication')
Note: See TracChangeset for help on using the changeset viewer.