From b124468399e56c469cca79496ddcdf85b7f489fb Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 18 Sep 2023 22:47:25 +0200 Subject: [PATCH] =?UTF-8?q?petites=20am=C3=A9lioration=20du=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/scodoc/sco_formsemestre_status.py | 95 +++++++++++++-------------- app/views/assiduites.py | 23 ++++--- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index 0612204a..2b00158f 100755 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -811,63 +811,58 @@ def formsemestre_description( # genere liste html pour accès aux groupes de ce semestre -def _make_listes_sem(formsemestre: FormSemestre, with_absences=True): - # construit l'URL "destination" - # (a laquelle on revient apres saisie absences) - destination = url_for( - "notes.formsemestre_status", - scodoc_dept=g.scodoc_dept, - formsemestre_id=formsemestre.id, - ) - # +def _make_listes_sem(formsemestre: FormSemestre) -> str: + """La section avec les groupes et l'assiduité""" H = [] # pas de menu absences si pas autorise: - if with_absences and not current_user.has_permission(Permission.ScoAbsChange): - with_absences = False - + can_edit_abs = current_user.has_permission(Permission.ScoAbsChange) # H.append( f"""

Listes de {formsemestre.titre} ({formsemestre.mois_debut()} - {formsemestre.mois_fin()})

""" ) - weekday = datetime.datetime.today().weekday() - try: - if with_absences: - form_abs_tmpl = f""" - - - """ - form_abs_tmpl += f""" - - - - - """ - else: - form_abs_tmpl = f""" - - - - """ - except ScoInvalidDateError: # dates incorrectes dans semestres ? - form_abs_tmpl = "" + form_abs_tmpl = f""" + + + + """ + + if can_edit_abs: + form_abs_tmpl += f""" + + + + + + + + + """ + form_abs_tmpl += "" # H.append('
') # Genere liste pour chaque partition (categorie de groupes) @@ -875,7 +870,7 @@ def _make_listes_sem(formsemestre: FormSemestre, with_absences=True): if not partition["partition_name"]: H.append("

Tous les étudiants

") else: - H.append("

Groupes de %(partition_name)s

" % partition) + H.append(f"""

Groupes de {partition["partition_name"]}

""") partition_is_empty = True groups = sco_groups.get_partition_groups(partition) if groups: diff --git a/app/views/assiduites.py b/app/views/assiduites.py index ecce79c6..32cb529b 100644 --- a/app/views/assiduites.py +++ b/app/views/assiduites.py @@ -704,8 +704,8 @@ def signal_assiduites_group(): @permission_required(Permission.ScoView) def visu_assiduites_group(): """ - signal_assiduites_group Saisie des assiduités des groupes pour le jour donnée - + Visualisation des assiduités des groupes pour le jour donné + dans le formsemestre_id et le moduleimpl_id Returns: str: l'html généré """ @@ -721,15 +721,17 @@ def visu_assiduites_group(): map(str, group_ids) # Vérification du moduleimpl_id - try: - moduleimpl_id = int(moduleimpl_id) - except (TypeError, ValueError): - moduleimpl_id = None + if moduleimpl_id is not None: + try: + moduleimpl_id = int(moduleimpl_id) + except (TypeError, ValueError) as exc: + raise ScoValueError("identifiant de moduleimpl invalide") from exc # Vérification du formsemestre_id - try: - formsemestre_id = int(formsemestre_id) - except (TypeError, ValueError): - formsemestre_id = None + if formsemestre_id is not None: + try: + formsemestre_id = int(formsemestre_id) + except (TypeError, ValueError) as exc: + raise ScoValueError("identifiant de formsemestre invalide") from exc groups_infos = sco_groups_view.DisplayedGroupsInfos( group_ids, moduleimpl_id=moduleimpl_id, formsemestre_id=formsemestre_id @@ -924,6 +926,7 @@ def etat_abs_date(): @scodoc @permission_required(Permission.ScoView) def visu_assi_group(): + """Visualisation de l'assiduité d'un groupe entre deux dates""" dates = { "debut": request.args.get("date_debut"), "fin": request.args.get("date_fin"),