From a52bd6e7fe2c4ade67a2e499f4d554a29df4b07b Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 21 Apr 2022 13:59:53 +0200 Subject: [PATCH] Edition elts Apo semestre et annee --- app/scodoc/sco_dept.py | 17 ++++++++++++- app/scodoc/sco_formation_recap.py | 2 +- app/static/js/scolar_index.js | 12 +++++++-- app/views/notes.py | 42 +++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 4 deletions(-) diff --git a/app/scodoc/sco_dept.py b/app/scodoc/sco_dept.py index 8c74fa65b..14c476513 100644 --- a/app/scodoc/sco_dept.py +++ b/app/scodoc/sco_dept.py @@ -237,6 +237,8 @@ def _sem_table_gt(sems, showcodes=False): "titre_resp", "nb_inscrits", "etapes_apo_str", + "elt_annee_apo", + "elt_sem_apo", ) if showcodes: columns_ids = ("formsemestre_id",) + columns_ids @@ -253,6 +255,9 @@ def _sem_table_gt(sems, showcodes=False): "dash_mois_fin": "Année", "titre_resp": "Semestre", "nb_inscrits": "N", + "etapes_apo_str": "Étape Apo.", + "elt_annee_apo": "Elt. année Apo.", + "elt_sem_apo": "Elt. sem. Apo.", }, columns_ids=columns_ids, rows=sems, @@ -260,7 +265,11 @@ def _sem_table_gt(sems, showcodes=False): html_class_ignore_default=True, html_class=html_class, html_sortable=True, - html_table_attrs=f"""data-apo_save_url="{url_for('notes.formsemestre_set_apo_etapes', scodoc_dept=g.scodoc_dept)}" """, + html_table_attrs=f""" + data-apo_save_url="{url_for('notes.formsemestre_set_apo_etapes', scodoc_dept=g.scodoc_dept)}" + data-elt_annee_apo_save_url="{url_for('notes.formsemestre_set_elt_annee_apo', scodoc_dept=g.scodoc_dept)}" + data-elt_sem_apo_save_url="{url_for('notes.formsemestre_set_elt_sem_apo', scodoc_dept=g.scodoc_dept)}" + """, html_with_td_classes=True, preferences=sco_preferences.SemPreferences(), ) @@ -298,6 +307,12 @@ def _style_sems(sems): sem[ "_etapes_apo_str_td_attrs" ] = f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['etapes_apo_str']}" """ + sem[ + "_elt_annee_apo_td_attrs" + ] = f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['elt_annee_apo']}" """ + sem[ + "_elt_sem_apo_td_attrs" + ] = f""" data-oid="{sem['formsemestre_id']}" data-value="{sem['elt_sem_apo']}" """ def delete_dept(dept_id: int): diff --git a/app/scodoc/sco_formation_recap.py b/app/scodoc/sco_formation_recap.py index 16aa336d2..fc594bcc7 100644 --- a/app/scodoc/sco_formation_recap.py +++ b/app/scodoc/sco_formation_recap.py @@ -70,7 +70,7 @@ def formation_table_recap(formation_id, format="html"): "_apo_td_attrs": f""" data-oid="{ue.id}" data-value="{ue.code_apogee or ''}" """, "coef": ue.coefficient or "", "ects": ue.ects, - "_css_row_class": f"ue ue_", + "_css_row_class": "ue", } ) li += 1 diff --git a/app/static/js/scolar_index.js b/app/static/js/scolar_index.js index 600a7cf5a..90c20b45f 100644 --- a/app/static/js/scolar_index.js +++ b/app/static/js/scolar_index.js @@ -1,5 +1,7 @@ /* Page accueil département */ var apo_editor = null; +var elt_annee_apo_editor = null; +var elt_sem_apo_editor = null; $(document).ready(function () { var table_options = { @@ -17,8 +19,14 @@ $(document).ready(function () { $('table.semlist').DataTable(table_options); let table_editable = document.querySelector("table#semlist.apo_editable"); if (table_editable) { - let apo_save_url = document.querySelector("table#semlist.apo_editable").dataset.apo_save_url; - apo_editor = new ScoFieldEditor(".etapes_apo_str", apo_save_url, false); + let save_url = document.querySelector("table#semlist.apo_editable").dataset.apo_save_url; + apo_editor = new ScoFieldEditor(".etapes_apo_str", save_url, false); + + save_url = document.querySelector("table#semlist.apo_editable").dataset.elt_annee_apo_save_url; + elt_annee_apo_editor = new ScoFieldEditor(".elt_annee_apo", save_url, false); + + save_url = document.querySelector("table#semlist.apo_editable").dataset.elt_sem_apo_save_url; + elt_sem_apo_editor = new ScoFieldEditor(".elt_sem_apo", save_url, false); } }); diff --git a/app/views/notes.py b/app/views/notes.py index 4fc69bdc8..2a6b76b12 100644 --- a/app/views/notes.py +++ b/app/views/notes.py @@ -2463,6 +2463,48 @@ def formsemestre_set_apo_etapes(): return ("", 204) +@bp.route("/formsemestre_set_elt_annee_apo", methods=["POST"]) +@scodoc +@permission_required(Permission.ScoEditApo) +def formsemestre_set_elt_annee_apo(): + """Change les codes étapes du semestre indiqué. + Args: oid=formsemestre_id, value=chaine "V3ONM, V3ONM1, V3ONM2", codes séparés par des virgules + """ + oid = int(request.form.get("oid")) + value = (request.form.get("value") or "").strip() + formsemestre: FormSemestre = FormSemestre.query.get_or_404(oid) + if value != formsemestre.elt_annee_apo: + formsemestre.elt_annee_apo = value + db.session.add(formsemestre) + db.session.commit() + ScolarNews.add( + typ=ScolarNews.NEWS_APO, + text=f"Modification code Apogée du semestre {formsemestre.titre_annee()})", + ) + return ("", 204) + + +@bp.route("/formsemestre_set_elt_sem_apo", methods=["POST"]) +@scodoc +@permission_required(Permission.ScoEditApo) +def formsemestre_set_elt_sem_apo(): + """Change les codes étapes du semestre indiqué. + Args: oid=formsemestre_id, value=chaine "V3ONM, V3ONM1, V3ONM2", codes séparés par des virgules + """ + oid = int(request.form.get("oid")) + value = (request.form.get("value") or "").strip() + formsemestre: FormSemestre = FormSemestre.query.get_or_404(oid) + if value != formsemestre.elt_sem_apo: + formsemestre.elt_sem_apo = value + db.session.add(formsemestre) + db.session.commit() + ScolarNews.add( + typ=ScolarNews.NEWS_APO, + text=f"Modification code Apogée du semestre {formsemestre.titre_annee()})", + ) + return ("", 204) + + @bp.route("/ue_set_apo", methods=["POST"]) @scodoc @permission_required(Permission.ScoEditApo)