diff --git a/app/models/formations.py b/app/models/formations.py index dd809500b..8c52dff22 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 96074bdb9..588913ddd 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 bee6b6a19..b15e2f71e 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 0648fa523..e6bf3160e 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 b1d8bddbb..488d5ea94 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 40ada69dd..f5b9c995a 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 a496c4c51..542a161cf 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 %}
+