adaptation du code d'édition des pv

This commit is contained in:
Jean-Marie Place 2021-11-07 09:05:53 +01:00
parent d7e34b8ce2
commit ecd637fb39

View File

@ -52,6 +52,7 @@ from app.scodoc import sco_pdf
from app.scodoc import sco_preferences from app.scodoc import sco_preferences
from app.scodoc import sco_etud from app.scodoc import sco_etud
import sco_version import sco_version
from app.scodoc.sco_logos import find_logo
from app.scodoc.sco_pdf import PDFLOCK from app.scodoc.sco_pdf import PDFLOCK
from app.scodoc.sco_pdf import SU from app.scodoc.sco_pdf import SU
@ -201,33 +202,36 @@ class CourrierIndividuelTemplate(PageTemplate):
self.logo_footer = None self.logo_footer = None
self.logo_header = None self.logo_header = None
# Search logos in dept specific dir, then in global scu.CONFIG dir # Search logos in dept specific dir, then in global scu.CONFIG dir
for image_dir in ( if template_name == "PVJuryTemplate":
scu.SCODOC_LOGOS_DIR + "/logos_" + g.scodoc_dept, background = find_logo(
scu.SCODOC_LOGOS_DIR, # global logos logoname="pvjury_background",
): dept_id=g.scodoc_dept_id,
for suffix in scu.LOGOS_IMAGES_ALLOWED_TYPES: prefix="",
if template_name == "PVJuryTemplate": )
fn = image_dir + "/pvjury_background" + "." + suffix else:
else: background = find_logo(
fn = image_dir + "/letter_background" + "." + suffix logoname="letter_background",
if not self.background_image_filename and os.path.exists(fn): dept_id=g.scodoc_dept_id,
self.background_image_filename = fn prefix="",
)
if not self.background_image_filename and background is not None:
self.background_image_filename = background.filepath
fn = image_dir + "/logo_footer" + "." + suffix footer = find_logo(logoname="footer", dept_id=g.scodoc_dept_id)
if not self.logo_footer and os.path.exists(fn): if footer is not None:
self.logo_footer = Image( self.logo_footer = Image(
fn, footer.filepath,
height=LOGO_FOOTER_HEIGHT, height=LOGO_FOOTER_HEIGHT,
width=LOGO_FOOTER_WIDTH, width=LOGO_FOOTER_WIDTH,
) )
fn = image_dir + "/logo_header" + "." + suffix header = find_logo(logoname="header", dept_id=g.scodoc_dept_id)
if not self.logo_header and os.path.exists(fn): if header is not None:
self.logo_header = Image( self.logo_header = Image(
fn, header.filepath,
height=LOGO_HEADER_HEIGHT, height=LOGO_HEADER_HEIGHT,
width=LOGO_HEADER_WIDTH, width=LOGO_HEADER_WIDTH,
) )
def beforeDrawPage(self, canvas, doc): def beforeDrawPage(self, canvas, doc):
"""Draws a logo and an contribution message on each page.""" """Draws a logo and an contribution message on each page."""