From b38ee4ea25b0e7a6d61c1188bb6073d760803732 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 7 Oct 2021 23:00:02 +0200 Subject: [PATCH] Fix: create user avec date exp. --- app/views/users.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/views/users.py b/app/views/users.py index df02f43b..aa72d5ed 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -400,6 +400,18 @@ def create_user_form(user_name=None, edit=0, all_roles=1): return "\n".join(H) + "\n" + tf[1] + F + if "date_expiration" in vals: + try: + if vals["date_expiration"]: + vals["date_expiration"] = datetime.datetime.strptime( + vals["date_expiration"], "%d/%m/%Y" + ) + else: + vals["date_expiration"] = None + except ValueError: + H.append(tf_error_message("date expiration invalide")) + return "\n".join(H) + "\n" + tf[1] + F + if edit: # modif utilisateur (mais pas password ni user_name !) if (not can_choose_dept) and "dept" in vals: del vals["dept"] @@ -411,17 +423,6 @@ def create_user_form(user_name=None, edit=0, all_roles=1): del vals["user_name"] if (current_user.user_name == user_name) and "status" in vals: del vals["status"] # no one can't change its own status - if "date_expiration" in vals: - try: - if vals["date_expiration"]: - vals["date_expiration"] = datetime.datetime.strptime( - vals["date_expiration"], "%d/%m/%Y" - ) - else: - vals["date_expiration"] = None - except ValueError: - H.append(tf_error_message("date expiration invalide")) - return "\n".join(H) + "\n" + tf[1] + F if "status" in vals: vals["active"] = vals["status"] == "" # traitement des roles: ne doit pas affecter les roles