Changeset 14631 for main/waeup.aaue/trunk/src
- Timestamp:
- 15 Mar 2017, 12:08:35 (8 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students/reports
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py
r14600 r14631 19 19 import grok 20 20 from zope.component import getUtility 21 from zope.interface import implementer, Interface, Attribute 21 22 from waeup.kofa.interfaces import IKofaUtils 22 23 from waeup.kofa.students.reports.session_results_presentation import ( 23 SessionResultsPresentation, SessionResultsPresentationGenerator) 24 SessionResultsPresentation, SessionResultsPresentationGenerator, 25 ISessionResultsPresentation, SessionResultsPresentationGeneratorPage, 26 SessionResultsPresentationPDFView) 24 27 25 28 class CustomSessionResultsPresentation(SessionResultsPresentation): … … 90 93 level=level, author=author) 91 94 return result 95 96 97 # Session Results Presentation for graduating students only 98 99 class IGradSessionResultsPresentation(ISessionResultsPresentation): 100 """Marker interface to distuingish graduating students level reports 101 from ordinary level reports. 102 """ 103 104 @implementer(IGradSessionResultsPresentation) 105 class GradSessionResultsPresentation(CustomSessionResultsPresentation): 106 """ 107 """ 108 109 title = 'Presentation of Results to Senate' 110 111 @property 112 def right_footer(self): 113 return self.title + ' (graduating students only) - %s -' % self.session 114 115 def _excluded(self, level_obj): 116 """ 117 """ 118 final_level = max(level_obj.student['studycourse'].keys()) 119 final_level_obj = level_obj.student['studycourse'][final_level] 120 if final_level_obj.remark not in ( 121 'Pass', '3s_rd_s', '2s_2_s', '2s_1_s', '1s_st_s'): 122 return True 123 return False 124 125 class GradSessionResultsPresentationGenerator(SessionResultsPresentationGenerator): 126 127 title = 'Presentation of Graduating Students Results to Senate' 128 grok.name('grad_session_results_presentation') 129 130 def generate(self, site, faccode=None, depcode=None, certcode=None, 131 session=None, level=None, author=None): 132 result = GradSessionResultsPresentation(faccode=faccode, depcode=depcode, 133 certcode=certcode, session=session, level=level, author=author) 134 return result 135 136 class GradSessionResultsPresentationGeneratorPage(SessionResultsPresentationGeneratorPage): 137 138 grok.context(GradSessionResultsPresentationGenerator) 139 140 class GradSessionResultsPresentationPDFView(SessionResultsPresentationPDFView): 141 142 grok.context(IGradSessionResultsPresentation) 143 grok.name('pdf') 144 grok.require('waeup.handleReports') 145 146 def _filename(self): 147 return 'GradSessionResultsPresentation_rno%s_%s.pdf' % ( 148 self.context.__name__, 149 self.context.creation_dt_string) -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py
r14608 r14631 12 12 from waeup.kofa.browser.tests.test_pdf import samples_dir 13 13 14 from waeup.aaue.students.reports.session_results_presentation import CustomSessionResultsPresentation 14 from waeup.aaue.students.reports.session_results_presentation import ( 15 CustomSessionResultsPresentation, 16 GradSessionResultsPresentation, 17 IGradSessionResultsPresentation) 15 18 16 19 from waeup.aaue.testing import FunctionalLayer … … 40 43 return 41 44 42 43 45 def test_create_pdf(self): 44 46 self.certificate.degree = 'BA(FS)' … … 55 57 56 58 59 class GradSessionResultsPresentationTests(CatalogTestSetup): 60 61 layer = FunctionalLayer 62 63 def test_iface(self): 64 # ensure we fullfill interface contracts 65 obj = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100) 66 verifyClass(IGradSessionResultsPresentation, GradSessionResultsPresentation) 67 verifyObject(IGradSessionResultsPresentation, obj) 68 return 69 70 def test_get_students(self): 71 sr = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100) 72 result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100) 73 self.assertEqual(result, [[], [], [], [], [], [], []]) 74 # if end level is 100, the student seems graduating and 75 # we can get a table with one student 76 self.certificate.end_level = 100 77 self.student['studycourse']['100']['Course1'].credits = 91 78 result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100) 79 self.assertEqual(result, [[], [], [], [], [], [], []]) 80 self.student['studycourse']['100']['Course1'].score = 60 81 self.student['studycourse']['100']['Course1'].ca = 10 82 result = sr._get_students('fac1', 'dep1', 'CERT1', 2010, 100) 83 self.assertEqual(result, 84 [[], [], [], [], [], [(u'E1000000', u'1234', u'TESTER, Bob')], []]) 85 return 86 87 def test_create_pdf(self): 88 self.certificate.degree = 'BA(FS)' 89 self.certificate.end_level = 100 90 self.student['studycourse']['100']['Course1'].credits = 91 91 self.student['studycourse']['100']['Course1'].ca = 0 92 self.app['faculties']['fac1'].officer_1 = 'Rosa Moonshine - Dean of Faculty' 93 self.app['faculties']['fac1']['dep1'].officer_1 = 'Amalia Sunshine - Head of Department' 94 self.app['faculties']['fac1']['dep1'].officer_2 = 'Theresa Starbright - External Examiner' 95 report = GradSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100) 96 result = report.create_pdf('JOB_ID') 97 self.assertTrue(result.startswith('%PDF-')) 98 path = os.path.join(samples_dir(), 'grad_session_results_presentation.pdf') 99 open(path, 'wb').write(result) 100 print "Sample grad_session_results_presentation.pdf written to %s" % path 101 return 102
Note: See TracChangeset for help on using the changeset viewer.