From 5efebb133679306080123c80eb95134715c4f897 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 10 Mar 2022 09:18:19 +0100 Subject: [PATCH] =?UTF-8?q?Bul.=20BUT:=20SAE=20dans=20synth=C3=A8se,=20pie?= =?UTF-8?q?d=20de=20bul.=20sur=20meme=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/bulletin_but_pdf.py | 43 ++++++++++++++-------------- app/scodoc/sco_bulletins_standard.py | 7 +++-- app/scodoc/sco_groups.py | 2 +- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/app/but/bulletin_but_pdf.py b/app/but/bulletin_but_pdf.py index bd8791cc..6a317684 100644 --- a/app/but/bulletin_but_pdf.py +++ b/app/but/bulletin_but_pdf.py @@ -6,7 +6,7 @@ """Génération bulletin BUT au format PDF standard """ - +import itertools from reportlab.platypus import KeepInFrame, Paragraph, Spacer from app.scodoc.sco_pdf import blue, cm, mm @@ -141,26 +141,27 @@ class BulletinGeneratorStandardBUT(BulletinGeneratorStandard): ], } rows.append(t) - # Liste chaque ressource - for mod_code, mod in ue["ressources"].items(): - t = { - "titre": f"{mod_code} {self.infos['ressources'][mod_code]['titre']}", - "moyenne": mod["moyenne"], - "coef": mod["coef"], - "_coef_pdf": Paragraph( - f"{mod['coef']}" - ), - "_pdf_style": [ - ( - "LINEBELOW", - (0, 0), - (-1, 0), - self.PDF_LINEWIDTH, - (0.7, 0.7, 0.7), # gris clair - ) - ], - } - rows.append(t) + # Liste chaque ressource puis SAE + for mod_type in ("ressources", "saes"): + for mod_code, mod in ue[mod_type].items(): + t = { + "titre": f"{mod_code} {self.infos[mod_type][mod_code]['titre']}", + "moyenne": mod["moyenne"], + "coef": mod["coef"], + "_coef_pdf": Paragraph( + f"{mod['coef']}" + ), + "_pdf_style": [ + ( + "LINEBELOW", + (0, 0), + (-1, 0), + self.PDF_LINEWIDTH, + (0.7, 0.7, 0.7), # gris clair + ) + ], + } + rows.append(t) # Global pdf style commands: pdf_style = [ ("VALIGN", (0, 0), (-1, -1), "TOP"), diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index fd84e7d9..95f6f172 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -46,10 +46,11 @@ de la forme %(XXX)s sont remplacées par la valeur de XXX, pour XXX dans: Balises img: actuellement interdites. """ +from reportlab.platypus import KeepTogether, Paragraph, Spacer, Table +from reportlab.lib.units import cm, mm +from reportlab.lib.colors import Color, blue import app.scodoc.sco_utils as scu -from app.scodoc.sco_pdf import Color, Paragraph, Spacer, Table -from app.scodoc.sco_pdf import blue, cm, mm from app.scodoc.sco_pdf import SU from app.scodoc import sco_preferences from app.scodoc.sco_permissions import Permission @@ -195,7 +196,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): # ----- if format == "pdf": - return Op + return [KeepTogether(Op)] elif format == "html": return "\n".join(H) diff --git a/app/scodoc/sco_groups.py b/app/scodoc/sco_groups.py index 2a27b498..48a1dbba 100644 --- a/app/scodoc/sco_groups.py +++ b/app/scodoc/sco_groups.py @@ -124,7 +124,7 @@ def get_partition(partition_id): {"partition_id": partition_id}, ) if not r: - raise ValueError("invalid partition_id (%s)" % partition_id) + raise ScoValueError(f"Partition inconnue (déjà supprimée ?) ({partition_id})") return r[0]