From 57f0066556f49e53056124b6ac708b68890af3bb Mon Sep 17 00:00:00 2001 From: Iziram Date: Fri, 12 Jul 2024 16:40:46 +0200 Subject: [PATCH] Formulaire feuille d'appel --- app/forms/scolar/groups_form.py | 56 +++++++++++ app/scodoc/sco_excel.py | 14 +-- app/scodoc/sco_groups_view.py | 17 ++-- .../scolar/formulaire_feuille_appel.j2 | 55 +++++++++++ app/views/__init__.py | 5 +- app/views/groups.py | 93 +++++++++++++++++++ 6 files changed, 225 insertions(+), 15 deletions(-) create mode 100644 app/forms/scolar/groups_form.py create mode 100644 app/templates/scolar/formulaire_feuille_appel.j2 create mode 100644 app/views/groups.py diff --git a/app/forms/scolar/groups_form.py b/app/forms/scolar/groups_form.py new file mode 100644 index 000000000..33a0d7521 --- /dev/null +++ b/app/forms/scolar/groups_form.py @@ -0,0 +1,56 @@ +""" +Formulaire FlaskWTF pour les groupes +""" + +from flask_wtf import FlaskForm +from wtforms import StringField, SubmitField, validators + + +class FeuilleAppelPreForm(FlaskForm): + """ + Formulaire utiliser dans le téléchargement des feuilles d'émargement + """ + + def __init__(self, *args, **kwargs): + "Init form, adding a filed for our error messages" + super().__init__(*args, **kwargs) + self.ok = True + self.error_messages: list[str] = [] + + def set_error(self, err_msg, field=None): + "Set error message both in form and field" + self.ok = False + self.error_messages.append(err_msg) + if field: + field.errors.append(err_msg) + + discipline = StringField( + "Discipline", + ) + + ens = StringField( + "Enseignant", + ) + + date = StringField( + "Date de la séance", + validators=[validators.Length(max=10)], + render_kw={ + "class": "datepicker", + "size": 10, + "id": "date", + }, + ) + + heure = StringField( + "Heure de début de la séance", + default="", + validators=[validators.Length(max=5)], + render_kw={ + "class": "timepicker", + "size": 5, + "id": "heure", + }, + ) + + submit = SubmitField("Télécharger la liste d'émargement") diff --git a/app/scodoc/sco_excel.py b/app/scodoc/sco_excel.py index dd15da8bd..f82a04f98 100644 --- a/app/scodoc/sco_excel.py +++ b/app/scodoc/sco_excel.py @@ -26,8 +26,8 @@ ############################################################################## -""" Excel file handling -""" +"""Excel file handling""" + import datetime import io import time @@ -724,10 +724,7 @@ def excel_feuille_listeappel( # ligne 3 cell_2 = ws.make_cell("Enseignant :", style2) - cell_6 = ws.make_cell(f"Groupe {groupname}", style3) - ws.append_row( - [None, cell_2, ws.make_cell(edt_params.get("ens", ""), style3), cell_6] - ) + ws.append_row([None, cell_2, ws.make_cell(edt_params.get("ens", ""), style3)]) # ligne 4: Avertissement pour ne pas confondre avec listes notes + Date cell_1 = ws.make_cell("Date :", style2) @@ -745,10 +742,13 @@ def excel_feuille_listeappel( ] ) + # ligne 6: groupe + ws.append_row([None, ws.make_cell(f"Groupe {groupname}", style3)]) + ws.append_blank_row() ws.append_row([None, cell_2]) - # ligne 8: Entête (contruction dans une liste cells) + # ligne 9: Entête (contruction dans une liste cells) cell_2 = ws.make_cell("Nom", style3) cells = [None, cell_2] letter_int += 1 diff --git a/app/scodoc/sco_groups_view.py b/app/scodoc/sco_groups_view.py index 86d7db499..40ff6d7cf 100644 --- a/app/scodoc/sco_groups_view.py +++ b/app/scodoc/sco_groups_view.py @@ -586,8 +586,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"] = ( + 'id="%s" class="etudinfo"' % (etud_info["etudid"]) ) etud_info["bourse_str"] = "oui" if etud_info["boursier"] else "non" if etud_info["etat"] == "D": @@ -748,8 +748,6 @@ def groups_table( tab.html(), f"""