Changeset 10686


Ignore:
Timestamp:
3 Nov 2013, 07:13:05 (11 years ago)
Author:
Henrik Bettermann
Message:

Make renderPDFAdmissionLetter more flexible.

File:
1 edited

Legend:

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

    r10681 r10686  
    527527        return text
    528528
    529     def renderPDFAdmissionLetter(self, view, student=None, omit_fields=()):
     529    def renderPDFAdmissionLetter(self, view, student=None, omit_fields=(),
     530                                 pre_text=None, post_text=None,):
    530531        """Render pdf admission letter.
    531532        """
     
    549550            footer_text = "%s - %s - " % (student.student_id, footer_text)
    550551
    551         # Admission text
    552         html = format_html(self._admissionText(student, portal_language))
     552        # Insert text before student data
     553        if pre_text is None:
     554            html = format_html(self._admissionText(student, portal_language))
     555        else:
     556            html = format_html(pre_text)
    553557        data.append(Paragraph(html, NOTE_STYLE))
    554558        data.append(Spacer(1, 20))
     
    557561        data.append(render_student_data(view, omit_fields, lang=portal_language))
    558562
    559         # Insert history
     563        # Insert text after student data
    560564        data.append(Spacer(1, 20))
    561         datelist = student.history.messages[0].split()[0].split('-')
    562         creation_date = u'%s/%s/%s' % (datelist[2], datelist[1], datelist[0])
    563         text = trans(_(
    564             'Your Kofa student record was created on ${a}.',
    565             mapping = {'a': creation_date}),
    566             portal_language)
     565        if post_text is None:
     566            datelist = student.history.messages[0].split()[0].split('-')
     567            creation_date = u'%s/%s/%s' % (datelist[2], datelist[1], datelist[0])
     568            text = trans(_(
     569                'Your Kofa student record was created on ${a}.',
     570                mapping = {'a': creation_date}),
     571                portal_language)
     572        else:
     573            text = post_text
    567574        html = format_html(text)
    568575        data.append(Paragraph(html, NOTE_STYLE))
Note: See TracChangeset for help on using the changeset viewer.