Ignore:
Timestamp:
8 Jan 2013, 07:52:55 (12 years ago)
Author:
Henrik Bettermann
Message:

Implement local student data exports in certificates.

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

    r9838 r9842  
    5656from waeup.kofa.university.department import (
    5757    VirtualDepartmentExportJobContainer,)
     58from waeup.kofa.university.certificate import (
     59    VirtualCertificateExportJobContainer,)
    5860from waeup.kofa.university.vocabularies import course_levels
    5961from waeup.kofa.utils.batching import VirtualExportJobContainer
     
    27242726        return None
    27252727
     2728    @property
     2729    def certcode(self):
     2730        return None
     2731
    27262732    def update(self, START=None, session=None, level=None, mode=None,
    27272733               exporter=None):
     
    27432749                                      current_level=level,
    27442750                                      current_mode=mode,
    2745                                       depcode=self.depcode)
     2751                                      depcode=self.depcode,
     2752                                      certcode=self.certcode)
    27462753        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    27472754        self.context.logger.info(
    2748             '%s - exported: %s (%s, %s, %s, %s), job_id=%s'
    2749             % (ob_class, exporter, session, level, mode, self.depcode, job_id))
     2755            '%s - exported: %s (%s, %s, %s, %s, %s), job_id=%s'
     2756            % (ob_class, exporter, session, level, mode, self.depcode,
     2757            self.certcode, job_id))
    27502758        self.flash(_('Export started for students with') +
    27512759                   ' current_session=%s, current_level=%s, study_mode=%s' % (
     
    27772785    def depcode(self):
    27782786        return self.context.__parent__.code
     2787
     2788class CertificateExportJobContainerJobConfig(ExportJobContainerJobConfig):
     2789    """Page that configures a students export job for certificates.
     2790
     2791    """
     2792    grok.context(VirtualCertificateExportJobContainer)
     2793
     2794    @property
     2795    def certcode(self):
     2796        return self.context.__parent__.code
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9837 r9842  
    27762776        self.assertTrue(
    27772777            'zope.mgr - students.browser.DepartmentExportJobContainerJobConfig '
    2778             '- exported: students (2004, 100, ug_ft, dep1), job_id='
     2778            '- exported: students (2004, 100, ug_ft, dep1, None), job_id=%s'
     2779            % job_id in logcontent
    27792780            )
    27802781        self.assertTrue(
    27812782            'zope.mgr - students.browser.ExportJobContainerDownload '
    27822783            '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s'
    2783             % (job_id, job_id)
     2784            % (job_id, job_id) in logcontent
    27842785            )
    27852786        self.assertTrue(
    27862787            'zope.mgr - students.browser.ExportJobContainerOverview '
    2787             '- discarded: job_id=%s' % job_id
     2788            '- discarded: job_id=%s' % job_id in logcontent
    27882789            )
     2790
     2791    def test_certificate_export(self):
     2792        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     2793        cert1_path = 'http://localhost/app/faculties/fac1/dep1/certificates/CERT1'
     2794        self.browser.open(cert1_path)
     2795        self.browser.getLink("Export student data").click()
     2796        self.browser.getControl("Configure new export").click()
     2797        self.browser.getControl(name="exporter").value = ['students']
     2798        self.browser.getControl(name="session").value = ['2004']
     2799        self.browser.getControl(name="level").value = ['100']
     2800        self.browser.getControl(name="mode").value = ['ug_ft']
     2801        self.browser.getControl("Create CSV file").click()
     2802
     2803        # When the job is finished and we reload the page...
     2804        job_id = self.wait_for_export_job_completed()
     2805        self.browser.open(cert1_path + '/exports')
     2806        # ... the csv file can be downloaded ...
     2807        self.browser.getLink("Download").click()
     2808        self.assertEqual(self.browser.headers['content-type'],
     2809            'text/csv; charset=UTF-8')
     2810        self.assertTrue(
     2811            'filename="WAeUP.Kofa_students_%s.csv' % job_id in
     2812            self.browser.headers['content-disposition'])
     2813        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     2814        job_id = self.app['datacenter'].running_exports[0][0]
     2815        # ... and discarded
     2816        self.browser.open(cert1_path + '/exports')
     2817        self.browser.getControl("Discard").click()
     2818        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     2819        # Creation, downloading and discarding is logged
     2820        logfile = os.path.join(
     2821            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     2822        logcontent = open(logfile).read()
     2823        self.assertTrue(
     2824            'zope.mgr - students.browser.CertificateExportJobContainerJobConfig '
     2825            '- exported: students (2004, 100, ug_ft, None, CERT1), job_id=%s'
     2826            % job_id in logcontent
     2827            )
     2828        self.assertTrue(
     2829            'zope.mgr - students.browser.ExportJobContainerDownload '
     2830            '- downloaded: WAeUP.Kofa_students_%s.csv, job_id=%s'
     2831            % (job_id, job_id) in logcontent
     2832            )
     2833        self.assertTrue(
     2834            'zope.mgr - students.browser.ExportJobContainerOverview '
     2835            '- discarded: job_id=%s' % job_id in logcontent
     2836            )
Note: See TracChangeset for help on using the changeset viewer.