diff --git a/app/models/but_refcomp.py b/app/models/but_refcomp.py index 429c63898e..0750f1a9f6 100644 --- a/app/models/but_refcomp.py +++ b/app/models/but_refcomp.py @@ -6,8 +6,6 @@ """ScoDoc 9 models : Référentiel Compétence BUT 2021 """ from datetime import datetime -from enum import unique -from typing import Any from sqlalchemy.orm import class_mapper import sqlalchemy @@ -28,6 +26,8 @@ def attribute_names(cls): class XMLModel: + """Mixin class, to ease loading Orebut XMLs""" + _xml_attribs = {} # to be overloaded id = "_" @@ -162,6 +162,7 @@ class ApcCompetence(db.Model, XMLModel): class ApcSituationPro(db.Model, XMLModel): + "Situation professionnelle" id = db.Column(db.Integer, primary_key=True) competence_id = db.Column( db.Integer, db.ForeignKey("apc_competence.id"), nullable=False @@ -173,6 +174,7 @@ class ApcSituationPro(db.Model, XMLModel): class ApcComposanteEssentielle(db.Model, XMLModel): + "Composante essentielle" id = db.Column(db.Integer, primary_key=True) competence_id = db.Column( db.Integer, db.ForeignKey("apc_competence.id"), nullable=False @@ -199,6 +201,9 @@ class ApcNiveau(db.Model, XMLModel): cascade="all, delete-orphan", ) + def __repr__(self): + return f"<{self.__class__.__name__} ordre={self.ordre}>" + def to_dict(self): return { "libelle": self.libelle, @@ -222,14 +227,14 @@ class ApcAppCritique(db.Model, XMLModel): backref=db.backref("app_critiques", lazy="dynamic"), ) - def to_dict(self): + def to_dict(self) -> dict: return {"libelle": self.libelle} - def get_label(self): + def get_label(self) -> str: return self.code + " - " + self.titre def __repr__(self): - return "".format(self.code) + return f"<{self.__class__.__name__} {self.code}>" def get_saes(self): """Liste des SAE associées""" @@ -258,6 +263,9 @@ class ApcParcours(db.Model, XMLModel): cascade="all, delete-orphan", ) + def __repr__(self): + return f"<{self.__class__.__name__} {self.code}>" + def to_dict(self): return { "code": self.code, @@ -274,6 +282,9 @@ class ApcAnneeParcours(db.Model, XMLModel): ) ordre = db.Column(db.Integer) + def __repr__(self): + return f"<{self.__class__.__name__} ordre={self.ordre}>" + def to_dict(self): return { "ordre": self.ordre, @@ -320,3 +331,6 @@ class ApcParcoursNiveauCompetence(db.Model): cascade="save-update, merge, delete, delete-orphan", ), ) + + def __repr__(self): + return f"<{self.__class__.__name__} {self.competence} {self.annee_parcours}>" diff --git a/app/models/formations.py b/app/models/formations.py index f76607d3c9..43d3d680c0 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -7,7 +7,6 @@ from app.comp import df_cache from app.models import SHORT_STR_LEN from app.models.modules import Module from app.models.ues import UniteEns -from app.scodoc import notesdb as ndb from app.scodoc import sco_cache from app.scodoc import sco_codes_parcours from app.scodoc import sco_utils as scu diff --git a/app/scodoc/sco_bulletins.py b/app/scodoc/sco_bulletins.py index bb1d933dbd..efc0b53415 100644 --- a/app/scodoc/sco_bulletins.py +++ b/app/scodoc/sco_bulletins.py @@ -32,7 +32,7 @@ import email import time from flask import g, request -from flask import flash, render_template, url_for +from flask import flash, jsonify, render_template, url_for from flask_login import current_user from app import email @@ -76,6 +76,34 @@ from app.scodoc import sco_bulletins_legacy from app.scodoc import sco_bulletins_ucac # format expérimental UCAC Cameroun +def get_formsemestre_bulletin_etud_json( + formsemestre: FormSemestre, + etud: Identite, + force_publishing=False, + version="long", +) -> str: + """Le JSON du bulletin d'un étudiant, quel que soit le type de formation.""" + if formsemestre.formation.is_apc(): + r = bulletin_but.BulletinBUT(formsemestre) + return jsonify( + r.bulletin_etud( + etud, + formsemestre, + force_publishing=force_publishing, + version=version, + ) + ) + return formsemestre_bulletinetud( + etud, + formsemestre_id=formsemestre.id, + format="json", + version=version, + xml_with_decisions=True, + force_publishing=force_publishing, + ) + + +# ------------- def make_context_dict(formsemestre: FormSemestre, etud: dict) -> dict: """Construit dictionnaire avec valeurs pour substitution des textes (preferences bul_pdf_*) @@ -799,7 +827,10 @@ def formsemestre_bulletinetud( force_publishing=False, # force publication meme si semestre non publie sur "portail" prefer_mail_perso=False, ): - "page bulletin de notes" + """Page bulletin de notes + pour les formations classiques hors BUT (page HTML) + ou le format "oldjson". + """ format = format or "html" formsemestre: FormSemestre = FormSemestre.query.get(formsemestre_id) if not formsemestre: diff --git a/app/templates/but/bulletin.html b/app/templates/but/bulletin.html index 826356ff4c..8c260e600d 100644 --- a/app/templates/but/bulletin.html +++ b/app/templates/but/bulletin.html @@ -34,14 +34,14 @@ }) .catch(error => { let div = document.createElement("div"); - div.innerText = "Une erreur s'est produite lors du transfère des données."; + div.innerText = "Une erreur s'est produite lors du transfert des données."; div.style.fontSize = "24px"; div.style.color = "#d93030"; let releve = document.querySelector("releve-but"); releve.after(div); releve.remove(); - + throw 'Fin du script - données invalides'; }); document.querySelector("html").style.scrollBehavior = "smooth"; diff --git a/app/templates/but/refcomp_show.html b/app/templates/but/refcomp_show.html index 2b245b59b1..0e4ffef688 100644 --- a/app/templates/but/refcomp_show.html +++ b/app/templates/but/refcomp_show.html @@ -13,14 +13,13 @@
-Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à partir du fichier {{ref.scodoc_orig_filename or "(inconnu)"}}. + Référentiel chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M") if ref.scodoc_date_loaded else ""}} à + partir du fichier {{ref.scodoc_orig_filename or "(inconnu)"}}.
-revenir à la liste des référentiels + liste des référentiels
{% endblock %} diff --git a/app/views/notes.py b/app/views/notes.py index cd0e5238e3..adde8b6a12 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -312,53 +312,42 @@ def formsemestre_bulletinetud( raise ScoValueError( "Paramètre manquant: spécifier etudid, code_nip ou code_ine" ) - if formsemestre.formation.is_apc() and format != "oldjson": - if format == "json": - r = bulletin_but.BulletinBUT(formsemestre) - return jsonify( - r.bulletin_etud( - etud, - formsemestre, - force_publishing=force_publishing, - version=version, - ) - ) - elif format == "html": - return render_template( - "but/bulletin.html", - appreciations=models.BulAppreciations.query.filter_by( - etudid=etudid, formsemestre_id=formsemestre.id - ).order_by(models.BulAppreciations.date), - bul_url=url_for( - "notes.formsemestre_bulletinetud", - scodoc_dept=g.scodoc_dept, - formsemestre_id=formsemestre_id, - etudid=etudid, - format="json", - force_publishing=1, # pour ScoDoc lui même - version=version, - ), - can_edit_appreciations=formsemestre.est_responsable(current_user) - or (current_user.has_permission(Permission.ScoEtudInscrit)), - etud=etud, - formsemestre=formsemestre, - inscription_courante=etud.inscription_courante(), - inscription_str=etud.inscription_descr()["inscription_str"], - is_apc=formsemestre.formation.is_apc(), - menu_autres_operations=sco_bulletins.make_menu_autres_operations( - formsemestre, etud, "notes.formsemestre_bulletinetud", version - ), - sco=ScoData(etud=etud), - scu=scu, - time=time, - title=f"Bul. {etud.nom} - BUT", - version=version, - ) - - if not (etudid or code_nip or code_ine): - raise ScoValueError( - "Paramètre manquant: spécifier code_nip ou etudid ou code_ine" + if format == "json": + return sco_bulletins.get_formsemestre_bulletin_etud_json( + formsemestre, etud, version=version ) + if formsemestre.formation.is_apc() and format == "html": + return render_template( + "but/bulletin.html", + appreciations=models.BulAppreciations.query.filter_by( + etudid=etudid, formsemestre_id=formsemestre.id + ).order_by(models.BulAppreciations.date), + bul_url=url_for( + "notes.formsemestre_bulletinetud", + scodoc_dept=g.scodoc_dept, + formsemestre_id=formsemestre_id, + etudid=etudid, + format="json", + force_publishing=1, # pour ScoDoc lui même + version=version, + ), + can_edit_appreciations=formsemestre.est_responsable(current_user) + or (current_user.has_permission(Permission.ScoEtudInscrit)), + etud=etud, + formsemestre=formsemestre, + inscription_courante=etud.inscription_courante(), + inscription_str=etud.inscription_descr()["inscription_str"], + is_apc=formsemestre.formation.is_apc(), + menu_autres_operations=sco_bulletins.make_menu_autres_operations( + formsemestre, etud, "notes.formsemestre_bulletinetud", version + ), + sco=ScoData(etud=etud), + scu=scu, + time=time, + title=f"Bul. {etud.nom} - BUT", + version=version, + ) + if format == "oldjson": format = "json" r = sco_bulletins.formsemestre_bulletinetud( diff --git a/sco_version.py b/sco_version.py index df7bcd01e5..d5f9c80842 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.2.11" +SCOVERSION = "9.2.12" SCONAME = "ScoDoc"