Changeset 10579 for main/waeup.kofa/trunk
- Timestamp:
- 2 Sep 2013, 11:45:45 (11 years ago)
- 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 220 220 container = self.context.__parent__ 221 221 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) 222 226 kw = dict( 223 session= int(session),224 level= int(level),227 session=session, 228 level=level, 225 229 faccode=faccode, 226 230 depcode=depcode) -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/session_results_presentation.py
r10578 r10579 67 67 continue 68 68 else: 69 # XXX: Not yet supported by by generator page70 69 itemcount = 0 71 70 for item in stud['studycourse'].values(): … … 118 117 site = grok.getSite() 119 118 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 121 123 self.levelcode = level 122 124 self.sessioncode = session … … 153 155 gpa_class += 1 154 156 155 # XXX: Not yet supported by by generator page156 157 if self.data[-1]: 157 158 pdf_data.append(Spacer(1, 20)) … … 202 203 label = _('Create session results presentation') 203 204 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 204 218 class SessionResultsPresentationPDFView(StudentStatisticsReportPDFView): 205 219 -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_session_results_presentation.py
r10577 r10579 83 83 return False 84 84 85 def trigger_report_creation(self ):85 def trigger_report_creation(self, level='100'): 86 86 self.browser.addHeader('Authorization', 'Basic mgr:mgrpw') 87 87 self.browser.open('http://localhost/app/reports') … … 90 90 self.browser.getControl(name="generator").value = ['session_results_presentation'] 91 91 self.browser.getControl("Configure").click() 92 self.browser.getControl(name="level").value = [ '100']92 self.browser.getControl(name="level").value = [level] 93 93 self.browser.getControl(name="session").value = ['2010'] 94 94 self.browser.getControl(name="faccode_depcode").value = ['fac1_dep1'] … … 133 133 'report %s discarded' % job_id in logcontent 134 134 ) 135 135 136 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.