Changeset 12182
- Timestamp:
- 9 Dec 2014, 11:04:53 (10 years ago)
- Location:
- main/waeup.ikoba/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/setup.py
r12060 r12182 42 42 'z3c.evalexception', 43 43 'paypalrestsdk', 44 'PyPDF2', 44 45 ], 45 46 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12169 r12182 1029 1029 omit_fields=self.omit_fields) 1030 1030 1031 1032 class PDFMergeDocumentSlipPage(PDFDocumentSlipPage): 1033 """Deliver pdf file including metadata. 1034 """ 1035 grok.context(ICustomerPDFDocument) 1036 1037 def render(self): 1038 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE 1039 customerview = CustomerBasePDFFormPage(self.context.customer, 1040 self.request, self.omit_fields) 1041 customers_utils = getUtility(ICustomersUtils) 1042 return customers_utils.renderPDF( 1043 self, 'pdfdocument_slip.pdf', 1044 self.context.customer, customerview, 1045 omit_fields=self.omit_fields, 1046 mergefiles=self.context.connected_files) 1047 1031 1048 # Pages for customer contracts 1032 1049 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12169 r12182 1091 1091 open(path, 'wb').write(self.browser.contents) 1092 1092 print "Sample document_slip.pdf written to %s" % path 1093 # Officers can open merged pdf document slips 1094 pdfdocument = createObject('waeup.CustomerPDFDocument') 1095 pdfdocument.title = u'My first document' 1096 self.customer['documents'].addDocument(pdfdocument) 1097 # Add pdf file 1098 file_id = IFileStoreNameChooser(pdfdocument).chooseName(attr='sample.pdf') 1099 fs = ExtFileStore(root=self.dc_root) 1100 pdffile = open(SAMPLE_PDF, 'rb') 1101 fs.createFile(file_id, pdffile) 1102 self.browser.open(self.customer_path + '/documents/d102') 1103 self.browser.getLink("Download document slip").click() 1104 self.assertEqual(self.browser.headers['Status'], '200 Ok') 1105 self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf') 1106 path = os.path.join(samples_dir(), 'pdfdocument_slip.pdf') 1107 open(path, 'wb').write(self.browser.contents) 1108 print "Sample pdfdocument_slip.pdf written to %s" % path 1093 1109 1094 1110 -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12099 r12182 21 21 import os 22 22 import grok 23 from StringIO import StringIO 23 24 from reportlab.lib import colors 24 25 from reportlab.lib.units import cm … … 26 27 from reportlab.lib.styles import getSampleStyleSheet 27 28 from reportlab.platypus import Paragraph, Image, Table, Spacer 29 from reportlab.platypus.flowables import PageBreak 30 from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter 28 31 from zope.event import notify 29 32 from zope.schema.interfaces import ConstraintNotSatisfied … … 334 337 note=None, signatures=None, sigs_in_footer=(), 335 338 show_scans=True, show_history=True, topMargin=1.5, 336 omit_fields=() ):339 omit_fields=(), mergefiles=None): 337 340 """Render pdf slips for various pages. 338 341 """ … … 419 422 view.flash('Error in image file.') 420 423 return view.redirect(view.url(view.context)) 424 425 if mergefiles: 426 merger = PdfFileMerger() 427 merger.append(StringIO(pdf_stream)) 428 for file in mergefiles: 429 merger.append(file[1]) 430 tmp = StringIO() 431 merger.write(tmp) 432 return tmp.getvalue() 433 421 434 return pdf_stream -
main/waeup.ikoba/trunk/versions.cfg
r12170 r12182 177 177 # paypalrestsdk==1.6.1 178 178 requests = 2.4.3 179 180 # Added by buildout at 2014-12-09 08:56:22.978680 181 182 # Required by: 183 # waeup.ikoba==0.2dev 184 PyPDF2 = 1.23
Note: See TracChangeset for help on using the changeset viewer.