Changeset 10575


Ignore:
Timestamp:
2 Sep 2013, 06:40:49 (11 years ago)
Author:
Henrik Bettermann
Message:

Make StudentStatisticsReportPDFView reusable.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students/reports
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/level_report.py

    r10574 r10575  
    2626from waeup.kofa.reports import IReport
    2727from waeup.kofa.browser.pdf import get_signature_tables
     28from waeup.kofa.students.reports.student_statistics import (
     29    StudentStatisticsReportPDFView)
    2830
    2931class ILevelReport(IReport):
     
    256258        return
    257259
    258 class LevelReportPDFView(grok.View):
     260class LevelReportPDFView(StudentStatisticsReportPDFView):
    259261
    260262    grok.context(ILevelReport)
    261263    grok.name('pdf')
    262264    grok.require('waeup.Public')
    263 
    264     def render(self):
    265         filename = 'LevelReport_%s_%s_%s_%s_%s.pdf' % (
     265    prefix = 'LevelReport'
     266
     267    def _filename(self):
     268        return 'LevelReport_%s_%s_%s_%s_%s.pdf' % (
    266269            self.context.faccode, self.context.depcode,
    267270            self.context.sessioncode, self.context.levelcode,
    268271            self.context.creation_dt_string)
    269         filename = filename.replace(
    270             '/', '_').replace(' ','_').replace(':', '-')
    271         self.response.setHeader(
    272             'Content-Type', 'application/pdf')
    273         self.response.setHeader(
    274             'Content-Disposition:', 'attachment; filename="%s' % filename)
    275         pdf_stream = self.context.create_pdf()
    276         ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    277         grok.getSite().logger.info('%s - report %s downloaded: %s' % (
    278             ob_class, self.context.__name__, filename))
    279         return pdf_stream
     272
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/student_statistics.py

    r10565 r10575  
    221221    grok.name('pdf')
    222222    grok.require('waeup.Public')
    223 
    224     def render(self):
    225         filename = 'StudentStatisticsReport_%s_%s_%s.pdf' % (
     223    prefix = ''
     224
     225    def _filename(self):
     226        return 'StudentStatisticsReport_%s_%s_%s.pdf' % (
    226227            self.context.session, self.context.mode,
    227228            self.context.creation_dt_string)
    228         filename = filename.replace(
     229
     230    def render(self):
     231        filename = self._filename().replace(
    229232            '/', '_').replace(' ','_').replace(':', '-')
    230233        self.response.setHeader(
Note: See TracChangeset for help on using the changeset viewer.