From 0cafc0b1841b3f3d24fe1af44f17def9fe85036a Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 16 Jan 2024 12:36:20 +0100 Subject: [PATCH] Ajoute timepicker partout. Utilise pour evaluation_edit. Fix #829 --- app/models/evaluations.py | 18 ++++---------- app/scodoc/TrivialFormulator.py | 5 ++++ app/scodoc/html_sco_header.py | 24 ++++++++++++++----- app/scodoc/sco_evaluation_edit.py | 9 +++---- app/scodoc/sco_moduleimpl_status.py | 1 + .../assiduites/pages/ajout_assiduite_etud.j2 | 15 +----------- .../assiduites/pages/ajout_assiduites.j2 | 13 +--------- .../pages/ajout_justificatif_etud.j2 | 15 +----------- app/templates/assiduites/pages/choix_date.j2 | 9 ------- app/templates/sco_page.j2 | 3 +++ app/templates/sco_timepicker.j2 | 12 ++++++++++ 11 files changed, 49 insertions(+), 75 deletions(-) create mode 100644 app/templates/sco_timepicker.j2 diff --git a/app/models/evaluations.py b/app/models/evaluations.py index 3dcac6677..0c7d1213b 100644 --- a/app/models/evaluations.py +++ b/app/models/evaluations.py @@ -584,20 +584,10 @@ def check_convert_evaluation_args(moduleimpl: "ModuleImpl", data: dict): if date_debut and date_fin: duration = data["date_fin"] - data["date_debut"] if duration.total_seconds() < 0 or duration > MAX_EVALUATION_DURATION: - raise ScoValueError("Heures de l'évaluation incohérentes !") - # # --- heures - # heure_debut = data.get("heure_debut", None) - # if heure_debut and not isinstance(heure_debut, datetime.time): - # if date_format == "dmy": - # data["heure_debut"] = heure_to_time(heure_debut) - # else: # ISO - # data["heure_debut"] = datetime.time.fromisoformat(heure_debut) - # heure_fin = data.get("heure_fin", None) - # if heure_fin and not isinstance(heure_fin, datetime.time): - # if date_format == "dmy": - # data["heure_fin"] = heure_to_time(heure_fin) - # else: # ISO - # data["heure_fin"] = datetime.time.fromisoformat(heure_fin) + raise ScoValueError( + "Heures de l'évaluation incohérentes !", + dest_url="javascript:history.back();", + ) def heure_to_time(heure: str) -> datetime.time: diff --git a/app/scodoc/TrivialFormulator.py b/app/scodoc/TrivialFormulator.py index de061800f..944566a07 100644 --- a/app/scodoc/TrivialFormulator.py +++ b/app/scodoc/TrivialFormulator.py @@ -685,6 +685,11 @@ class TF(object): '' % (field, values[field]) ) + elif input_type == "time": # JavaScript widget for date input + lem.append( + f"""""" + ) elif input_type == "text_suggest": lem.append( '\n' + f""" + + + """ ) if init_google_maps: # It may be necessary to add an API key: @@ -219,19 +224,26 @@ def sco_header( # jQuery H.append( - f""" - """ + f""" + + + """ ) # qTip if init_qtip: H.append( f""" - """ + + """ ) H.append( - f""" - """ + f""" + + + """ ) if init_google_maps: H.append( diff --git a/app/scodoc/sco_evaluation_edit.py b/app/scodoc/sco_evaluation_edit.py index 9e0c487f4..9b5c716fd 100644 --- a/app/scodoc/sco_evaluation_edit.py +++ b/app/scodoc/sco_evaluation_edit.py @@ -178,9 +178,7 @@ def evaluation_create_form( { "title": "Heure de début", "explanation": "heure du début de l'épreuve", - "input_type": "menu", - "allowed_values": heures, - "labels": heures, + "input_type": "time", }, ), ( @@ -188,9 +186,7 @@ def evaluation_create_form( { "title": "Heure de fin", "explanation": "heure de fin de l'épreuve", - "input_type": "menu", - "allowed_values": heures, - "labels": heures, + "input_type": "time", }, ), ] @@ -335,6 +331,7 @@ def evaluation_create_form( + "\n" + tf[1] + render_template("scodoc/help/evaluations.j2", is_apc=is_apc) + + render_template("sco_timepicker.j2") + html_sco_header.sco_footer() ) elif tf[0] == -1: diff --git a/app/scodoc/sco_moduleimpl_status.py b/app/scodoc/sco_moduleimpl_status.py index d3f83c287..5f01a3bfd 100644 --- a/app/scodoc/sco_moduleimpl_status.py +++ b/app/scodoc/sco_moduleimpl_status.py @@ -167,6 +167,7 @@ def _ue_coefs_html(coefs_lst) -> str: {'background-color: ' + ue.color + ';' if ue.color else ''} ">
{coef}
{ue.acronyme}""" for ue, coef in coefs_lst + if coef > 0 ] ) + "" diff --git a/app/templates/assiduites/pages/ajout_assiduite_etud.j2 b/app/templates/assiduites/pages/ajout_assiduite_etud.j2 index cdc3dc7c3..260ba5e45 100644 --- a/app/templates/assiduites/pages/ajout_assiduite_etud.j2 +++ b/app/templates/assiduites/pages/ajout_assiduite_etud.j2 @@ -6,7 +6,6 @@ {% block styles %} {{super()}} - {% endblock %} @@ -114,19 +113,7 @@ div.submit > input { {% block scripts %} {{ super() }} - - +{% include "sco_timepicker.j2" %} {% endblock scripts %} diff --git a/app/templates/assiduites/pages/ajout_assiduites.j2 b/app/templates/assiduites/pages/ajout_assiduites.j2 index 9326d9307..85b7697ad 100644 --- a/app/templates/assiduites/pages/ajout_assiduites.j2 +++ b/app/templates/assiduites/pages/ajout_assiduites.j2 @@ -97,19 +97,8 @@ color: var(--color-error); } +{% include "sco_timepicker.j2" %} - +{% include "sco_timepicker.j2" %} -{% endblock scripts %} \ No newline at end of file diff --git a/app/templates/sco_page.j2 b/app/templates/sco_page.j2 index 67ab61b37..f2bc9425b 100644 --- a/app/templates/sco_page.j2 +++ b/app/templates/sco_page.j2 @@ -5,6 +5,8 @@ {{super()}} + @@ -45,6 +47,7 @@ + diff --git a/app/templates/sco_timepicker.j2 b/app/templates/sco_timepicker.j2 new file mode 100644 index 000000000..de0e0123e --- /dev/null +++ b/app/templates/sco_timepicker.j2 @@ -0,0 +1,12 @@ +