forked from ScoDoc/ScoDoc
fix pdf code for py3
This commit is contained in:
parent
86f728b781
commit
b0717e35e0
@ -27,13 +27,10 @@
|
|||||||
|
|
||||||
"""Edition des PV de jury
|
"""Edition des PV de jury
|
||||||
"""
|
"""
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
try:
|
|
||||||
from io import StringIO # for Python 3
|
|
||||||
except ImportError:
|
|
||||||
from cStringIO import StringIO # for Python 2
|
|
||||||
import reportlab
|
import reportlab
|
||||||
from reportlab.lib.units import cm, mm
|
from reportlab.lib.units import cm, mm
|
||||||
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
|
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
|
||||||
@ -390,7 +387,7 @@ def pdf_lettres_individuelles(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# ----- Build PDF
|
# ----- Build PDF
|
||||||
report = StringIO.StringIO() # in-memory document, no disk file
|
report = io.BytesIO() # in-memory document, no disk file
|
||||||
document = BaseDocTemplate(report)
|
document = BaseDocTemplate(report)
|
||||||
document.addPageTemplates(
|
document.addPageTemplates(
|
||||||
CourrierIndividuelTemplate(
|
CourrierIndividuelTemplate(
|
||||||
@ -590,7 +587,7 @@ def _make_signature_image(signature, leftindent, formsemestre_id, context=None):
|
|||||||
# cree une image PIL pour avoir la taille (W,H)
|
# cree une image PIL pour avoir la taille (W,H)
|
||||||
from PIL import Image as PILImage
|
from PIL import Image as PILImage
|
||||||
|
|
||||||
f = StringIO.StringIO(signature)
|
f = io.BytesIO(signature)
|
||||||
im = PILImage.open(f)
|
im = PILImage.open(f)
|
||||||
width, height = im.size
|
width, height = im.size
|
||||||
pdfheight = (
|
pdfheight = (
|
||||||
@ -674,7 +671,7 @@ def pvjury_pdf(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# ----- Build PDF
|
# ----- Build PDF
|
||||||
report = StringIO.StringIO() # in-memory document, no disk file
|
report = io.BytesIO() # in-memory document, no disk file
|
||||||
document = BaseDocTemplate(report)
|
document = BaseDocTemplate(report)
|
||||||
document.pagesize = landscape(A4)
|
document.pagesize = landscape(A4)
|
||||||
document.addPageTemplates(
|
document.addPageTemplates(
|
||||||
@ -838,7 +835,7 @@ def _pvjury_pdf_type(
|
|||||||
|
|
||||||
def _format_pv_cell(x):
|
def _format_pv_cell(x):
|
||||||
"""convert string to paragraph"""
|
"""convert string to paragraph"""
|
||||||
if isinstance(x, bytes):
|
if isinstance(x, str):
|
||||||
return Paragraph(SU(x), cell_style)
|
return Paragraph(SU(x), cell_style)
|
||||||
else:
|
else:
|
||||||
return x
|
return x
|
||||||
|
@ -2218,6 +2218,7 @@ sco_publish(
|
|||||||
"/formsemestre_lettres_individuelles",
|
"/formsemestre_lettres_individuelles",
|
||||||
sco_pvjury.formsemestre_lettres_individuelles,
|
sco_pvjury.formsemestre_lettres_individuelles,
|
||||||
Permission.ScoView,
|
Permission.ScoView,
|
||||||
|
methods=["GET", "POST"],
|
||||||
)
|
)
|
||||||
sco_publish(
|
sco_publish(
|
||||||
"/formsemestre_pvjury_pdf", sco_pvjury.formsemestre_pvjury_pdf, Permission.ScoView
|
"/formsemestre_pvjury_pdf", sco_pvjury.formsemestre_pvjury_pdf, Permission.ScoView
|
||||||
|
Loading…
Reference in New Issue
Block a user