- Timestamp:
- 10 Jan 2017, 09:25:41 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py
r14374 r14381 29 29 from waeup.kofa.browser.pdf import get_signature_tables 30 30 from waeup.kofa.students.vocabularies import StudyLevelSource 31 from waeup.kofa.students.reports.level_report import LevelReportGeneratorPage 31 32 from waeup.kofa.students.reports.student_statistics import ( 32 33 StudentStatisticsReportPDFView) … … 283 284 from waeup.kofa.browser.breadcrumbs import Breadcrumb 284 285 grok.templatedir('browser_templates') 285 class RawScoreReportGeneratorPage( KofaPage):286 class RawScoreReportGeneratorPage(LevelReportGeneratorPage): 286 287 287 288 grok.context(RawScoreReportGenerator) 288 grok.name('index.html')289 grok.require('waeup.handleReports')290 grok.template('levelreportgeneratorpage')291 289 292 290 label = _('Create raw score report') 293 294 @property295 def generator_name(self):296 for name, gen in get_generators():297 if gen == self.context:298 return name299 return None300 301 def update(self, CREATE=None, faccode_depcode=None,302 session=None, level=None):303 self.parent_url = self.url(self.context.__parent__)304 self._set_session_values()305 self._set_level_values()306 self._set_faccode_depcode_values()307 if CREATE and session:308 # create a new report job for students by session309 faccode = faccode_depcode.split('_')[0]310 depcode = faccode_depcode.split('_')[1]311 container = self.context.__parent__312 user_id = self.request.principal.id313 if level:314 level = int(level)315 if session:316 session = int(session)317 kw = dict(318 session=session,319 level=level,320 faccode=faccode,321 depcode=depcode)322 self.flash(_('New report is being created in background'))323 job_id = container.start_report_job(324 self.generator_name, user_id, kw=kw)325 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')326 grok.getSite().logger.info(327 '%s - report %s created: %s (faculty=%s, department=%s, session=%s, level=%s)' % (328 ob_class, job_id, self.context.title, faccode, depcode, session, level))329 self.redirect(self.parent_url)330 return331 return332 333 def _set_session_values(self):334 vocab_terms = academic_sessions_vocab.by_value.values()335 self.sessions = [(x.title, x.token) for x in vocab_terms]336 return337 338 #def _set_level_values(self):339 # vocab_terms = course_levels.by_value.values()340 # self.levels = sorted([(x.title, x.token) for x in vocab_terms])341 # return342 343 def _set_level_values(self):344 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE345 studylevelsource = StudyLevelSource().factory346 self.levels = []347 for code in studylevelsource.getValues(None):348 title = translate(studylevelsource.getTitle(None, code),349 'waeup.kofa', target_language=portal_language)350 self.levels.append((title, code))351 return352 353 def _set_faccode_depcode_values(self):354 faccode_depcodes = []355 faculties = grok.getSite()['faculties']356 for fac in faculties.values():357 for dep in fac.values():358 faccode_depcodes.append(359 ('%s (%s)' %(dep.longtitle, fac.longtitle),360 '%s_%s' %(fac.code, dep.code)))361 self.faccode_depcodes = sorted(362 faccode_depcodes, key=lambda value: value[0])363 return364 291 365 292 class RawScoreReportPDFView(StudentStatisticsReportPDFView):
Note: See TracChangeset for help on using the changeset viewer.