From 24440f457b7637b0579a1c524ce9606e6f541abb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 4 Dec 2021 22:20:08 +0100 Subject: [PATCH] vis. et suppr. des ref. comp. --- app/templates/but/refcomp_show.html | 16 ++++++++++ app/views/refcomp.py | 48 +++++++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 app/templates/but/refcomp_show.html diff --git a/app/templates/but/refcomp_show.html b/app/templates/but/refcomp_show.html new file mode 100644 index 00000000..d5664e3b --- /dev/null +++ b/app/templates/but/refcomp_show.html @@ -0,0 +1,16 @@ +{% extends "sco_page.html" %} + +{% block app_content %} +

Référentiel de compétences {{ref.type_titre}} {{ref.specialite_long}}

+ +
+ +Chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M")}} à partir du fichier {{ref.scodoc_orig_filename}}. + +
+ +
+revenir à la liste des référentiels +
+ +{% endblock %} \ No newline at end of file diff --git a/app/views/refcomp.py b/app/views/refcomp.py index f47e5fbe..3eb7f142 100644 --- a/app/views/refcomp.py +++ b/app/views/refcomp.py @@ -24,6 +24,7 @@ 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 import html_sidebar +from app.scodoc import sco_utils as scu from app.scodoc.sco_exceptions import ScoFormatError from app.scodoc.sco_permissions import Permission from app.views import notes_bp as bp @@ -38,24 +39,67 @@ def refcomp(refcomp_id): return jsonify(ref.to_dict()) +@bp.route("/referentiel/comp/show/") +@scodoc +@permission_required(Permission.ScoView) +def refcomp_show(refcomp_id): + ref = ApcReferentielCompetences.query.get_or_404(refcomp_id) + return render_template( + "but/refcomp_show.html", + ref=ref, + title="Référentiel de compétences", + sco=ScoData(), + ) + + +@bp.route("/referentiel/comp/delete/", methods=["GET", "POST"]) +@scodoc +@permission_required(Permission.ScoChangeFormation) +def refcomp_delete(refcomp_id): + ref = ApcReferentielCompetences.query.get_or_404(refcomp_id) + db.session.delete(ref) + db.session.commit() + flash("référentiel de compétences supprimé") + return redirect(url_for("notes.refcomp_table", scodoc_dept=g.scodoc_dept)) + + @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) + columns_ids = ("type_titre", "specialite_long", "json", "nb_formations") + if current_user.has_permission(Permission.ScoChangeFormation): + columns_ids = ("suppr",) + columns_ids + suppr_icon = scu.icontag( + "delete_small_img", border="0", alt="supprimer", title="Supprimer" + ) tab = GenTable( - columns_ids=("type_titre", "specialite_long", "json", "nb_formations"), - titles={"type_titre": "Type", "specialite_long": "Spécialité"}, + columns_ids=columns_ids, + titles={ + "suppr": "", + "type_titre": "Type", + "specialite_long": "Spécialité", + "json": "Export", + "nb_formations": "Formations", + }, rows=[ { "type_titre": ref.type_titre, "specialite_long": ref.specialite_long, + "_specialite_long_target": url_for( + "notes.refcomp_show", scodoc_dept=g.scodoc_dept, refcomp_id=ref.id + ), "json": "json", "_json_target": url_for( "notes.refcomp", scodoc_dept=g.scodoc_dept, refcomp_id=ref.id ), "nb_formations": len(ref.formations), + "suppr": suppr_icon, + "_suppr_target": url_for( + "notes.refcomp_delete", scodoc_dept=g.scodoc_dept, refcomp_id=ref.id + ), } for ref in refs ],