From d5f01e062858d4aa1754410530e522291bb4aca9 Mon Sep 17 00:00:00 2001 From: iziram Date: Thu, 1 Jun 2023 17:32:50 +0200 Subject: [PATCH] =?UTF-8?q?Assiduites=20:=20Signalement=20diff=C3=A9r?= =?UTF-8?q?=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/but/bulletin_but.py | 1 - app/scodoc/sco_formsemestre_status.py | 30 +- app/scodoc/sco_preferences.py | 10 +- .../assiduites/signal_assiduites_diff.j2 | 372 ++++++++++++++++++ app/views/assiduites.py | 81 +++- 5 files changed, 465 insertions(+), 29 deletions(-) create mode 100644 app/templates/assiduites/signal_assiduites_diff.j2 diff --git a/app/but/bulletin_but.py b/app/but/bulletin_but.py index 4d008214..e24aac66 100644 --- a/app/but/bulletin_but.py +++ b/app/but/bulletin_but.py @@ -390,7 +390,6 @@ class BulletinBUT: "H.": "Heure(s)", "J.": "Journée(s)", "1/2 J.": "1/2 Jour.", - "N.": "Nombre", }.get(sco_preferences.get_preference("assi_metrique")), } decisions_ues = self.res.get_etud_decisions_ue(etud.id) or {} diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index e7f47b0b..c8cb25da 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -823,34 +823,20 @@ def _make_listes_sem(formsemestre: FormSemestre, with_absences=True): first_monday = sco_abs.ddmmyyyy( formsemestre.date_debut.strftime("%d/%m/%Y") ).prev_monday() - form_abs_tmpl = f""" + form_abs_tmpl = """ - absences + -
- - - - - - - saisie par semaine -
+ }?group_ids=%(group_id)s&jour={datetime.date.today().isoformat()}&formsemestre_id={formsemestre.id}"> + + """ else: form_abs_tmpl = "" diff --git a/app/scodoc/sco_preferences.py b/app/scodoc/sco_preferences.py index 9656f060..b7099dab 100644 --- a/app/scodoc/sco_preferences.py +++ b/app/scodoc/sco_preferences.py @@ -632,7 +632,7 @@ class BasePreferences(object): }, ), ( - "etat_defaut", + "assi_etat_defaut", { "initvalue": "aucun", "input_type": "menu", @@ -658,12 +658,12 @@ class BasePreferences(object): { "initvalue": "1/2 J.", "input_type": "menu", - "labels": ["1/2 J.", "J.", "H.", "N."], - "allowed_values": ["1/2 J.", "J.", "H.", "N."], + "labels": ["1/2 J.", "J.", "H."], + "allowed_values": ["1/2 J.", "J.", "H."], "title": "Métrique de l'assiduité", - "explanation": "Unité affichée dans la fiche étudiante et le bilan\n(J. = journée, H. = heure, N. = nombre)", + "explanation": "Unité affichée dans la fiche étudiante et le bilan\n(J. = journée, H. = heure)", "category": "assi", - "only_global" : True, + "only_global": True, }, ), # portal diff --git a/app/templates/assiduites/signal_assiduites_diff.j2 b/app/templates/assiduites/signal_assiduites_diff.j2 new file mode 100644 index 00000000..e0061e0b --- /dev/null +++ b/app/templates/assiduites/signal_assiduites_diff.j2 @@ -0,0 +1,372 @@ +

Signalement différé des assiduités {{gr |safe}}

+

{{sem | safe }}

+ +
+
+
+
Noms
+ +
+
+
+ + {% for etud in etudiants %} +
+
{{etud.nomprenom}}
+
+ {% endfor %} +
+
+ +{% include "assiduites/alert.j2" %} +{% include "assiduites/prompt.j2" %} + + + + \ No newline at end of file diff --git a/app/views/assiduites.py b/app/views/assiduites.py index 978c69c3..a283797b 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -325,6 +325,7 @@ def signal_assiduites_group(): # --- Filtrage par formsemestre --- formsemestre_id = groups_infos.formsemestre_id + formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id) if formsemestre.dept_id != g.scodoc_dept_id: abort(404, "groupes inexistants dans ce département") @@ -414,7 +415,7 @@ def signal_assiduites_group(): @bp.route("/EtatAbsencesDate") @scodoc -@permission_required(Permission.ScoAbsChange) +@permission_required(Permission.ScoView) def get_etat_abs_date(): evaluation = { "jour": request.args.get("jour"), @@ -483,6 +484,84 @@ def get_etat_abs_date(): ).build() +@bp.route("/SignalAssiduiteDifferee") +@scodoc +@permission_required(Permission.ScoAbsChange) +def signal_assiduites_diff(): + group_ids: list[int] = request.args.get("group_ids", None) + etudid: int = request.args.get("etudid", None) + formsemestre_id: int = request.args.get("formsemestre_id", -1) + etudiants: list[dict] = [] + + titre = None + + # Vérification du formsemestre_id + try: + formsemestre_id = int(formsemestre_id) + except (TypeError, ValueError): + formsemestre_id = None + + formsemestre: FormSemestre = FormSemestre.query.get_or_404(formsemestre_id) + + if etudid is not None: + etudiants.append(sco_etud.get_etud_info(etudid=int(etudid), filled=True)[0]) + + if group_ids is None: + group_ids = [] + else: + group_ids = group_ids.split(",") + map(str, group_ids) + + groups_infos = sco_groups_view.DisplayedGroupsInfos(group_ids) + + etudiants.extend( + [ + sco_etud.get_etud_info(etudid=m["etudid"], filled=True)[0] + for m in groups_infos.members + ] + ) + + etudiants = list(sorted(etudiants, key=lambda x: x["nom"])) + + header: str = html_sco_header.sco_header( + page_title="Assiduités Différées", + init_qtip=True, + javascripts=html_sco_header.BOOTSTRAP_MULTISELECT_JS + + [ + "js/assiduites.js", + "libjs/moment.new.min.js", + "libjs/moment-timezone.js", + ], + ) + + sem = formsemestre.to_dict() + + if groups_infos.tous_les_etuds_du_sem: + gr_tit = "en" + else: + if len(groups_infos.group_ids) > 1: + grp = "des groupes" + else: + grp = "du groupe" + gr_tit = ( + grp + ' ' + groups_infos.groups_titles + "" + ) + + + return HTMLBuilder( + header, + render_template( + "assiduites/signal_assiduites_diff.j2", + etudiants=etudiants, + etat_def=sco_preferences.get_preference("assi_etat_defaut"), + moduleimpl_select=_module_selector(formsemestre), + gr=gr_tit, + sem=sem["titre_num"], + ), + html_sco_header.sco_footer(), + ).build() + + def _module_selector( formsemestre: FormSemestre, moduleimpl_id: int = None ) -> HTMLElement: