From d8f6fe35e902ee830f29337aa87e2d5f4421673d Mon Sep 17 00:00:00 2001 From: ilona Date: Fri, 23 Aug 2024 16:33:35 +0200 Subject: [PATCH] Liste groupe: affichage optionnel de la date d'inscription --- app/scodoc/sco_excel.py | 17 ++++++++++++++--- app/scodoc/sco_groups_view.py | 34 +++++++++++++++++++++++++++------- app/static/js/groups_view.js | 30 +++++++++++++++++++----------- app/views/scolar.py | 12 +++++++++--- 4 files changed, 69 insertions(+), 24 deletions(-) diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index 1ef1df49..8a30e92e 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -45,6 +45,7 @@ from openpyxl.worksheet.worksheet import Worksheet import app.scodoc.sco_utils as scu from app import log +from app.models.scolar_event import ScolarEvent from app.scodoc.sco_exceptions import ScoValueError from app.scodoc import notesdb, sco_preferences @@ -638,11 +639,12 @@ def excel_feuille_listeappel( lines, partitions=None, with_codes=False, + with_date_inscription=False, with_paiement=False, server_name=None, edt_params: dict = None, ): - """generation feuille appel + """Génération feuille appel. edt_params : - "discipline" : Discipline @@ -763,7 +765,8 @@ def excel_feuille_listeappel( cells.append(ws.make_cell("etudid", style3)) cells.append(ws.make_cell("code_nip", style3)) cells.append(ws.make_cell("code_ine", style3)) - + if with_date_inscription: + cells.append(ws.make_cell("Date inscr.", style3)) # case Groupes cells.append(ws.make_cell("Groupes", style3)) letter_int += 1 @@ -805,7 +808,15 @@ def excel_feuille_listeappel( cells.append(ws.make_cell(code_nip, style2t3)) code_ine = t.get("code_ine", "") cells.append(ws.make_cell(code_ine, style2t3)) - + if with_date_inscription: + event = ScolarEvent.query.filter_by( + etudid=t["etudid"], + event_type="INSCRIPTION", + formsemestre_id=formsemestre_id, + ).first() + if event: + date_inscription = event.event_date + cells.append(ws.make_cell(date_inscription, style2t3)) cells.append(ws.make_cell(style=style2t3)) ws.append_row(cells) ws.set_row_dimension_height(row_id, 30) diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index d4817ee2..541589bb 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -40,7 +40,7 @@ from flask import url_for, g, render_template, request from flask_login import current_user from app import db -from app.models import FormSemestre, Identite +from app.models import FormSemestre, Identite, ScolarEvent import app.scodoc.sco_utils as scu from app.scodoc import html_sco_header from app.scodoc import sco_assiduites as scass @@ -70,6 +70,7 @@ def groups_lists( group_ids=(), fmt="html", with_codes=0, + with_date_inscription=0, etat=None, with_paiement=0, with_archives=0, @@ -102,6 +103,7 @@ def groups_lists( groups_infos=groups_infos, fmt=fmt, with_codes=with_codes, + with_date_inscription=with_date_inscription, etat=etat, with_paiement=with_paiement, with_archives=with_archives, @@ -121,6 +123,7 @@ def groups_lists( groups_infos=groups_infos, fmt=fmt, with_codes=with_codes, + with_date_inscription=with_date_inscription, etat=etat, with_paiement=with_paiement, with_archives=with_archives, @@ -507,6 +510,7 @@ class DisplayedGroupsInfos: def groups_table( groups_infos: DisplayedGroupsInfos = None, with_codes=0, + with_date_inscription=0, etat=None, fmt="html", with_paiement=0, # si vrai, ajoute colonnes infos paiement droits et finalisation inscription (lent car interrogation portail) @@ -522,15 +526,16 @@ def groups_table( can_view_etud_data = int(current_user.has_permission(Permission.ViewEtudData)) with_codes = int(with_codes) + with_date_inscription = int(with_date_inscription) with_paiement = int(with_paiement) and can_view_etud_data with_archives = int(with_archives) and can_view_etud_data with_annotations = int(with_annotations) and can_view_etud_data with_bourse = int(with_bourse) and can_view_etud_data - base_url_np = groups_infos.base_url + f"&with_codes={with_codes}" base_url = ( - base_url_np - + f"""&with_paiement={with_paiement}&with_archives={ + groups_infos.base_url + + f"""&with_codes={with_codes}&with_date_inscription={ + with_date_inscription}&with_paiement={with_paiement}&with_archives={ with_archives}&with_annotations={with_annotations }&with_bourse={with_bourse}""" ) @@ -546,6 +551,7 @@ def groups_table( "etudid": "etudid", "code_nip": "code_nip", "code_ine": "code_ine", + "date_inscription": "Date inscription", "datefinalisationinscription_str": "Finalisation inscr.", "paiementinscription_str": "Paiement", "etudarchive": "Fichiers", @@ -579,9 +585,11 @@ def groups_table( if with_codes: columns_ids += ["etape", "etudid", "code_nip", "code_ine"] + if with_date_inscription: + columns_ids += ["date_inscription"] if with_paiement: columns_ids += ["datefinalisationinscription_str", "paiementinscription_str"] - if with_paiement: # or with_codes: + if with_paiement: sco_portal_apogee.check_paiement_etuds(groups_infos.members) if with_archives: from app.scodoc import sco_archives_etud @@ -597,6 +605,16 @@ def groups_table( moodle_groupenames = set() # ajoute liens for etud_info in groups_infos.members: + if with_date_inscription: + event = ScolarEvent.query.filter_by( + etudid=etud_info["etudid"], + event_type="INSCRIPTION", + formsemestre_id=groups_infos.formsemestre_id, + ).first() + if event: + etud_info["date_inscription"] = event.event_date.strftime(scu.DATE_FMT) + etud_info["_date_inscription_xls"] = event.event_date + etud_info["_date_inscription_order"] = event.event_date.isoformat if etud_info["email"]: etud_info["_email_target"] = "mailto:" + etud_info["email"] else: @@ -612,8 +630,8 @@ def groups_table( etud_info["_nom_disp_order"] = etud_sort_key(etud_info) etud_info["_prenom_target"] = fiche_url - etud_info["_nom_disp_td_attrs"] = 'id="%s" class="etudinfo"' % ( - etud_info["etudid"] + etud_info["_nom_disp_td_attrs"] = ( + f"""id="{etud_info['etudid']}" class="etudinfo" """ ) etud_info["bourse_str"] = "oui" if etud_info["boursier"] else "non" if etud_info["etat"] == "D": @@ -720,6 +738,7 @@ def groups_table( if groups_infos.members: options = { "with_codes": "Affiche codes", + "with_date_inscription": "Date inscription", } if can_view_etud_data: options.update( @@ -824,6 +843,7 @@ def groups_table( groups_infos.members, partitions=groups_infos.partitions, with_codes=with_codes, + with_date_inscription=with_date_inscription, with_paiement=with_paiement, server_name=request.url_root, ) diff --git a/app/static/js/groups_view.js b/app/static/js/groups_view.js index 7f16a580..43eb694b 100644 --- a/app/static/js/groups_view.js +++ b/app/static/js/groups_view.js @@ -48,13 +48,12 @@ function change_list_options(selected_options) { "with_archives", "with_annotations", "with_codes", + "with_date_inscription", "with_bourse", ]; for (var i = 0; i < options.length; i++) { - var option = options[i]; - if ($.inArray(option, selected_options) >= 0) { - urlParams.set(option, "1"); - } + let option = options[i]; + urlParams.set(option, selected_options.indexOf(option) >= 0 ? "1" : "0"); } window.location = url.href; } @@ -62,23 +61,32 @@ function change_list_options(selected_options) { // Menu choix groupe: function toggle_visible_etuds() { // - $(".etud_elem").hide(); + document.querySelectorAll('.etud_elem').forEach(element => { + element.style.display = 'none'; + }); var qargs = ""; - $("#group_ids_sel option:selected").each(function (index, opt) { + var selectedOptions = document.querySelectorAll("#group_ids_sel option:checked"); + var qargs = ""; + selectedOptions.forEach(function (opt) { var group_id = opt.value; - $(".group-" + group_id).show(); + var groupElements = document.querySelectorAll(".group-" + group_id); + groupElements.forEach(function (elem) { + elem.style.display = "block"; + }); qargs += "&group_ids=" + group_id; }); // Update url saisie tableur: - var input_eval = $("#formnotes_evaluation_id"); + let input_eval = document.querySelectorAll("#formnotes_evaluation_id"); if (input_eval.length > 0) { - var evaluation_id = input_eval[0].value; - $("#menu_saisie_tableur a").attr( + let evaluation_id = input_eval[0].value; + let menu_saisie_tableur_a = document.querySelector("#menu_saisie_tableur a"); + menu_saisie_tableur_a.setAttribute( "href", "saisie_notes_tableur?evaluation_id=" + evaluation_id + qargs ); // lien feuille excel: - $("#lnk_feuille_saisie").attr( + let lnk_feuille_saisie = document.querySelector("#lnk_feuille_saisie"); + lnk_feuille_saisie.setAttribute( "href", "feuille_saisie_notes?evaluation_id=" + evaluation_id + qargs ); diff --git a/app/views/scolar.py b/app/views/scolar.py index 1a55f771..31438ae8 100644 --- a/app/views/scolar.py +++ b/app/views/scolar.py @@ -471,18 +471,24 @@ def groups_lists( fmt="html", # Options pour listes: with_codes=0, + with_date_inscription=0, etat=None, - with_paiement=0, # si vrai, ajoute colonnes infos paiement droits et finalisation inscription (lent car interrogation portail) - with_archives=0, # ajoute colonne avec noms fichiers archivés + with_paiement=0, + with_archives=0, with_annotations=0, with_bourse=0, formsemestre_id=None, ): - "Listes des étudiants des groupes" + """Listes des étudiants des groupes. + Si with_paiement, ajoute colonnes infos paiement droits et finalisation + inscription (lent car interrogation portail). + Si with_archives, ajoute colonne avec noms fichiers archivés. + """ return sco_groups_view.groups_lists( group_ids=group_ids, fmt=fmt, with_codes=with_codes, + with_date_inscription=with_date_inscription, etat=etat, with_paiement=with_paiement, with_archives=with_archives,