From e1adf93bf0d2edfccf0779041f460f7a4bc5978c Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 4 Jan 2022 19:32:58 +0100 Subject: [PATCH] Fix: edition des users sans dept --- app/views/users.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/users.py b/app/views/users.py index fee36edf2..21c992fda 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -152,7 +152,6 @@ def user_info(user_name, format="json"): def create_user_form(user_name=None, edit=0, all_roles=1): "form. création ou edition utilisateur" auth_dept = current_user.dept - auth_username = current_user.user_name from_mail = current_user.email initvalues = {} edit = int(edit) @@ -204,7 +203,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1): administrable_dept_acronyms = sorted( set( [ - x.dept + x.dept or "" for x in UserRole.query.filter_by(user=current_user) if x.role.has_permission(Permission.ScoUsersAdmin) and x.dept ] @@ -249,7 +248,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1): r.name + "_" + (dept or "") for (r, dept) in displayed_roles ] displayed_roles_labels = [f"{dept}: {r.name}" for (r, dept) in displayed_roles] - disabled_roles = {} # pour desactiver les roles que l'on ne peut pas editer + disabled_roles = {} # pour désactiver les roles que l'on ne peut pas éditer for i in range(len(displayed_roles_strings)): if displayed_roles_strings[i] not in editable_roles_strings: disabled_roles[i] = True @@ -375,7 +374,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1): can_choose_dept = True else: selectable_dept_acronyms = set(administrable_dept_acronyms) - if edit: # ajoute dept actuel de l'utilisateur + if edit and the_user.dept is not None: # ajoute dept actuel de l'utilisateur selectable_dept_acronyms |= {the_user.dept} if len(selectable_dept_acronyms) > 1: can_choose_dept = True