Bul. PDF: pied de page
This commit is contained in:
parent
e0a3c31f9c
commit
8ef265baab
@ -163,7 +163,9 @@ class BulletinGenerator:
|
|||||||
|
|
||||||
formsemestre_id = self.infos["formsemestre_id"]
|
formsemestre_id = self.infos["formsemestre_id"]
|
||||||
marque_debut_bulletin = sco_pdf.DebutBulletin(
|
marque_debut_bulletin = sco_pdf.DebutBulletin(
|
||||||
self.infos["etud"]["nomprenom"], filigranne=self.infos["filigranne"]
|
self.infos["etud"]["nomprenom"],
|
||||||
|
filigranne=self.infos["filigranne"],
|
||||||
|
footer_content=f"""ScoDoc - Bulletin de {self.infos["etud"]["nomprenom"]} - {time.strftime("%d/%m/%Y %H:%M")}""",
|
||||||
)
|
)
|
||||||
story = []
|
story = []
|
||||||
# partie haute du bulletin
|
# partie haute du bulletin
|
||||||
|
@ -46,7 +46,9 @@ CONFIG.LOGO_HEADER_HEIGHT = 28
|
|||||||
#
|
#
|
||||||
# server_url: URL du serveur ScoDoc
|
# server_url: URL du serveur ScoDoc
|
||||||
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir sco_version.py)
|
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir sco_version.py)
|
||||||
CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s"
|
CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = (
|
||||||
|
"Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# ------------- Capitalisation des UEs -------------
|
# ------------- Capitalisation des UEs -------------
|
||||||
|
@ -190,9 +190,10 @@ class DebutBulletin(BulMarker):
|
|||||||
Element vide utilisé pour générer les bookmarks
|
Element vide utilisé pour générer les bookmarks
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, bookmark=None, filigranne=None):
|
def __init__(self, bookmark=None, filigranne=None, footer_content=None):
|
||||||
self.bookmark = bookmark
|
self.bookmark = bookmark
|
||||||
self.filigranne = filigranne
|
self.filigranne = filigranne
|
||||||
|
self.footer_content = footer_content
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
|
||||||
@ -298,24 +299,34 @@ class ScoDocPageTemplate(PageTemplate):
|
|||||||
if bookmark:
|
if bookmark:
|
||||||
canvas.bookmarkPage(bookmark)
|
canvas.bookmarkPage(bookmark)
|
||||||
canvas.addOutlineEntry(SU(bookmark), bookmark)
|
canvas.addOutlineEntry(SU(bookmark), bookmark)
|
||||||
# ---- Footer
|
|
||||||
|
def draw_footer(self, canvas, content):
|
||||||
|
"""Print the footer"""
|
||||||
canvas.setFont(
|
canvas.setFont(
|
||||||
self.preferences["SCOLAR_FONT"], self.preferences["SCOLAR_FONT_SIZE_FOOT"]
|
self.preferences["SCOLAR_FONT"], self.preferences["SCOLAR_FONT_SIZE_FOOT"]
|
||||||
)
|
)
|
||||||
d = _makeTimeDict()
|
|
||||||
d["scodoc_name"] = sco_version.SCONAME
|
|
||||||
d["server_url"] = self.server_name
|
|
||||||
footer_str = SU(self.footer_template % d)
|
|
||||||
canvas.drawString(
|
canvas.drawString(
|
||||||
self.preferences["pdf_footer_x"] * mm,
|
self.preferences["pdf_footer_x"] * mm,
|
||||||
self.preferences["pdf_footer_y"] * mm,
|
self.preferences["pdf_footer_y"] * mm,
|
||||||
footer_str,
|
content,
|
||||||
)
|
)
|
||||||
canvas.restoreState()
|
canvas.restoreState()
|
||||||
|
|
||||||
|
def footer_string(self) -> str:
|
||||||
|
"""String contenu du pied de page"""
|
||||||
|
d = _makeTimeDict()
|
||||||
|
d["scodoc_name"] = sco_version.SCONAME
|
||||||
|
d["server_url"] = self.server_name
|
||||||
|
return SU(self.footer_template % d)
|
||||||
|
|
||||||
def afterDrawPage(self, canvas, doc):
|
def afterDrawPage(self, canvas, doc):
|
||||||
if not self.preferences:
|
if not self.preferences:
|
||||||
return
|
return
|
||||||
|
# ---- Footer
|
||||||
|
foot_content = None
|
||||||
|
if hasattr(doc, "current_footer"):
|
||||||
|
foot_content = doc.current_footer
|
||||||
|
self.draw_footer(canvas, foot_content or self.footer_string())
|
||||||
# ---- Filigranne (texte en diagonal en haut a gauche de chaque page)
|
# ---- Filigranne (texte en diagonal en haut a gauche de chaque page)
|
||||||
filigranne = None
|
filigranne = None
|
||||||
if hasattr(doc, "filigranne"):
|
if hasattr(doc, "filigranne"):
|
||||||
@ -352,7 +363,9 @@ class BulletinDocTemplate(BaseDocTemplate):
|
|||||||
def afterFlowable(self, flowable):
|
def afterFlowable(self, flowable):
|
||||||
"""Called by Reportlab after each flowable"""
|
"""Called by Reportlab after each flowable"""
|
||||||
if isinstance(flowable, DebutBulletin):
|
if isinstance(flowable, DebutBulletin):
|
||||||
|
self.current_footer = ""
|
||||||
if flowable.bookmark:
|
if flowable.bookmark:
|
||||||
|
self.current_footer = flowable.footer_content
|
||||||
self.canv.bookmarkPage(flowable.bookmark)
|
self.canv.bookmarkPage(flowable.bookmark)
|
||||||
self.canv.addOutlineEntry(
|
self.canv.addOutlineEntry(
|
||||||
SU(flowable.bookmark), flowable.bookmark, level=0, closed=None
|
SU(flowable.bookmark), flowable.bookmark, level=0, closed=None
|
||||||
|
@ -248,7 +248,7 @@ def about(scodoc_dept=None):
|
|||||||
# INSTITUTION_ADDRESS = "Web <b>www.sor.bonne.top</b> - 11, rue Simon Crubelier - 75017 Paris"
|
# INSTITUTION_ADDRESS = "Web <b>www.sor.bonne.top</b> - 11, rue Simon Crubelier - 75017 Paris"
|
||||||
# INSTITUTION_CITY = "Paris"
|
# INSTITUTION_CITY = "Paris"
|
||||||
# Textareas:
|
# Textareas:
|
||||||
# DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s"
|
# DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s"
|
||||||
|
|
||||||
# Booléens
|
# Booléens
|
||||||
# always_require_ine
|
# always_require_ine
|
||||||
|
@ -63,7 +63,9 @@ CONFIG.LOGO_HEADER_HEIGHT = 28 # taille verticale dans le document en millimetr
|
|||||||
# server_url: URL du serveur ScoDoc
|
# server_url: URL du serveur ScoDoc
|
||||||
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir sco_version.py)
|
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir sco_version.py)
|
||||||
|
|
||||||
CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s"
|
CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = (
|
||||||
|
"Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -55,7 +55,7 @@ CONFIG = CFG()
|
|||||||
# server_url: URL du serveur ScoDoc
|
# server_url: URL du serveur ScoDoc
|
||||||
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir sco_version.py)
|
# scodoc_name: le nom du logiciel (ScoDoc actuellement, voir sco_version.py)
|
||||||
|
|
||||||
# CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s sur %(server_url)s"
|
# CONFIG.DEFAULT_PDF_FOOTER_TEMPLATE = "Edité par %(scodoc_name)s le %(day)s/%(month)s/%(year)s à %(hour)sh%(minute)s"
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user