Changeset 12898
- Timestamp:
- 2 May 2015, 06:12:58 (10 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
r12897 r12898 81 81 from waeup.kofa.reports import Report 82 82 from waeup.kofa.browser.interfaces import IPDFCreator 83 from waeup.kofa.university.vocabularies import course_levels84 83 85 84 STYLE = getSampleStyleSheet() … … 148 147 args=[faccode, depcode, session, level], kwargs={'author':author}) 149 148 site = grok.getSite() 149 self.studylevelsource = StudyLevelSource().factory 150 self.portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 150 151 self.session = academic_sessions_vocab.getTerm(session).title 151 self.level = course_levels.getTerm(level).title 152 self.level = translate(self.studylevelsource.getTitle(None, int(level)), 153 'waeup.kofa', target_language=self.portal_language) 152 154 self.levelcode = level 153 155 self.sessioncode = session … … 170 172 STYLE["Normal"]), 171 173 Spacer(1, 12),] 172 pdf_data += [Paragraph('%s<br />%s<br />Level: %s<br />Session: %s' % ( 173 self.factitle, self.deptitle, self.level, self.session), 174 pdf_data += [Paragraph( 175 translate( 176 '${a}<br />${b}<br />Level: ${c}<br />Session: ${d}', 177 mapping = {'a':self.factitle, 178 'b':self.deptitle, 179 'c':self.level, 180 'd':self.session, }), 174 181 STYLE["Normal"]), 175 182 Spacer(1, 12),] … … 179 186 180 187 pdf_data.append(Spacer(1, 40)) 181 signatures = ['Ag. Head of Department', 'Dean of Faculty'] 188 signatures = [ 189 translate(_('Ag. Head of Department')), 190 translate(_('Dean of Faculty'))] 182 191 signaturetables = get_signature_tables(signatures, landscape=True) 183 192 pdf_data.append(signaturetables[0]) … … 239 248 container = self.context.__parent__ 240 249 user_id = self.request.principal.id 241 if level is not None:250 if level: 242 251 level = int(level) 243 if session is not None:252 if session: 244 253 session = int(session) 245 254 kw = dict( -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/session_results_presentation.py
r11254 r12898 17 17 ## 18 18 import grok 19 from zope.i18n import translate 19 20 from zope.catalog.interfaces import ICatalog 20 21 from zope.component import queryUtility, getUtility … … 23 24 IKofaUtils, 24 25 academic_sessions_vocab, registration_states_vocab) 26 from waeup.kofa.students.vocabularies import StudyLevelSource 25 27 from waeup.kofa.students.interfaces import IStudentsUtils 26 28 from waeup.kofa.interfaces import MessageFactory as _ … … 60 62 stud.display_fullname, 61 63 ) 62 if level is not None:64 if level != 0: 63 65 if not stud['studycourse'].has_key(str(level)): 64 66 continue … … 76 78 continue 77 79 if itemcount > 1: 78 # Error: more than one sessionregistered in this session80 # Error: more than one level registered in this session 79 81 table[len(students_utils.gpa_boundaries)].append(line) 80 82 continue … … 95 97 from waeup.kofa.reports import Report 96 98 from waeup.kofa.browser.interfaces import IPDFCreator 97 from waeup.kofa.university.vocabularies import course_levels98 99 99 100 STYLE = getSampleStyleSheet() … … 121 122 args=[faccode, depcode, session, level], kwargs={'author':author}) 122 123 site = grok.getSite() 124 self.studylevelsource = StudyLevelSource().factory 125 self.portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 123 126 self.session = academic_sessions_vocab.getTerm(session).title 124 if level == None:125 self.level = 'All levels'127 if level == 0: 128 self.level = translate(_('all levels')) 126 129 else: 127 self.level = course_levels.getTerm(level).title 130 self.level = translate(self.studylevelsource.getTitle(None, int(level)), 131 'waeup.kofa', target_language=self.portal_language) 128 132 self.levelcode = level 129 133 self.sessioncode = session … … 181 185 class SessionResultsPresentationGenerator(grok.GlobalUtility): 182 186 183 title = _('Session Results Presentation')187 title = 'Session Results Presentation' 184 188 grok.name('session_results_presentation') 185 189 … … 208 212 def update(self, CREATE=None, faccode_depcode=None, 209 213 session=None, level=None): 210 if level == 'all':211 level = None212 214 super(SessionResultsPresentationGeneratorPage, self).update( 213 215 CREATE, faccode_depcode ,session, level) 214 216 217 #def _set_level_values(self): 218 # vocab_terms = course_levels.by_value.values() 219 # self.levels = [('All levels', 'all')] + sorted( 220 # [(x.title, x.token) for x in vocab_terms]) 221 # return 222 215 223 def _set_level_values(self): 216 vocab_terms = course_levels.by_value.values() 217 self.levels = [('All levels', 'all')] + sorted( 218 [(x.title, x.token) for x in vocab_terms]) 224 portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE 225 studylevelsource = StudyLevelSource().factory 226 self.levels = [(u'All levels', 0)] 227 for code in studylevelsource.getValues(None): 228 title = translate(studylevelsource.getTitle(None, code), 229 'waeup.kofa', target_language=portal_language) 230 self.levels.append((title, code)) 219 231 return 220 232 -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_session_results_presentation.py
r10581 r12898 12 12 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 13 13 from waeup.kofa.browser.tests.test_pdf import samples_dir 14 from waeup.kofa.students.studylevel import StudentStudyLevel 14 from waeup.kofa.students.studylevel import StudentStudyLevel, CourseTicket 15 15 16 16 class SessionResultsPresentationTests(CatalogTestSetup): … … 32 32 33 33 def test_get_students_at_all_levels(self): 34 result = get_students('fac1', 'dep1', 2010 )34 result = get_students('fac1', 'dep1', 2010, 0) 35 35 self.assertEqual(result, 36 36 [[], [], [], [], [], [(u'K1000000', u'1234', u'Bob Tester')], []]) … … 43 43 studylevel.level_session = 2010 44 44 self.student['studycourse']['200'] = studylevel 45 result = get_students('fac1', 'dep1', 2010 )45 result = get_students('fac1', 'dep1', 2010, 0) 46 46 self.assertEqual(result, 47 47 [[], [], [], [], [], [], [(u'K1000000', u'1234', u'Bob Tester')]]) … … 50 50 def test_get_students_without_scores(self): 51 51 self.student['studycourse']['100']['Course1'].score = None 52 result = get_students('fac1', 'dep1', 2010 )52 result = get_students('fac1', 'dep1', 2010, 0) 53 53 self.assertEqual(result, 54 54 [[], [], [], [], [], [], [(u'K1000000', u'1234', u'Bob Tester')]]) … … 70 70 return 71 71 72 def test_create_pdf_620(self): 73 studylevel = StudentStudyLevel() 74 studylevel.level = 620 75 studylevel.level_session = 2013 76 ticket = CourseTicket() 77 ticket.code = 'Course2' 78 ticket.credits = 40 79 ticket.score = 44 80 self.student['studycourse']['620'] = studylevel 81 self.student['studycourse']['620']['Course2'] = ticket 82 report = SessionResultsPresentation('fac1', 'dep1', 2013, 620) 83 result = report.create_pdf() 84 self.assertTrue(result.startswith('%PDF-')) 85 path = os.path.join(samples_dir(), 'session_results_presentation_620.pdf') 86 open(path, 'wb').write(result) 87 print "Sample session_results_presentation_620.pdf written to %s" % path 88 return 89 72 90 def test_create_pdf_with_two_levels_in_session(self): 73 # Register second level in the same session (which shouldn't be!)91 # Register second level with tickets in the same session (which shouldn't be!) 74 92 # Check the pdf file if the student record has really been classified 75 93 # as erroneous. … … 77 95 studylevel.level = 200 78 96 studylevel.level_session = 2010 97 ticket = CourseTicket() 98 ticket.code = 'Course2' 99 ticket.credits = 40 100 ticket.score = 11 79 101 self.student['studycourse']['200'] = studylevel 80 report = SessionResultsPresentation('fac1', 'dep1', 2010, None) 102 self.student['studycourse']['200']['Course2'] = ticket 103 report = SessionResultsPresentation('fac1', 'dep1', 2010, 0) 81 104 result = report.create_pdf() 82 105 self.assertTrue(result.startswith('%PDF-')) … … 160 183 def test_report_download_all_levels(self): 161 184 # We can download a generated report for all levels 162 self.trigger_report_creation(level=' all')185 self.trigger_report_creation(level='0') 163 186 # When the job is finished and we reload the page... 164 187 job_id = self.wait_for_report_job_completed() … … 169 192 'application/pdf') 170 193 self.assertTrue( 171 'filename="SessionResultsPresentation_fac1_dep1_2010_ None_' in194 'filename="SessionResultsPresentation_fac1_dep1_2010_0_' in 172 195 self.browser.headers['content-disposition']) 173 196 self.assertEqual(len(self.app['reports'].running_report_jobs), 1) … … 183 206 self.assertTrue( 184 207 'INFO - zope.mgr - students.reports.session_results_presentation.SessionResultsPresentationGeneratorPage - ' 185 'report %s created: Session Results Presentation (faculty=fac1, department=dep1, session=2010, level= None)'208 'report %s created: Session Results Presentation (faculty=fac1, department=dep1, session=2010, level=0)' 186 209 % job_id in logcontent 187 210 ) 188 211 self.assertTrue( 189 212 'INFO - zope.mgr - students.reports.session_results_presentation.SessionResultsPresentationPDFView - ' 190 'report %s downloaded: SessionResultsPresentation_fac1_dep1_2010_ None_'213 'report %s downloaded: SessionResultsPresentation_fac1_dep1_2010_0_' 191 214 % job_id in logcontent 192 215 )
Note: See TracChangeset for help on using the changeset viewer.