liste refcomps + routes

This commit is contained in:
Emmanuel Viennet 2021-12-03 15:46:46 +01:00
parent 958539977a
commit c455f6261f
3 changed files with 48 additions and 5 deletions

View File

@ -39,9 +39,6 @@ class Formation(db.Model):
referentiel_competence_id = db.Column( referentiel_competence_id = db.Column(
db.Integer, db.ForeignKey("apc_referentiel_competences.id") 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") ues = db.relationship("UniteEns", backref="formation", lazy="dynamic")
formsemestres = db.relationship("FormSemestre", lazy="dynamic", backref="formation") formsemestres = db.relationship("FormSemestre", lazy="dynamic", backref="formation")
ues = db.relationship("UniteEns", lazy="dynamic", backref="formation") ues = db.relationship("UniteEns", lazy="dynamic", backref="formation")

View File

@ -0,0 +1,17 @@
{% extends "base.html" %}
{% import 'bootstrap/wtf.html' as wtf %}
{% block app_content %}
<h1>Référentiels de compétences chargés</h1>
<div class="row">
{{tab.html() | safe}}
</div>
<div>
<a href="{{url_for(
'notes.refcomp_load', scodoc_dept=g.scodoc_dept)
}}">charger un nouveau référentiel de compétences Orébut</a>.
</div>
{% endblock %}

View File

@ -22,12 +22,13 @@ from app.models.formations import Formation
from app.models.but_refcomp import ApcReferentielCompetences from app.models.but_refcomp import ApcReferentielCompetences
from app.but.import_refcomp import orebut_import_refcomp from app.but.import_refcomp import orebut_import_refcomp
from app.but.forms.refcomp_forms import FormationRefCompForm, RefCompLoadForm 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_exceptions import ScoFormatError
from app.scodoc.sco_permissions import Permission from app.scodoc.sco_permissions import Permission
from app.views import notes_bp as bp from app.views import notes_bp as bp
@bp.route("/referentiel/comp/<int:refcomp_id>") @bp.route("/referentiel/comp/get/<int:refcomp_id>")
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
def refcomp(refcomp_id): def refcomp(refcomp_id):
@ -35,6 +36,31 @@ def refcomp(refcomp_id):
return jsonify(ref.to_dict()) 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/<int:formation_id>", methods=["GET", "POST"]) @bp.route("/refcomp_assoc/<int:formation_id>", methods=["GET", "POST"])
@scodoc @scodoc
@permission_required(Permission.ScoChangeFormation) @permission_required(Permission.ScoChangeFormation)
@ -74,7 +100,10 @@ def refcomp_assoc(formation_id: int):
) )
@bp.route("/refcomp_load/<int:formation_id>", methods=["GET", "POST"]) @bp.route(
"/referentiel/comp/load", defaults={"formation_id": None}, methods=["GET", "POST"]
)
@bp.route("/referentiel/comp/load/<int:formation_id>", methods=["GET", "POST"])
@scodoc @scodoc
@permission_required(Permission.ScoChangeFormation) @permission_required(Permission.ScoChangeFormation)
def refcomp_load(formation_id=None): def refcomp_load(formation_id=None):