forked from ScoDoc/ScoDoc
Bul. BUT PDF: débuts sur pages impaires
This commit is contained in:
parent
0c1c6de7bc
commit
e0a3c31f9c
@ -23,7 +23,8 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
list_in_menu = False # spécialisation du BulletinGeneratorStandard, ne pas présenter à l'utilisateur
|
list_in_menu = False # spécialisation du BulletinGeneratorStandard, ne pas présenter à l'utilisateur
|
||||||
scale_table_in_page = False
|
scale_table_in_page = False # pas de mise à l'échelle pleine page auto
|
||||||
|
multi_pages = True # plusieurs pages par bulletins
|
||||||
small_fontsize = "8"
|
small_fontsize = "8"
|
||||||
|
|
||||||
def bul_table(self, format="html"):
|
def bul_table(self, format="html"):
|
||||||
|
@ -49,7 +49,14 @@ import traceback
|
|||||||
|
|
||||||
|
|
||||||
import reportlab
|
import reportlab
|
||||||
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Frame, PageBreak
|
from reportlab.platypus import (
|
||||||
|
SimpleDocTemplate,
|
||||||
|
DocIf,
|
||||||
|
Paragraph,
|
||||||
|
Spacer,
|
||||||
|
Frame,
|
||||||
|
PageBreak,
|
||||||
|
)
|
||||||
from reportlab.platypus import Table, TableStyle, Image, KeepInFrame
|
from reportlab.platypus import Table, TableStyle, Image, KeepInFrame
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
@ -72,6 +79,7 @@ class BulletinGenerator:
|
|||||||
description = "superclass for bulletins" # description for user interface
|
description = "superclass for bulletins" # description for user interface
|
||||||
list_in_menu = True # la classe doit-elle est montrée dans le menu de config ?
|
list_in_menu = True # la classe doit-elle est montrée dans le menu de config ?
|
||||||
scale_table_in_page = True # rescale la table sur 1 page
|
scale_table_in_page = True # rescale la table sur 1 page
|
||||||
|
multi_pages = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -157,28 +165,35 @@ class BulletinGenerator:
|
|||||||
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"]
|
||||||
)
|
)
|
||||||
objects = []
|
story = []
|
||||||
# partie haute du bulletin
|
# partie haute du bulletin
|
||||||
objects += self.bul_title_pdf() # pylint: disable=no-member
|
story += self.bul_title_pdf() # pylint: disable=no-member
|
||||||
index_obj_debut = len(objects)
|
index_obj_debut = len(story)
|
||||||
|
|
||||||
# table des notes
|
# table des notes
|
||||||
objects += self.bul_table(format="pdf") # pylint: disable=no-member
|
story += self.bul_table(format="pdf") # pylint: disable=no-member
|
||||||
# infos sous la table
|
# infos sous la table
|
||||||
objects += self.bul_part_below(format="pdf") # pylint: disable=no-member
|
story += self.bul_part_below(format="pdf") # pylint: disable=no-member
|
||||||
# signatures
|
# signatures
|
||||||
objects += self.bul_signatures_pdf() # pylint: disable=no-member
|
story += self.bul_signatures_pdf() # pylint: disable=no-member
|
||||||
if self.scale_table_in_page:
|
if self.scale_table_in_page:
|
||||||
# Réduit sur une page
|
# Réduit sur une page
|
||||||
objects = [marque_debut_bulletin, KeepInFrame(0, 0, objects, mode="shrink")]
|
story = [marque_debut_bulletin, KeepInFrame(0, 0, story, mode="shrink")]
|
||||||
else:
|
else:
|
||||||
# Insere notre marqueur qui permet de générer les bookmarks et filigrannes:
|
# Insere notre marqueur qui permet de générer les bookmarks et filigrannes:
|
||||||
objects.insert(index_obj_debut, marque_debut_bulletin)
|
story.insert(index_obj_debut, marque_debut_bulletin)
|
||||||
#
|
#
|
||||||
# objects.append(sco_pdf.FinBulletin())
|
# objects.append(sco_pdf.FinBulletin())
|
||||||
if not stand_alone:
|
if not stand_alone:
|
||||||
objects.append(PageBreak()) # insert page break at end
|
if self.multi_pages:
|
||||||
return objects
|
# Bulletins sur plusieurs page, force début suivant sur page impaire
|
||||||
|
story.append(
|
||||||
|
DocIf("doc.page%2 == 1", [PageBreak(), PageBreak()], [PageBreak()])
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
story.append(PageBreak()) # insert page break at end
|
||||||
|
|
||||||
|
return story
|
||||||
else:
|
else:
|
||||||
# Generation du document PDF
|
# Generation du document PDF
|
||||||
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
sem = sco_formsemestre.get_formsemestre(formsemestre_id)
|
||||||
@ -198,7 +213,7 @@ class BulletinGenerator:
|
|||||||
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
preferences=sco_preferences.SemPreferences(formsemestre_id),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
document.build(objects)
|
document.build(story)
|
||||||
data = report.getvalue()
|
data = report.getvalue()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -359,7 +359,6 @@ class BulletinDocTemplate(BaseDocTemplate):
|
|||||||
)
|
)
|
||||||
if flowable.filigranne:
|
if flowable.filigranne:
|
||||||
self.filigranne = flowable.filigranne
|
self.filigranne = flowable.filigranne
|
||||||
# log(f"afterFlowable addOutlineEntry {flowable.bookmark} page {self.page}")
|
|
||||||
|
|
||||||
|
|
||||||
def _makeTimeDict():
|
def _makeTimeDict():
|
||||||
|
Loading…
Reference in New Issue
Block a user