From 763f60fb3d1f5649b47116044dd828d6c2f1cbfb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 19 Mar 2024 09:34:03 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20/etud=5Finfo=5Fhtml=20si=20pas=20de=20do?= =?UTF-8?q?nn=C3=A9es=20admission?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/formations.py | 3 +- app/but/import_refcomp.py | 10 +++-- app/scodoc/sco_page_etud.py | 88 ++++++++++++++++++++----------------- sco_version.py | 2 +- 4 files changed, 57 insertions(+), 46 deletions(-) diff --git a/app/api/formations.py b/app/api/formations.py index 7ff02a07..37bf6ccf 100644 --- a/app/api/formations.py +++ b/app/api/formations.py @@ -52,7 +52,8 @@ def formations(): @as_json def formations_ids(): """ - Retourne la liste de toutes les id de formations (tous départements) + Retourne la liste de toutes les id de formations + (tous départements, ou du département indiqué dans la route) Exemple de résultat : [ 17, 99, 32 ] """ diff --git a/app/but/import_refcomp.py b/app/but/import_refcomp.py index b203c413..8a11c2d8 100644 --- a/app/but/import_refcomp.py +++ b/app/but/import_refcomp.py @@ -23,9 +23,12 @@ from app.models.but_refcomp import ( from app.scodoc.sco_exceptions import ScoFormatError, ScoValueError -def orebut_import_refcomp(xml_data: str, dept_id: int, orig_filename=None): +def orebut_import_refcomp( + xml_data: str, dept_id: int, orig_filename=None +) -> ApcReferentielCompetences: """Importation XML Orébut peut lever TypeError ou ScoFormatError + L'objet créé est ajouté et commité. Résultat: instance de ApcReferentielCompetences """ # Vérifie que le même fichier n'a pas déjà été chargé: @@ -41,7 +44,7 @@ def orebut_import_refcomp(xml_data: str, dept_id: int, orig_filename=None): try: root = ElementTree.XML(xml_data) except ElementTree.ParseError as exc: - raise ScoFormatError(f"fichier XML Orébut invalide (2): {exc.args}") + raise ScoFormatError(f"fichier XML Orébut invalide (2): {exc.args}") from exc if root.tag != "referentiel_competence": raise ScoFormatError("élément racine 'referentiel_competence' manquant") args = ApcReferentielCompetences.attr_from_xml(root.attrib) @@ -60,7 +63,8 @@ def orebut_import_refcomp(xml_data: str, dept_id: int, orig_filename=None): # ne devrait plus se produire car pas d'unicité de l'id: donc inutile db.session.rollback() raise ScoValueError( - f"""Un référentiel a déjà été chargé avec les mêmes compétences ! ({competence.attrib["id"]}) + f"""Un référentiel a déjà été chargé avec les mêmes compétences ! ({ + competence.attrib["id"]}) """ ) from exc ref.competences.append(c) diff --git a/app/scodoc/sco_page_etud.py b/app/scodoc/sco_page_etud.py index c5b21b7b..ad52e813 100644 --- a/app/scodoc/sco_page_etud.py +++ b/app/scodoc/sco_page_etud.py @@ -332,28 +332,29 @@ def fiche_etud(etudid=None): ) # fiche admission - infos_admission = _infos_admission(etud, restrict_etud_data) - has_adm_notes = any( - infos_admission[k] for k in ("math", "physique", "anglais", "francais") - ) - has_bac_info = any( - infos_admission[k] - for k in ( - "bac_specialite", - "annee_bac", - "rapporteur", - "commentaire", - "classement", - "type_admission", - "rap", + if etud.admission: + infos_admission = _infos_admission(etud, restrict_etud_data) + has_adm_notes = any( + infos_admission[k] for k in ("math", "physique", "anglais", "francais") ) - ) - if has_bac_info or has_adm_notes: - adm_tmpl = """ -
Informations admission
-""" - if has_adm_notes: - adm_tmpl += """ + has_bac_info = any( + infos_admission[k] + for k in ( + "bac_specialite", + "annee_bac", + "rapporteur", + "commentaire", + "classement", + "type_admission", + "rap", + ) + ) + if has_bac_info or has_adm_notes: + adm_tmpl = """ +
Informations admission
+ """ + if has_adm_notes: + adm_tmpl += """ @@ -364,24 +365,26 @@ def fiche_etud(etudid=None):
BacAnnéeRg MathPhysiqueAnglaisFrançais
%(math)s%(physique)s%(anglais)s%(francais)s
-""" - adm_tmpl += """ -
Bac %(bac_specialite)s obtenu en %(annee_bac)s
-
%(info_lycee)s
""" - if infos_admission["type_admission"] or infos_admission["classement"]: - adm_tmpl += """
""" - if infos_admission["type_admission"]: - adm_tmpl += """Voie d'admission: %(type_admission)s """ - if infos_admission["classement"]: - adm_tmpl += """Rang admission: %(classement)s""" - if infos_admission["type_admission"] or infos_admission["classement"]: - adm_tmpl += "
" - if infos_admission["rap"]: - adm_tmpl += """
%(rap)s
""" - adm_tmpl += """""" + """ + adm_tmpl += """ +
Bac %(bac_specialite)s obtenu en %(annee_bac)s
+
%(info_lycee)s
""" + if infos_admission["type_admission"] or infos_admission["classement"]: + adm_tmpl += """
""" + if infos_admission["type_admission"]: + adm_tmpl += """Voie d'admission: %(type_admission)s """ + if infos_admission["classement"]: + adm_tmpl += """Rang admission: %(classement)s""" + if infos_admission["type_admission"] or infos_admission["classement"]: + adm_tmpl += "
" + if infos_admission["rap"]: + adm_tmpl += """
%(rap)s
""" + adm_tmpl += """""" + else: + adm_tmpl = "" # pas de boite "info admission" + info["adm_data"] = adm_tmpl % infos_admission else: - adm_tmpl = "" # pas de boite "info admission" - info["adm_data"] = adm_tmpl % infos_admission + info["adm_data"] = "" # Fichiers archivés: info["fichiers_archive_htm"] = ( @@ -654,7 +657,7 @@ def _format_adresse(adresse: Adresse | None) -> dict: def _infos_admission(etud: Identite, restrict_etud_data: bool) -> dict: - """dict with adminission data, restricted or not""" + """dict with admission data, restricted or not""" # info sur rapporteur et son commentaire rap = "" if not restrict_etud_data: @@ -799,8 +802,11 @@ def etud_info_html(etudid, with_photo="1", debug=False): code_cursus, _ = sco_report.get_code_cursus_etud( etud, formsemestres=etud.get_formsemestres(), prefix="S", separator=", " ) - bac = sco_bac.Baccalaureat(etud.admission.bac, etud.admission.specialite) - bac_abbrev = bac.abbrev() + if etud.admission: + bac = sco_bac.Baccalaureat(etud.admission.bac, etud.admission.specialite) + bac_abbrev = bac.abbrev() + else: + bac_abbrev = "-" H = f"""