Ignore:
Timestamp:
29 May 2013, 06:29:51 (12 years ago)
Author:
Henrik Bettermann
Message:

Enable bursary data export at facultiescontainer level.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
4 edited

Legend:

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

    r10244 r10247  
    419419    text = _('Manage academic section')
    420420
     421class ExportFacultiesStudentsActionButton(ManageActionButton):
     422    """ 'Export student data' button for faculties.
     423    """
     424    grok.context(IFacultiesContainer)
     425    grok.view(FacultiesContainerPage)
     426    grok.require('waeup.showStudents')
     427    icon = 'actionicon_down.png'
     428    text = _('Export student data')
     429    target = 'exports'
     430    grok.order(3)
     431
    421432class SearchFacultiesContainerActionButton(ManageActionButton):
    422433    """ 'Manage settings' button for faculties.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r10179 r10247  
    5656from waeup.kofa.university.department import (
    5757    VirtualDepartmentExportJobContainer,)
     58from waeup.kofa.university.facultiescontainer import (
     59    VirtualFacultiesExportJobContainer, FacultiesContainer)
    5860from waeup.kofa.university.certificate import (
    5961    VirtualCertificateExportJobContainer,)
     
    28782880            exporters.append((util.title, name),)
    28792881        self.exporters = exporters
     2882        return
    28802883
    28812884    @property
     
    29382941    grok.context(IDataCenter)
    29392942    redirect_target = '@@export'
     2943
     2944class FacultiesExportJobContainerJobConfig(ExportJobContainerJobConfig):
     2945    """Page that configures a students export job in facultiescontainer.
     2946
     2947    """
     2948    grok.context(VirtualFacultiesExportJobContainer)
     2949
     2950    def _set_exporter_values(self):
     2951        # Only Bursary Officers will use this export. They must
     2952        # not be allowed to export regular student data at faculties level
     2953        self.exporters = [('Bursary Data', 'bursary')]
     2954        return
    29402955
    29412956class DepartmentExportJobContainerJobConfig(ExportJobContainerJobConfig):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10178 r10247  
    28792879        return job_id
    28802880
     2881    def test_faculties_export(self):
     2882        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     2883        facs_path = 'http://localhost/app/faculties'
     2884        self.browser.open(facs_path)
     2885        self.browser.getLink("Export student data").click()
     2886        self.browser.getControl("Configure new export").click()
     2887        # Only the bursary exporter us available ot this level
     2888        self.assertFalse('<option value="students">' in self.browser.contents)
     2889        self.assertTrue('<option value="bursary">' in self.browser.contents)
     2890        self.browser.getControl(name="exporter").value = ['bursary']
     2891        self.browser.getControl(name="session").value = ['2004']
     2892        self.browser.getControl(name="level").value = ['100']
     2893        self.browser.getControl(name="mode").value = ['ug_ft']
     2894        self.browser.getControl("Create CSV file").click()
     2895
     2896        # When the job is finished and we reload the page...
     2897        job_id = self.wait_for_export_job_completed()
     2898        self.browser.open(facs_path + '/exports')
     2899        # ... the csv file can be downloaded ...
     2900        self.browser.getLink("Download").click()
     2901        self.assertEqual(self.browser.headers['content-type'],
     2902            'text/csv; charset=UTF-8')
     2903        self.assertTrue(
     2904            'filename="WAeUP.Kofa_bursary_%s.csv' % job_id in
     2905            self.browser.headers['content-disposition'])
     2906        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     2907        job_id = self.app['datacenter'].running_exports[0][0]
     2908        # ... and discarded
     2909        self.browser.open(facs_path + '/exports')
     2910        self.browser.getControl("Discard").click()
     2911        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     2912        # Creation, downloading and discarding is logged
     2913        logfile = os.path.join(
     2914            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     2915        logcontent = open(logfile).read()
     2916        self.assertTrue(
     2917            'zope.mgr - students.browser.FacultiesExportJobContainerJobConfig '
     2918            '- exported: bursary (2004, 100, ug_ft, None, None), job_id=%s'
     2919            % job_id in logcontent
     2920            )
     2921        self.assertTrue(
     2922            'zope.mgr - students.browser.ExportJobContainerDownload '
     2923            '- downloaded: WAeUP.Kofa_bursary_%s.csv, job_id=%s'
     2924            % (job_id, job_id) in logcontent
     2925            )
     2926        self.assertTrue(
     2927            'zope.mgr - students.browser.ExportJobContainerOverview '
     2928            '- discarded: job_id=%s' % job_id in logcontent
     2929            )
     2930
    28812931    def test_department_export(self):
    28822932        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
  • main/waeup.kofa/trunk/src/waeup/kofa/university/facultiescontainer.py

    r8367 r10247  
    1717##
    1818import grok
     19import zope.location.location
    1920from zope.component.interfaces import IFactory
    2021from zope.interface import implementedBy
    2122from waeup.kofa.interfaces import IKofaPluggable
    2223from waeup.kofa.university.interfaces import IFacultiesContainer, IFaculty
     24from waeup.kofa.utils.batching import VirtualExportJobContainer
     25
     26class VirtualFacultiesExportJobContainer(VirtualExportJobContainer):
     27    """A virtual export job container for certificates.
     28    """
    2329
    2430class FacultiesContainer(grok.Container):
     
    2632    """
    2733    grok.implements(IFacultiesContainer)
     34
     35    def traverse(self, name):
     36        if name == 'exports':
     37            # create a virtual exports container and return it
     38            container = VirtualFacultiesExportJobContainer()
     39            zope.location.location.located(container, self, 'exports')
     40            return container
     41        return None
    2842
    2943    def addFaculty(self, faculty):
Note: See TracChangeset for help on using the changeset viewer.