From 1fd54ade84e1b68b0e116795325f220e694bd905 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 2 Sep 2023 15:53:30 +0200 Subject: [PATCH] Fix some bugs: bul. but, modimpl_status --- app/but/bulletin_but_court.py | 17 ++++++++++++---- app/but/bulletin_but_court_pdf.py | 25 ++++++++++++++++-------- app/scodoc/sco_bulletins_generator.py | 2 ++ app/scodoc/sco_bulletins_standard.py | 4 ++-- app/scodoc/sco_moduleimpl_status.py | 8 ++++++-- app/templates/bul_head.j2 | 18 +++++++++-------- app/templates/but/bulletin_court_page.j2 | 15 ++++++++++---- sco_version.py | 2 +- 8 files changed, 62 insertions(+), 29 deletions(-) diff --git a/app/but/bulletin_but_court.py b/app/but/bulletin_but_court.py index 684b16823..3997d091a 100644 --- a/app/but/bulletin_but_court.py +++ b/app/but/bulletin_but_court.py @@ -36,7 +36,7 @@ from app.decorators import ( ) from app.models import FormSemestre, FormSemestreInscription, Identite from app.scodoc.codes_cursus import UE_STANDARD -from app.scodoc.sco_exceptions import ScoNoReferentielCompetences +from app.scodoc.sco_exceptions import ScoNoReferentielCompetences, ScoValueError from app.scodoc.sco_logos import find_logo from app.scodoc.sco_permissions import Permission import app.scodoc.sco_utils as scu @@ -63,12 +63,18 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"): .filter_by(etudid=etudid) .first_or_404() ) + if not formsemestre.formation.is_apc(): + raise ScoValueError("formation non BUT") bulletins_sem = BulletinBUT(formsemestre) if fmt == "pdf": bul: dict = bulletins_sem.bulletin_etud_complet(etud) else: # la même chose avec un peu moins d'infos bul: dict = bulletins_sem.bulletin_etud(etud) - decision_ues = {x["acronyme"]: x for x in bul["semestre"]["decision_ue"]} + decision_ues = ( + {x["acronyme"]: x for x in bul["semestre"]["decision_ue"]} + if "semestre" in bul + else {} + ) cursus = cursus_but.EtudCursusBUT(etud, formsemestre.formation) refcomp = formsemestre.formation.referentiel_competence if refcomp is None: @@ -80,6 +86,7 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"): logo = find_logo(logoname="header", dept_id=g.scodoc_dept_id) + ue_acronyms = bul["ues"].keys() args = { "bul": bul, "cursus": cursus, @@ -91,13 +98,15 @@ def bulletin_but(formsemestre_id: int, etudid: int = None, fmt="html"): "title": f"Bul. {etud.nom_disp()} BUT (court)", "ue_validation_by_niveau": ue_validation_by_niveau, "ues_acronyms": [ - ue.acronyme for ue in bulletins_sem.res.ues if ue.type == UE_STANDARD + ue.acronyme + for ue in bulletins_sem.res.ues + if ue.type == UE_STANDARD and ue.acronyme in ue_acronyms ], } if fmt == "pdf": filename = scu.bul_filename(formsemestre, etud, prefix="bul-but") bul_pdf = bulletin_but_court_pdf.make_bulletin_but_court_pdf(**args) - return scu.sendPDFFile(bul_pdf, filename) + return scu.sendPDFFile(bul_pdf, filename + ".pdf") return render_template( "but/bulletin_court_page.j2", diff --git a/app/but/bulletin_but_court_pdf.py b/app/but/bulletin_but_court_pdf.py index 40914b09c..1887efd24 100644 --- a/app/but/bulletin_but_court_pdf.py +++ b/app/but/bulletin_but_court_pdf.py @@ -16,7 +16,7 @@ from flask_login import current_user from reportlab.lib import styles from reportlab.lib.colors import black, white, Color from reportlab.lib.enums import TA_CENTER -from reportlab.lib.units import cm, mm +from reportlab.lib.units import mm from reportlab.platypus import Paragraph, Spacer, Table from app.but import cursus_but @@ -102,13 +102,15 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard): self.style_base = styles.ParagraphStyle("style_base") self.style_base.fontName = "Helvetica" self.style_base.fontSize = 9 + self.style_base.firstLineIndent = 0 + # écrase style defaut des bulletins + self.style_field = self.style_base + # Le nom/prénom de l'étudiant: self.style_nom = styles.ParagraphStyle("style_nom", self.style_base) self.style_nom.fontSize = 11 self.style_nom.fontName = "Helvetica-Bold" - self.style_field = self.style_base # écrase style defaut buleltins - self.style_cell = styles.ParagraphStyle("style_cell", self.style_base) self.style_cell.fontSize = 7 self.style_cell.leading = 7 @@ -124,7 +126,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard): self.style_niveaux.firstLineIndent = 0 self.style_niveaux.leftIndent = 1 self.style_niveaux.rightIndent = 1 - self.style_niveaux.borderWidth = 1 + self.style_niveaux.borderWidth = 0.5 self.style_niveaux.borderPadding = 2 self.style_niveaux.borderRadius = 2 self.style_niveaux_top = styles.ParagraphStyle( @@ -162,6 +164,7 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard): ) # espace les lignes self.style_assiduite = self.style_cell + self.style_signature = self.style_appreciations # Géométrie page self.width_page_avail = 185 * mm # largeur utilisable @@ -189,10 +192,16 @@ class BulletinGeneratorBUTCourt(BulletinGeneratorStandard): appreciations = BulAppreciations.get_appreciations_list( self.formsemestre.id, self.etud.id ) - return [ - Spacer(1, 3 * mm), - self.bul_appreciations_pdf(appreciations, style=self.style_appreciations), - ] + return ( + [ + Spacer(1, 3 * mm), + self.bul_appreciations_pdf( + appreciations, style=self.style_appreciations + ), + ] + if appreciations + else [] + ) def bul_table(self, fmt=None) -> list: """Génère la table centrale du bulletin de notes diff --git a/app/scodoc/sco_bulletins_generator.py b/app/scodoc/sco_bulletins_generator.py index f0c66db67..bf6660d8f 100644 --- a/app/scodoc/sco_bulletins_generator.py +++ b/app/scodoc/sco_bulletins_generator.py @@ -117,6 +117,8 @@ class BulletinGenerator: self.style_field.fontName = self.preferences["SCOLAR_FONT_BUL_FIELDS"] self.style_field.fontSize = self.preferences["SCOLAR_FONT_SIZE"] self.style_field.firstLineIndent = 0 + # Champ signatures + self.style_signature = self.style_field # - Pour les cellules de table: self.CellStyle = reportlab.lib.styles.ParagraphStyle({}) self.CellStyle.fontSize = self.preferences["SCOLAR_FONT_SIZE"] diff --git a/app/scodoc/sco_bulletins_standard.py b/app/scodoc/sco_bulletins_standard.py index 8bff41a4c..c84f1a171 100644 --- a/app/scodoc/sco_bulletins_standard.py +++ b/app/scodoc/sco_bulletins_standard.py @@ -263,7 +263,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): sco_bulletins_pdf.process_field( self.preferences["bul_pdf_sig_left"], self.infos, - self.style_field, + self.style_signature, field_name="bul_pdf_sig_left", ) ] @@ -275,7 +275,7 @@ class BulletinGeneratorStandard(sco_bulletins_generator.BulletinGenerator): sco_bulletins_pdf.process_field( self.preferences["bul_pdf_sig_right"], self.infos, - self.style_field, + self.style_signature, field_name="bul_pdf_sig_right", ) ) diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index 93ce5237f..43b66230b 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -127,8 +127,12 @@ def moduleimpl_evaluation_menu(evaluation: Evaluation, nbnotes: int = 0) -> str: "args": { "group_ids": group_id, "desc": evaluation.description or "", - "date_debut": evaluation.date_debut.isoformat(), - "date_fin": evaluation.date_fin.isoformat(), + "date_debut": evaluation.date_debut.isoformat() + if evaluation.date_debut + else "", + "date_fin": evaluation.date_fin.isoformat() + if evaluation.date_fin + else "", }, "enabled": evaluation.date_debut is not None, }, diff --git a/app/templates/bul_head.j2 b/app/templates/bul_head.j2 index 9a59ccd52..89fa76899 100644 --- a/app/templates/bul_head.j2 +++ b/app/templates/bul_head.j2 @@ -42,20 +42,22 @@ format='pdf', version=version, )}}">{{scu.ICON_PDF|safe}} - version courte spéciale BUT + {% if formsemestre.formation.is_apc() %} + version courte spéciale BUT + {% endif %} {% if not is_apc %}
{{etud.photo_html(title="fiche de " + etud["nom"])|safe}}
{% endif %} diff --git a/app/templates/but/bulletin_court_page.j2 b/app/templates/but/bulletin_court_page.j2 index f7249c165..f1962d02c 100644 --- a/app/templates/but/bulletin_court_page.j2 +++ b/app/templates/but/bulletin_court_page.j2 @@ -39,10 +39,17 @@ {%- endmacro %} {% block app_content %} -

version pdf {{scu.ICON_PDF|safe}} +version complète

@@ -57,9 +64,9 @@
{% if bul.options.show_abs %} diff --git a/sco_version.py b/sco_version.py index 5cc41fa0f..dc28f1bd7 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.6.16" +SCOVERSION = "9.6.17" SCONAME = "ScoDoc"