diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index b19a5fc9d..d8c423208 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -804,64 +804,61 @@ def formsemestre_bulletinetud( except: return scu.log_unknown_etud(context, REQUEST, format=format) + bulletin = do_formsemestre_bulletinetud( + context, + formsemestre_id, + etudid, + format=format, + version=version, + xml_with_decisions=xml_with_decisions, + force_publishing=force_publishing, + prefer_mail_perso=prefer_mail_perso, + REQUEST=REQUEST, + )[0] + if format not in {"html", "pdfmail"}: + return bulletin + sem = sco_formsemestre.get_formsemestre(context, formsemestre_id) + H = [ + _formsemestre_bulletinetud_header_html( + context, etud, etudid, sem, formsemestre_id, format, version, REQUEST + ), + bulletin, + ] - R = [] - if format == "html" or format == "pdfmail": - R.append( - _formsemestre_bulletinetud_header_html( - context, etud, etudid, sem, formsemestre_id, format, version, REQUEST - ) + H.append("""
Situation actuelle: """) + if etud["inscription_formsemestre_id"]: + H.append( + """""" + % etud["inscription_formsemestre_id"] ) - - R.append( - do_formsemestre_bulletinetud( - context, - formsemestre_id, - etudid, - format=format, - version=version, - xml_with_decisions=xml_with_decisions, - force_publishing=force_publishing, - prefer_mail_perso=prefer_mail_perso, - REQUEST=REQUEST, - )[0] + H.append(etud["inscriptionstr"]) + if etud["inscription_formsemestre_id"]: + H.append("""""") + H.append("""
""") + if sem["modalite"] == "EXT": + H.append( + """+ Editer les validations d'UE dans ce semestre extérieur +
""" + % (formsemestre_id, etudid) + ) + # Place du diagramme radar + H.append( + """""" + % (etudid, formsemestre_id) ) + H.append('') - if format == "html" or format == "pdfmail": - R.append("""Situation actuelle: """) - if etud["inscription_formsemestre_id"]: - R.append( - """""" - % etud["inscription_formsemestre_id"] - ) - R.append(etud["inscriptionstr"]) - if etud["inscription_formsemestre_id"]: - R.append("""""") - R.append("""
""") - if sem["modalite"] == "EXT": - R.append( - """""" - % (formsemestre_id, etudid) - ) - # Place du diagramme radar - R.append( - """""" - % (etudid, formsemestre_id) - ) - R.append('') + # --- Pied de page + H.append(html_sco_header.sco_footer(context, REQUEST)) - # --- Pied de page - R.append(html_sco_header.sco_footer(context, REQUEST)) - - return "".join(R) + return "".join(H) def can_send_bulletin_by_mail(context, formsemestre_id, REQUEST): diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index 70557dfcd..3dafa3e4b 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -42,14 +42,12 @@ La préférence 'bul_pdf_class_name' est obsolete (inutilisée). """ -import time import collections +import io +import time import traceback -try: - from io import StringIO # for Python 3 -except ImportError: - from cStringIO import StringIO # for Python 2 + import reportlab from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Frame, PageBreak from reportlab.platypus import Table, TableStyle, Image, KeepInFrame @@ -219,7 +217,7 @@ class BulletinGenerator(object): else: # Generation du document PDF sem = sco_formsemestre.get_formsemestre(self.context, formsemestre_id) - report = StringIO.StringIO() # in-memory document, no disk file + report = io.BytesIO() # in-memory document, no disk file document = sco_pdf.BaseDocTemplate(report) document.addPageTemplates( sco_pdf.ScolarsPageTemplate( diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py index 2efe95797..36b1ad188 100755 --- a/app/scodoc/sco_pdf.py +++ b/app/scodoc/sco_pdf.py @@ -77,16 +77,14 @@ DEFAULT_PDF_FOOTER_TEMPLATE = CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE def SU(s): - "convert s from SCO default encoding to UTF8" - # Mis en service le 4/11/06, passage à ReportLab 2.0 - if not s: - s = "" + "convert s from string to string suitable for ReportLab" + # A priori inutile en Python 3, mais tester les "combining accents" + return s or "" # Remplace caractères composés # eg 'e\xcc\x81' COMBINING ACUTE ACCENT par '\xc3\xa9' LATIN SMALL LETTER E WITH ACUTE # car les "combining accents" ne sont pas traités par ReportLab mais peuvent # nous être envoyés par certains navigateurs ou imports - u = unicodedata.normalize("NFC", six.text_type(s, SCO_ENCODING, "replace")) - return u.encode("utf8") + # return unicodedata.normalize("NFC", s) def _splitPara(txt):