- Timestamp:
- 1 Oct 2020, 06:51:10 (4 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r16251 r16262 4 4 1.6.1.dev0 (unreleased) 5 5 ======================= 6 7 * Use Uli's marker substitution hack to inject signature 8 images into pdf files. 6 9 7 10 * Implement `ExportPDFPersonalDataSlip` (without button -
main/waeup.kofa/trunk/src/waeup/kofa/browser/pdf.py
r16149 r16262 23 23 import os 24 24 import pytz 25 from string import Template 25 26 from cStringIO import StringIO 26 27 from datetime import datetime … … 559 560 logo_left_pos = [0, 0, 0] 560 561 pagesize = portrait(A4) 562 563 test_signature_img_path = os.path.join( 564 os.path.dirname(__file__), 'static', 'test_signature.png') 561 565 562 566 @classmethod … … 823 827 return 824 828 829 def _substitute_markers(self, text): 830 """If `text` contains some marker, substitute it. 831 832 Markers are standard library string template placeholders. See 833 https://docs.python.org/2/library/string.html and 834 `string.Template` for details. Roughly, placeholders look like 835 ``${some_marker}``. 836 837 Valid markers: 838 ``test_signature_img_path`` -- path to signature image stored in 839 `test_signature_img_path`` attribute. 840 """ 841 text = Template(text) 842 PDF_SIGNATURES = { 843 'test_signature_img_path': self.test_signature_img_path, 844 } 845 return text.safe_substitute(PDF_SIGNATURES) 846 825 847 def create_pdf(self, data, headerline=None, title=None, author=None, 826 848 footer='', note=None, sigs_in_footer=[], topMargin=1.5, … … 849 871 doc.letterhead_path = letterhead_path 850 872 if note is not None: 873 # Inject signature images 874 note = self._substitute_markers(note) 875 # Format html 851 876 html = format_html(note) 852 877 data.append(Paragraph(html, NOTE_STYLE)) -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r16251 r16262 539 539 form_fields = grok.AutoFields(IStudentBase).select('student_id', 'reg_number') 540 540 541 542 # Can be used for testing. Just replace 'post_text=None' 543 # by post_text=self.post_text' 544 post_text = ''' 545 Conratulations! 546 547 548 <img src="${test_signature_img_path}" valign="-20" height="38" width="86" /> 549 550 551 John Tester 552 - Registrar - 553 ''' 554 541 555 @property 542 556 def label(self): … … 554 568 return students_utils.renderPDFAdmissionLetter(self, 555 569 self.context.student, omit_fields=self.omit_fields, 556 letterhead_path=letterhead_path )570 letterhead_path=letterhead_path, post_text=None) 557 571 558 572 class StudentBaseManageFormPage(KofaEditFormPage):
Note: See TracChangeset for help on using the changeset viewer.