Changeset 15197


Ignore:
Timestamp:
25 Oct 2018, 08:16:18 (6 years ago)
Author:
Henrik Bettermann
Message:

Process title if too long.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r15174 r15197  
    34523452        students_utils = getUtility(IStudentsUtils)
    34533453        return students_utils.renderPDFCourseticketsOverview(
    3454             self, session, self.data(session), lecturers, 'landscape')
     3454            self, session, self.data(session), lecturers, 'landscape', 90)
    34553455
    34563456class ExportJobContainerOverview(KofaPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r15173 r15197  
    157157
    158158    def renderPDFCourseticketsOverview(
    159                   view, session, data, lecturers, orientation):
     159                  view, session, data, lecturers, orientation, title_length):
    160160        """Render pdf slip of course tickets for a lecturer.
    161161        """
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r15174 r15197  
    43944394    def test_lecturers_can_download_course_tickets(self):
    43954395        # A course ticket slip can be downloaded
     4396        self.course.title = (u'Lorem ipsum dolor sit amet, consectetur '
     4397                            u'adipisici elit, sed eiusmod tempor incidunt')
    43964398        self.login_as_lecturer()
    43974399        pdf_url = '%s/coursetickets.pdf' % self.course_url
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r15163 r15197  
    993993
    994994    def renderPDFCourseticketsOverview(
    995             self, view, session, data, lecturers, orientation):
     995            self, view, session, data, lecturers, orientation, title_length):
    996996        """Render pdf slip of course tickets for a lecturer.
    997997        """
     
    10011001        creator = getUtility(IPDFCreator, name=orientation)
    10021002        style = getSampleStyleSheet()
    1003         pdf_data = [Paragraph(
     1003        pdf_data = []
     1004        ct = ft = view.context.title
     1005        # Process title if too long
     1006        if len(view.context.title) + len(view.context.code) > title_length:
     1007            i = 0
     1008            titlelist = view.context.title.split()
     1009            while len(' '.join(titlelist[:i+1])) < title_length:
     1010                i += 1
     1011            ct = ' '.join(titlelist[:i]) + '\n' + ' '.join(titlelist[i:])
     1012            ft = view.context.title[
     1013                :(title_length-len(view.context.code))] + u' ...'
     1014            pdf_data.append(Spacer(1, 20))
     1015        pdf_data += [Paragraph(
    10041016            translate(_('<b>Lecturer(s): ${a}</b>',
    10051017                      mapping = {'a':lecturers})), style["Normal"]),]
     
    10271039        pdf_data.append(Spacer(1, 20))
    10281040        pdf_data += [Table(data[0], style=CONTENT_STYLE)]
    1029         doc_title = translate(_('${a} (${b}) - Academic Session ${d}',
    1030             mapping = {'a':view.context.title,
     1041        doc_title = translate(_('${a} (${b})\nAcademic Session ${d}',
     1042            mapping = {'a':ct,
    10311043                       'b':view.context.code,
    10321044                       'd':session}))
    10331045        footer_title = translate(_('${a} (${b}) - ${d}',
    1034             mapping = {'a':view.context.title,
     1046            mapping = {'a':ft,
    10351047                       'b':view.context.code,
    10361048                       'd':session}))
Note: See TracChangeset for help on using the changeset viewer.