From c455f6261fcc4846f39e550f971e801ac1090c38 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 3 Dec 2021 15:46:46 +0100 Subject: [PATCH] liste refcomps + routes --- app/models/formations.py | 3 --- app/templates/but/refcomp_table.html | 17 ++++++++++++++ app/views/refcomp.py | 33 ++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 app/templates/but/refcomp_table.html diff --git a/app/models/formations.py b/app/models/formations.py index 19940fa4e..a49ce655c 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -39,9 +39,6 @@ class Formation(db.Model): referentiel_competence_id = db.Column( db.Integer, db.ForeignKey("apc_referentiel_competences.id") ) - referentiel_competence = db.relationship( # one-to-one - "ApcReferentielCompetences", backref="formation", uselist=False - ) ues = db.relationship("UniteEns", backref="formation", lazy="dynamic") formsemestres = db.relationship("FormSemestre", lazy="dynamic", backref="formation") ues = db.relationship("UniteEns", lazy="dynamic", backref="formation") diff --git a/app/templates/but/refcomp_table.html b/app/templates/but/refcomp_table.html new file mode 100644 index 000000000..2f7e40683 --- /dev/null +++ b/app/templates/but/refcomp_table.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} +{% import 'bootstrap/wtf.html' as wtf %} + +{% block app_content %} +

Référentiels de compétences chargés

+ +
+ {{tab.html() | safe}} +
+ +
+ charger un nouveau référentiel de compétences Orébut. +
+ +{% endblock %} \ No newline at end of file diff --git a/app/views/refcomp.py b/app/views/refcomp.py index 7f0bdb8f7..5f3c10ae0 100644 --- a/app/views/refcomp.py +++ b/app/views/refcomp.py @@ -22,12 +22,13 @@ from app.models.formations import Formation from app.models.but_refcomp import ApcReferentielCompetences from app.but.import_refcomp import orebut_import_refcomp from app.but.forms.refcomp_forms import FormationRefCompForm, RefCompLoadForm +from app.scodoc.gen_tables import GenTable from app.scodoc.sco_exceptions import ScoFormatError from app.scodoc.sco_permissions import Permission from app.views import notes_bp as bp -@bp.route("/referentiel/comp/") +@bp.route("/referentiel/comp/get/") @scodoc @permission_required(Permission.ScoView) def refcomp(refcomp_id): @@ -35,6 +36,31 @@ def refcomp(refcomp_id): return jsonify(ref.to_dict()) +@bp.route("/referentiel/comp/table") +@scodoc +@permission_required(Permission.ScoView) +def refcomp_table(): + """Liste html des ref. comp. chargés dans ce département""" + refs = ApcReferentielCompetences.query.filter_by(dept_id=g.scodoc_dept_id) + tab = GenTable( + columns_ids=("type_titre", "specialite_long", "json", "nb_formations"), + titles={"type_titre": "Type", "specialite_long": "Spécialité"}, + rows=[ + { + "type_titre": ref.type_titre, + "specialite_long": ref.specialite_long, + "json": "json", + "_json_target": url_for( + "notes.refcomp", scodoc_dept=g.scodoc_dept, refcomp_id=ref.id + ), + "nb_formations": len(ref.formations), + } + for ref in refs + ], + ) + return render_template("but/refcomp_table.html", tab=tab) + + @bp.route("/refcomp_assoc/", methods=["GET", "POST"]) @scodoc @permission_required(Permission.ScoChangeFormation) @@ -74,7 +100,10 @@ def refcomp_assoc(formation_id: int): ) -@bp.route("/refcomp_load/", methods=["GET", "POST"]) +@bp.route( + "/referentiel/comp/load", defaults={"formation_id": None}, methods=["GET", "POST"] +) +@bp.route("/referentiel/comp/load/", methods=["GET", "POST"]) @scodoc @permission_required(Permission.ScoChangeFormation) def refcomp_load(formation_id=None):