From 94c5c51983b2aa4b2326f422af92212b6e3dfb5d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Sat, 13 May 2023 18:35:10 +0200 Subject: [PATCH] Fix petits bugs parcours BUT, cosmetic --- app/models/formations.py | 4 +++- app/models/ues.py | 8 +++++--- app/static/css/parcour_formation.css | 2 ++ app/static/css/scodoc.css | 17 +++++++++++++++-- app/static/js/edit_ue.js | 4 +++- app/static/js/scodoc.js | 17 +++++++++++------ app/templates/base.j2 | 6 +++++- app/templates/but/parcour_formation.j2 | 2 +- app/templates/pn/form_ues.j2 | 15 ++++++++------- tests/ressources/yaml/cursus_but_info.yaml | 2 +- 10 files changed, 54 insertions(+), 23 deletions(-) diff --git a/app/models/formations.py b/app/models/formations.py index dd809500..8c52dff2 100644 --- a/app/models/formations.py +++ b/app/models/formations.py @@ -51,7 +51,9 @@ class Formation(db.Model): ) ues = db.relationship("UniteEns", backref="formation", lazy="dynamic") formsemestres = db.relationship("FormSemestre", lazy="dynamic", backref="formation") - ues = db.relationship("UniteEns", lazy="dynamic", backref="formation") + ues = db.relationship( + "UniteEns", lazy="dynamic", backref="formation", order_by="UniteEns.numero" + ) modules = db.relationship("Module", lazy="dynamic", backref="formation") def __repr__(self): diff --git a/app/models/ues.py b/app/models/ues.py index 96074bdb..588913dd 100644 --- a/app/models/ues.py +++ b/app/models/ues.py @@ -276,7 +276,8 @@ class UniteEns(db.Model): ues_meme_niveau = [ ue for ue in parcour.ues - if ue.formation_id == self.formation_id + if ue.id != self.id + and ue.formation_id == self.formation_id and ue.niveau_competence_id == niveau.id ] if ues_meme_niveau: @@ -295,8 +296,9 @@ class UniteEns(db.Model): 2 * (self.semestre_idx % 2) - 1 ) if ues_meme_niveau[0].semestre_idx != other_semestre_idx: - msg = f"""Niveau "{ - niveau.libelle}" associé à une autre année du {msg_parc}""" + msg = f"""Erreur: niveau "{ + niveau.libelle}" déjà associé à une autre UE du semestre S{ + ues_meme_niveau[0].semestre_idx} du {msg_parc}""" log( f"check_niveau_unique_dans_parcours(niveau_id={niveau.id}): " + msg diff --git a/app/static/css/parcour_formation.css b/app/static/css/parcour_formation.css index bee6b6a1..b15e2f71 100644 --- a/app/static/css/parcour_formation.css +++ b/app/static/css/parcour_formation.css @@ -37,6 +37,7 @@ div.les_parcours>div.parc>a:visited { .parcour_formation { margin-left: 16px; margin-right: 16px; + margin-bottom: 16px; min-width: 1200px; max-width: 1600px; } @@ -119,6 +120,7 @@ span.parc { font-weight: bold; /* color: rgb(92, 87, 255); */ color: white; + margin-right: 8px; padding: 4px; background-color: #09c; border-radius: 4px; diff --git a/app/static/css/scodoc.css b/app/static/css/scodoc.css index 0648fa52..e6bf3160 100644 --- a/app/static/css/scodoc.css +++ b/app/static/css/scodoc.css @@ -223,7 +223,7 @@ div.head_message { color: green; } -.message_curtom { +.message_custom { position: fixed; bottom: 100%; left: 50%; @@ -237,6 +237,18 @@ div.head_message { transform: translate(-50%, 0); } +div.message_error { + position: fixed; + top: 16px; + left: 50%; + transform: translateX(-50%); + z-index: 10; + padding: 20px; + border-radius: 10px 10px 10px 10px; + background: rgb(212, 0, 0); + color: #ffffff; + font-size: 24px; +} div.passwd_warn { font-weight: bold; @@ -2318,11 +2330,12 @@ span.notes_module_list_buts { div.formation_parcs { display: inline-flex; margin-left: 8px; + margin-right: 8px; + column-gap: 8px; } div.formation_parcs>div { font-size: 100%; - margin-left: 8px; color: white; background-color: #09c; opacity: 0.7; diff --git a/app/static/js/edit_ue.js b/app/static/js/edit_ue.js index b1d8bddb..488d5ea9 100644 --- a/app/static/js/edit_ue.js +++ b/app/static/js/edit_ue.js @@ -53,7 +53,9 @@ function set_ue_parcour(checkbox) { }) .then(response => response.json()) .then(data => { - if (data.status) { + if (data.status == 404) { + sco_error_message(data.message); + } else { sco_message(data.message); } }); diff --git a/app/static/js/scodoc.js b/app/static/js/scodoc.js index 40ada69d..f5b9c995 100644 --- a/app/static/js/scodoc.js +++ b/app/static/js/scodoc.js @@ -67,17 +67,22 @@ $(function () { } }); -// Affiche un message transitoire -function sco_message(msg) { +// Affiche un message transitoire (duration milliseconds, 0 means infinity) +function sco_message(msg, className = "message_custom", duration = 0) { var div = document.createElement("div"); - div.className = "message_curtom"; + div.className = className; div.innerHTML = msg; document.querySelector("body").appendChild(div); - setTimeout(() => { - div.remove(); - }, 3000); + if (duration) { + setTimeout(() => { + div.remove(); + }, 3000); + } } +function sco_error_message(msg) { + sco_message(msg, className = "message_error", duration = 0); +} function get_query_args() { diff --git a/app/templates/base.j2 b/app/templates/base.j2 index a496c4c5..542a161c 100644 --- a/app/templates/base.j2 +++ b/app/templates/base.j2 @@ -64,9 +64,13 @@ {% block content %}
{% include "flashed_messages.j2" %} - {# application content needs to be provided in the app_content block #} +
+ +{# application content needs to be provided in the app_content block #} +
{% block app_content %}{% endblock %}
+