1
0
forked from ScoDoc/ScoDoc

Fix: create user avec date exp.

This commit is contained in:
Emmanuel Viennet 2021-10-07 23:00:02 +02:00
parent 47f1497e5e
commit b38ee4ea25

View File

@ -400,6 +400,18 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
return "\n".join(H) + "\n" + tf[1] + F 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 edit: # modif utilisateur (mais pas password ni user_name !)
if (not can_choose_dept) and "dept" in vals: if (not can_choose_dept) and "dept" in vals:
del vals["dept"] del vals["dept"]
@ -411,17 +423,6 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
del vals["user_name"] del vals["user_name"]
if (current_user.user_name == user_name) and "status" in vals: if (current_user.user_name == user_name) and "status" in vals:
del vals["status"] # no one can't change its own status 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: if "status" in vals:
vals["active"] = vals["status"] == "" vals["active"] = vals["status"] == ""
# traitement des roles: ne doit pas affecter les roles # traitement des roles: ne doit pas affecter les roles