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

Enable report creation over all levels.

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

Legend:

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

    r10575 r10579  
    220220            container = self.context.__parent__
    221221            user_id = self.request.principal.id
     222            if level is not None:
     223                level = int(level)
     224            if session is not None:
     225                session = int(session)
    222226            kw = dict(
    223                 session=int(session),
    224                 level=int(level),
     227                session=session,
     228                level=level,
    225229                faccode=faccode,
    226230                depcode=depcode)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/session_results_presentation.py

    r10578 r10579  
    6767                continue
    6868        else:
    69             # XXX: Not yet supported by by generator page
    7069            itemcount = 0
    7170            for item in stud['studycourse'].values():
     
    118117        site = grok.getSite()
    119118        self.session = academic_sessions_vocab.getTerm(session).title
    120         self.level = course_levels.getTerm(level).title
     119        if level == None:
     120            self.level = 'All levels'
     121        else:
     122            self.level = course_levels.getTerm(level).title
    121123        self.levelcode = level
    122124        self.sessioncode = session
     
    153155            gpa_class += 1
    154156
    155         # XXX: Not yet supported by by generator page
    156157        if self.data[-1]:
    157158            pdf_data.append(Spacer(1, 20))
     
    202203    label = _('Create session results presentation')
    203204
     205    def update(self, CREATE=None, faccode_depcode=None,
     206               session=None, level=None):
     207        if level == 'all':
     208            level = None
     209        super(SessionResultsPresentationGeneratorPage, self).update(
     210            CREATE, faccode_depcode ,session, level)
     211
     212    def _set_level_values(self):
     213        vocab_terms = course_levels.by_value.values()
     214        self.levels = [('All levels', 'all')] + sorted(
     215            [(x.title, x.token) for x in vocab_terms])
     216        return
     217
    204218class SessionResultsPresentationPDFView(StudentStatisticsReportPDFView):
    205219
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_session_results_presentation.py

    r10577 r10579  
    8383        return False
    8484
    85     def trigger_report_creation(self):
     85    def trigger_report_creation(self, level='100'):
    8686        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    8787        self.browser.open('http://localhost/app/reports')
     
    9090        self.browser.getControl(name="generator").value = ['session_results_presentation']
    9191        self.browser.getControl("Configure").click()
    92         self.browser.getControl(name="level").value = ['100']
     92        self.browser.getControl(name="level").value = [level]
    9393        self.browser.getControl(name="session").value = ['2010']
    9494        self.browser.getControl(name="faccode_depcode").value = ['fac1_dep1']
     
    133133            'report %s discarded' % job_id in logcontent
    134134            )
     135
    135136        return
     137
     138    def test_report_download_all_levels(self):
     139        # We can download a generated report for all levels
     140        self.trigger_report_creation(level='all')
     141        # When the job is finished and we reload the page...
     142        job_id = self.wait_for_report_job_completed()
     143        self.browser.open('http://localhost/app/reports')
     144        # ... the pdf file can be downloaded ...
     145        self.browser.getControl("Download").click()
     146        self.assertEqual(self.browser.headers['content-type'],
     147                         'application/pdf')
     148        self.assertTrue(
     149            'filename="SessionResultsPresentation_fac1_dep1_2010_None_' in
     150            self.browser.headers['content-disposition'])
     151        self.assertEqual(len(self.app['reports'].running_report_jobs), 1)
     152        job_id = self.app['reports'].running_report_jobs[0][0]
     153        # ... and discarded
     154        self.browser.open('http://localhost/app/reports')
     155        self.browser.getControl("Discard").click()
     156        self.assertEqual(len(self.app['reports'].running_report_jobs), 0)
     157        # Creation, downloading and discarding is logged
     158        logfile = os.path.join(
     159            self.app['datacenter'].storage, 'logs', 'main.log')
     160        logcontent = open(logfile).read()
     161        self.assertTrue(
     162            'INFO - zope.mgr - students.reports.session_results_presentation.SessionResultsPresentationGeneratorPage - '
     163            'report %s created: Session Results Presentation (faculty=fac1, department=dep1, session=2010, level=None)'
     164            % job_id in logcontent
     165            )
     166        self.assertTrue(
     167            'INFO - zope.mgr - students.reports.session_results_presentation.SessionResultsPresentationPDFView - '
     168            'report %s downloaded: SessionResultsPresentation_fac1_dep1_2010_None_'
     169            % job_id in logcontent
     170            )
     171        self.assertTrue(
     172            'INFO - zope.mgr - browser.reports.ReportsContainerPage - '
     173            'report %s discarded' % job_id in logcontent
     174            )
     175
     176        return
Note: See TracChangeset for help on using the changeset viewer.