From 21714bae59b31c840790135329d57a316941fa0d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 21 Feb 2023 02:30:48 +0100 Subject: [PATCH] =?UTF-8?q?PV=20BUUT:=20options=20sans=20d=C3=A9tail=20ide?= =?UTF-8?q?ntit=C3=A9,=20anonyme=20et=20seulement=20dipl=C3=B4m=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/jury_but.py | 4 ++++ app/but/jury_but_pv.py | 20 +++++++++++++++----- app/models/etudiants.py | 19 +++++++++++++------ app/scodoc/sco_pv_pdf.py | 7 ++++++- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/app/but/jury_but.py b/app/but/jury_but.py index 942a5aa7d..1e861c9e5 100644 --- a/app/but/jury_but.py +++ b/app/but/jury_but.py @@ -983,6 +983,10 @@ class DecisionsProposeesAnnee(DecisionsProposees): messages.append(f"L'UE {ue.acronyme} n'a pas décision (???)") return messages + def valide_diplome(self) -> bool: + "Vrai si l'étudiant à validé son diplôme" + return False # TODO XXX + def list_ue_parcour_etud( formsemestre: FormSemestre, etud: Identite, res: ResultatsSemestreBUT diff --git a/app/but/jury_but_pv.py b/app/but/jury_but_pv.py index 32dd5a0f7..551c4d3ac 100644 --- a/app/but/jury_but_pv.py +++ b/app/but/jury_but_pv.py @@ -92,7 +92,12 @@ def pvjury_page_but(formsemestre_id: int, fmt="html"): def pvjury_table_but( - formsemestre: FormSemestre, etudids: list[int] = None, line_sep: str = "\n" + formsemestre: FormSemestre, + etudids: list[int] = None, + line_sep: str = "\n", + only_diplome=False, + anonymous=False, + with_paragraph_nom=False, ) -> tuple[list[dict], dict]: """Table avec résultats jury BUT pour PV. Si etudids est None, prend tous les étudiants inscrits. @@ -100,7 +105,7 @@ def pvjury_table_but( # remplace pour le BUT la fonction sco_pv_forms.pvjury_table annee_but = (formsemestre.semestre_id + 1) // 2 titles = { - "nom": "Nom", + "nom": "Code" if anonymous else "Nom", "cursus": "Cursus", "ects": "ECTS", "ues": "UE validées", @@ -127,8 +132,13 @@ def pvjury_table_but( continue except ScoValueError: deca = None + row = { - "nom": etud.etat_civil_pv(line_sep=line_sep), + "nom": etud.code_ine or etud.code_nip or etud.id + if anonymous # Mode anonyme: affiche INE ou sinon NIP, ou id + else etud.etat_civil_pv( + line_sep=line_sep, with_paragraph=with_paragraph_nom + ), "_nom_order": etud.sort_key, "_nom_target_attrs": f'class="etudinfo" id="{etud.id}"', "_nom_td_attrs": f'id="{etud.id}" class="etudinfo"', @@ -148,8 +158,8 @@ def pvjury_table_but( if deca else "", } - - rows.append(row) + if deca.valide_diplome() or not only_diplome: + rows.append(row) rows.sort(key=lambda x: x["_nom_order"]) return rows, titles diff --git a/app/models/etudiants.py b/app/models/etudiants.py index c49717111..77d07250a 100644 --- a/app/models/etudiants.py +++ b/app/models/etudiants.py @@ -419,14 +419,21 @@ class Identite(db.Model): return situation - def etat_civil_pv(self, line_sep="\n") -> str: + def etat_civil_pv(self, with_paragraph=True, line_sep="\n") -> str: """Présentation, pour PV jury - M. Pierre Dupont - n° 12345678 - né(e) le 7/06/1974 - à Paris + Si with_paragraph (défaut): + M. Pierre Dupont + n° 12345678 + né(e) le 7/06/1974 + à Paris + Sinon: + M. Pierre Dupont """ - return f"""{self.nomprenom}{line_sep}n°{self.code_nip or ""}{line_sep}né{self.e} le {self.date_naissance.strftime("%d/%m/%Y") if self.date_naissance else ""}{line_sep}à {self.lieu_naissance or ""}""" + if with_paragraph: + return f"""{self.nomprenom}{line_sep}n°{self.code_nip or ""}{line_sep}né{self.e} le { + self.date_naissance.strftime("%d/%m/%Y") if self.date_naissance else ""}{ + line_sep}à {self.lieu_naissance or ""}""" + return self.nomprenom def photo_html(self, title=None, size="small") -> str: """HTML img tag for the photo, either in small size (h90) diff --git a/app/scodoc/sco_pv_pdf.py b/app/scodoc/sco_pv_pdf.py index c9473ba1e..6c84deb98 100644 --- a/app/scodoc/sco_pv_pdf.py +++ b/app/scodoc/sco_pv_pdf.py @@ -232,7 +232,12 @@ def _pvjury_pdf_type( if formsemestre.formation.is_apc(): rows, titles = jury_but_pv.pvjury_table_but( - formsemestre, etudids=etudids, line_sep="
" + formsemestre, + etudids=etudids, + line_sep="
", + only_diplome=only_diplome, + anonymous=anonymous, + with_paragraph_nom=with_paragraph_nom, ) columns_ids = list(titles.keys()) a_diplome = codes_cursus.ADM in [row.get("diplome") for row in rows]