Changeset 9842


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
Files:
4 edited

Legend:

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

    r9819 r9842  
    472472    text = _('Edit course')
    473473   
    474 class ManageCertificateActionButton(ManageActionButton):
    475     """ 'Manage settings' button for certificates.
    476     """
    477     grok.context(ICertificate)
    478     grok.view(CertificatePage)
    479     text = _('Manage certificate')
    480 
    481474class ShowCourseStudentsActionButton(ManageActionButton):
    482475    """ 'Show students' button in course.
     
    489482    target = 'students'
    490483
     484class ManageCertificateActionButton(ManageActionButton):
     485    """ 'Manage settings' button for certificates.
     486    """
     487    grok.context(ICertificate)
     488    grok.view(CertificatePage)
     489    text = _('Manage certificate')
     490    grok.order(1)
     491
    491492class ShowCertificateStudentsActionButton(ManageActionButton):
    492493    """ 'Show students' button for certificates.
     
    498499    text = _('Show students')
    499500    target = 'students'
     501    grok.order(2)
     502
     503class ExportCertificateStudentsActionButton(ManageActionButton):
     504    """ 'Export student data' button for certificates.
     505    """
     506    grok.context(ICertificate)
     507    grok.view(CertificatePage)
     508    grok.require('waeup.showStudents')
     509    icon = 'actionicon_down.png'
     510    text = _('Export student data')
     511    target = 'exports'
     512    grok.order(3)
    500513
    501514class ManageCertificateCourseActionButton(ManageActionButton):
  • 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            )
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py

    r9826 r9842  
    1919"""
    2020import grok
     21import zope.location.location
    2122from zope.event import notify
    2223from zope.catalog.interfaces import ICatalog
     
    3031    ICertificate, ICertificateAdd, ICertificateCourse)
    3132from waeup.kofa.university.vocabularies import course_levels
     33from waeup.kofa.utils.batching import VirtualExportJobContainer
     34
     35class VirtualCertificateExportJobContainer(VirtualExportJobContainer):
     36    """A virtual export job container for certificates.
     37    """
    3238
    3339class Certificate(grok.Container):
     
    6167        self.school_fee_3 = school_fee_3
    6268        self.school_fee_4 = school_fee_4
     69
     70    def traverse(self, name):
     71        """Deliver appropriate containers.
     72        """
     73        if name == 'exports':
     74            # create a virtual exports container and return it
     75            container = VirtualCertificateExportJobContainer()
     76            zope.location.location.located(container, self, 'exports')
     77            return container
     78        return None
    6379
    6480    def longtitle(self):
Note: See TracChangeset for help on using the changeset viewer.