Changeset 15423 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 24 May 2019, 09:59:55 (6 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r15422 r15423 628 628 grok.order(5) 629 629 630 class DownloadAttendanceSheetActionButton(ManageActionButton): 631 """ 'Download ticket overview' button for courses. 632 """ 633 grok.context(ICourse) 634 grok.view(CoursePage) 635 grok.name('attendance') 636 grok.require('waeup.showStudents') 637 icon = 'actionicon_pdf.png' 638 text = _('Download attendance sheet') 639 target = 'attendance.pdf' 640 grok.order(6) 641 630 642 class DownloadCSVFileActionButton(ManageActionButton): 631 643 """ 'Download csv file' button for courses. … … 638 650 text = _('Download csv file (editable scores only)') 639 651 target = 'download_scores' 640 grok.order( 7)652 grok.order(1) 641 653 642 654 class ManageCertificateActionButton(ManageActionButton): -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r15422 r15423 3640 3640 students_utils = getUtility(IStudentsUtils) 3641 3641 return students_utils.renderPDFCourseticketsOverview( 3642 self, session, self.data(session), lecturers, 'landscape', 90, 3643 self.note) 3642 self, 'coursetickets', session, self.data(session), lecturers, 3643 'landscape', 90, self.note) 3644 3645 class ExportAttendanceSlip(UtilityView, grok.View, 3646 LocalRoleAssignmentUtilityView): 3647 """Deliver a PDF slip of course tickets in attendance sheet format. 3648 """ 3649 grok.context(ICourse) 3650 grok.name('attendance.pdf') 3651 grok.require('waeup.showStudents') 3652 3653 @property 3654 def note(self): 3655 return 3656 3657 def data(self, session): 3658 cat = queryUtility(ICatalog, name='coursetickets_catalog') 3659 # Attention: Also tickets of previous studycourses are found 3660 coursetickets = cat.searchResults( 3661 session=(session, session), 3662 code=(self.context.code, self.context.code) 3663 ) 3664 header = [[_('Student Id'), 3665 _('Matric No.'), 3666 _('Level'), 3667 _('Course of Studies'), 3668 _('Booklet No.'), 3669 _('Signature'), 3670 ],] 3671 tickets = [] 3672 for ticket in list(coursetickets): 3673 row = [ticket.student.student_id, 3674 ticket.student.matric_number, 3675 ticket.level, 3676 ticket.student.certcode, 3677 None, 3678 50 * ' ', 3679 ] 3680 tickets.append(row) 3681 return header + sorted(tickets, key=lambda value: value[0]), None 3682 3683 def render(self): 3684 session = grok.getSite()['configuration'].current_academic_session 3685 lecturers = [i['user_title'] for i in self.getUsersWithLocalRoles() 3686 if i['local_role'] == 'waeup.local.Lecturer'] 3687 lecturers = ', '.join(lecturers) 3688 students_utils = getUtility(IStudentsUtils) 3689 return students_utils.renderPDFCourseticketsOverview( 3690 self, 'attendance', session, self.data(session), 3691 lecturers, 'landscape', 90, self.note) 3644 3692 3645 3693 class ExportJobContainerOverview(KofaPage): -
main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
r15333 r15423 157 157 158 158 def renderPDFCourseticketsOverview( 159 view, session, data, lecturers, orientation,159 view, name, session, data, lecturers, orientation, 160 160 title_length, note): 161 161 """Render pdf slip of course tickets for a lecturer. -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r15422 r15423 4517 4517 print "Sample PDF coursetickets.pdf written to %s" % path 4518 4518 4519 def test_lecturers_can_download_attendance_sheet(self): 4520 # A course ticket slip can be downloaded 4521 self.course.title = (u'Lorem ipsum dolor sit amet, consectetur adipisici, ' 4522 u'sed eiusmod tempor incidunt ut labore et dolore') 4523 self.login_as_lecturer() 4524 pdf_url = '%s/attendance.pdf' % self.course_url 4525 self.browser.open(pdf_url) 4526 self.assertEqual(self.browser.headers['Status'], '200 Ok') 4527 self.assertEqual( 4528 self.browser.headers['Content-Type'], 'application/pdf') 4529 path = os.path.join(samples_dir(), 'attendance.pdf') 4530 open(path, 'wb').write(self.browser.contents) 4531 print "Sample PDF attendance.pdf written to %s" % path 4532 4533 4519 4534 def test_lecturers_can_download_scores_as_csv(self): 4520 4535 # Lecturers can download course scores as CSV. -
main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
r15337 r15423 1008 1008 1009 1009 def renderPDFCourseticketsOverview( 1010 self, view, session, data, lecturers, orientation,1010 self, view, name, session, data, lecturers, orientation, 1011 1011 title_length, note): 1012 1012 """Render pdf slip of course tickets for a lecturer. 1013 1013 """ 1014 filename = ' coursetickets_%s_%s_%s.pdf' % (1015 view.context.code, session, view.request.principal.id)1014 filename = '%s_%s_%s_%s.pdf' % ( 1015 name, view.context.code, session, view.request.principal.id) 1016 1016 session = academic_sessions_vocab.getTerm(session).title 1017 1017 creator = getUtility(IPDFCreator, name=orientation) … … 1055 1055 'b':view.context.code, 1056 1056 'd':session})) 1057 if name == 'attendance': 1058 doc_title += _('\nAttendance Sheet') 1059 if name == 'coursetickets': 1060 doc_title += _('\nCourse Tickets Overview') 1057 1061 footer_title = translate(_('${a} (${b}) - ${d}', 1058 1062 mapping = {'a':ft,
Note: See TracChangeset for help on using the changeset viewer.