From 4b4e52bf2dba250d589909a7781c33b3c88fc4b8 Mon Sep 17 00:00:00 2001 From: iziram Date: Fri, 2 Jun 2023 17:40:46 +0200 Subject: [PATCH] =?UTF-8?q?Assiduites=20:=20Correction=20bug=20granularit?= =?UTF-8?q?=C3=A9=20timeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/scodoc.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/scodoc.py b/app/views/scodoc.py index 339e5cd3e..7e2c9d163 100644 --- a/app/views/scodoc.py +++ b/app/views/scodoc.py @@ -203,8 +203,15 @@ def config_assiduites(): flash("Heure de midi enregistrée") if ScoDocSiteConfig.set("assi_afternoon_time", form.data["afternoon_time"]): flash("Heure de fin de la journée enregistrée") - if ScoDocSiteConfig.set("assi_tick_time", form.data["tick_time"]): + if ( + form.data["tick_time"] > 0 + and form.data["tick_time"] < 60 + and ScoDocSiteConfig.set("assi_tick_time", float(form.data["tick_time"])) + ): flash("Granularité de la timeline enregistrée") + else: + flash("Erreur : Granularité invalide ou identique") + return redirect(url_for("scodoc.configuration")) elif request.method == "GET": @@ -217,7 +224,12 @@ def config_assiduites(): form.afternoon_time.data = ScoDocSiteConfig.get( "assi_afternoon_time", datetime.time(18, 0, 0) ) - form.tick_time.data = float(ScoDocSiteConfig.get("assi_tick_time", 15)) + try: + form.tick_time.data = float(ScoDocSiteConfig.get("assi_tick_time", 15.0)) + except ValueError: + form.tick_time.data = 15.0 + ScoDocSiteConfig.set("assi_tick_time", 15.0) + return render_template( "assiduites/config_assiduites.j2", form=form,