Ignore:
Timestamp:
11 Dec 2019, 12:02:09 (5 years ago)
Author:
Henrik Bettermann
Message:

Add LetterPDFCreator utility and use this pdf creator
for admission slips. letterhead_admission.jpg file
must exist in students/static.

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

Legend:

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

    r15865 r15880  
    2222import pytz
    2323import sys
     24import os
    2425import textwrap
    2526from cStringIO import StringIO
     
    543544    def render(self):
    544545        students_utils = getUtility(IStudentsUtils)
     546        letterhead_path = os.path.join(
     547            os.path.dirname(__file__), 'static', 'letterhead_admission.jpg')
     548        if not os.path.exists(letterhead_path):
     549            letterhead_path = None
    545550        return students_utils.renderPDFAdmissionLetter(self,
    546             self.context.student, omit_fields=self.omit_fields)
     551            self.context.student, omit_fields=self.omit_fields,
     552            letterhead_path=letterhead_path)
    547553
    548554class StudentBaseManageFormPage(KofaEditFormPage):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/fileviewlets.py

    r15833 r15880  
    2424    IExtFileStore, IFileStoreNameChooser, IKofaObject, IKofaUtils)
    2525from waeup.kofa.utils.helpers import string_from_bytes, file_size
    26 from waeup.kofa.browser import DEFAULT_IMAGE_PATH
    2726
    2827from waeup.kofa.students.interfaces import IStudent, IStudentsUtils
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r15790 r15880  
    145145
    146146    def renderPDFAdmissionLetter(view, student=None, omit_fields=(),
    147                                  pre_text=None, post_text=None,):
     147                                 pre_text=None, post_text=None,
     148                                 letterhead_path=None):
    148149        """Render pdf admission letter.
    149150        """
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r15879 r15880  
    859859
    860860    def renderPDFAdmissionLetter(self, view, student=None, omit_fields=(),
    861                                  pre_text=None, post_text=None,):
     861                                 pre_text=None, post_text=None,
     862                                 letterhead_path=None):
    862863        """Render pdf admission letter.
    863864        """
     
    865866            return
    866867        style = getSampleStyleSheet()
    867         creator = self.getPDFCreator(student)
     868        if letterhead_path:
     869            creator = getUtility(IPDFCreator, name='letter')
     870        else:
     871            creator = getUtility(IPDFCreator)
    868872        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    869873        data = []
     
    912916        pdf_stream = creator.create_pdf(
    913917            data, None, doc_title, author=author, footer=footer_text,
    914             note=post_text)
     918            note=post_text, letterhead_path=letterhead_path)
    915919        return pdf_stream
    916920
Note: See TracChangeset for help on using the changeset viewer.