1
0
forked from ScoDoc/ScoDoc

vis. et suppr. des ref. comp.

This commit is contained in:
Emmanuel Viennet 2021-12-04 22:20:08 +01:00
parent f555122989
commit 24440f457b
2 changed files with 62 additions and 2 deletions

View File

@ -0,0 +1,16 @@
{% extends "sco_page.html" %}
{% block app_content %}
<h2>Référentiel de compétences {{ref.type_titre}} {{ref.specialite_long}}</h2>
<div>
Chargé le {{ref.scodoc_date_loaded.strftime("%d/%m/%Y à %H:%M")}} à partir du fichier <tt>{{ref.scodoc_orig_filename}}</tt>.
</div>
<div class="part2">
<a class="stdlink" href="{{url_for('notes.refcomp_table', scodoc_dept=g.scodoc_dept)}}">revenir à la liste des référentiels</a>
</div>
{% endblock %}

View File

@ -24,6 +24,7 @@ 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.gen_tables import GenTable
from app.scodoc import html_sidebar 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_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
@ -38,24 +39,67 @@ def refcomp(refcomp_id):
return jsonify(ref.to_dict()) return jsonify(ref.to_dict())
@bp.route("/referentiel/comp/show/<int:refcomp_id>")
@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/<int:refcomp_id>", 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") @bp.route("/referentiel/comp/table")
@scodoc @scodoc
@permission_required(Permission.ScoView) @permission_required(Permission.ScoView)
def refcomp_table(): def refcomp_table():
"""Liste html des ref. comp. chargés dans ce département""" """Liste html des ref. comp. chargés dans ce département"""
refs = ApcReferentielCompetences.query.filter_by(dept_id=g.scodoc_dept_id) 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( tab = GenTable(
columns_ids=("type_titre", "specialite_long", "json", "nb_formations"), columns_ids=columns_ids,
titles={"type_titre": "Type", "specialite_long": "Spécialité"}, titles={
"suppr": "",
"type_titre": "Type",
"specialite_long": "Spécialité",
"json": "Export",
"nb_formations": "Formations",
},
rows=[ rows=[
{ {
"type_titre": ref.type_titre, "type_titre": ref.type_titre,
"specialite_long": ref.specialite_long, "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": "json",
"_json_target": url_for( "_json_target": url_for(
"notes.refcomp", scodoc_dept=g.scodoc_dept, refcomp_id=ref.id "notes.refcomp", scodoc_dept=g.scodoc_dept, refcomp_id=ref.id
), ),
"nb_formations": len(ref.formations), "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 for ref in refs
], ],