- Timestamp:
- 9 Jun 2016, 12:36:41 (8 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r13894 r13898 4 4 1.4.2.dev0 (unreleased) 5 5 ======================= 6 7 * Add `ExportPDFScoresSlip`. 6 8 7 9 * Add `DownloadScoresView` which is for lecturers only. Remove -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r13894 r13898 551 551 grok.order(1) 552 552 553 class DownloadTicketOverviewActionButton(ManageActionButton): 554 """ 'Download ticket overview' button for courses. 555 """ 556 grok.context(ICourse) 557 grok.view(EditScoresPage) 558 grok.name('coursetickets') 559 grok.require('waeup.editScores') 560 icon = 'actionicon_pdf.png' 561 text = _('Download pdf file') 562 target = 'coursetickets.pdf' 563 grok.order(2) 564 553 565 class ManageCertificateActionButton(ManageActionButton): 554 566 """ 'Manage settings' button for certificates. -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r13894 r13898 39 39 from waeup.kofa.browser.breadcrumbs import Breadcrumb 40 40 from waeup.kofa.browser.pages import ( 41 ContactAdminFormPage, ExportCSVView, doll_up, exports_not_allowed) 41 ContactAdminFormPage, ExportCSVView, doll_up, exports_not_allowed, 42 LocalRoleAssignmentUtilityView) 42 43 from waeup.kofa.browser.interfaces import ICaptchaManager 43 44 from waeup.kofa.hostels.hostel import NOT_OCCUPIED … … 3163 3164 grok.require('waeup.editScores') 3164 3165 grok.name('download_scores') 3165 redirect_target = '@@export'3166 3166 3167 3167 def update(self): … … 3194 3194 'Content-Disposition:', 'attachment; filename="%s' % filename) 3195 3195 return self.csv 3196 3197 class ExportPDFScoresSlip(UtilityView, grok.View, 3198 LocalRoleAssignmentUtilityView): 3199 """Deliver a PDF slip of course tickets for a lecturer. 3200 """ 3201 grok.context(ICourse) 3202 grok.name('coursetickets.pdf') 3203 grok.require('waeup.editScores') 3204 3205 def table_data(self, session): 3206 cat = queryUtility(ICatalog, name='coursetickets_catalog') 3207 coursetickets = cat.searchResults( 3208 session=(session, session), 3209 code=(self.context.code, self.context.code) 3210 ) 3211 result = [[_('Matric No.'), 3212 _('Reg. No.'), 3213 _('Fullname'), 3214 _('Status'), 3215 _('Course of Studies'), 3216 _('Level'), 3217 _('Score') ],] 3218 for ticket in list(coursetickets): 3219 row = [ticket.student.matric_number, 3220 ticket.student.reg_number, 3221 ticket.student.display_fullname, 3222 ticket.student.translated_state, 3223 ticket.student.certcode, 3224 ticket.level, 3225 ticket.score] 3226 result.append(row) 3227 return result 3228 3229 def render(self): 3230 session = grok.getSite()['configuration'].current_academic_session 3231 lecturers = [i['user_title'] for i in self.getUsersWithLocalRoles() 3232 if i['local_role'] == 'waeup.local.Lecturer'] 3233 lecturers = ', '.join(lecturers) 3234 students_utils = getUtility(IStudentsUtils) 3235 return students_utils.renderPDFCourseticketsOverview( 3236 self, session, self.table_data(session), lecturers) 3196 3237 3197 3238 class ExportJobContainerOverview(KofaPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r13894 r13898 1889 1889 self.assertTrue('mrslecturer - students.browser.EditScoresPage - ' 1890 1890 'K1000000 100/COURSE1 score updated (None)' in logcontent) 1891 # A course ticket slip can be downloaded 1892 self.browser.open( 1893 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/coursetickets.pdf") 1894 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1895 self.assertEqual(self.browser.headers['Content-Type'], 1896 'application/pdf') 1897 path = os.path.join(samples_dir(), 'coursetickets.pdf') 1898 open(path, 'wb').write(self.browser.contents) 1899 print "Sample PDF coursetickets.pdf written to %s" % path 1900 1891 1901 1892 1902 def test_change_current_mode(self): -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r13797 r13898 55 55 ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black), 56 56 ('BOX', (0,0), (-1,-1), 1, colors.black), 57 58 57 ] 59 58 … … 936 935 return pdf_stream 937 936 937 def renderPDFCourseticketsOverview( 938 self, view, session, table_data, lecturers): 939 filename = 'coursetickets_%s_%s_%s.pdf' % ( 940 view.context.code, session, view.request.principal.id) 941 session = academic_sessions_vocab.getTerm(session).title 942 creator = getUtility(IPDFCreator) 943 style = getSampleStyleSheet() 944 pdf_data = [Table(table_data, style=CONTENT_STYLE)] 945 doc_title = translate( 946 _('${a} - Session ${b}\n' 947 'Lecturer(s): ${c}', 948 mapping = {'a':view.context.code, 'b':session, 'c':lecturers})) 949 author = '%s (%s)' % (view.request.principal.title, 950 view.request.principal.id) 951 view.response.setHeader( 952 'Content-Type', 'application/pdf') 953 view.response.setHeader( 954 'Content-Disposition:', 'attachment; filename="%s' % filename) 955 pdf_stream = creator.create_pdf( 956 pdf_data, None, doc_title, author, doc_title + ' -' 957 ) 958 return pdf_stream 959 938 960 def maxCredits(self, studylevel): 939 961 """Return maximum credits.
Note: See TracChangeset for help on using the changeset viewer.