1
0
forked from ScoDoc/ScoDoc

Fix: edition des users sans dept

This commit is contained in:
Emmanuel Viennet 2022-01-04 19:32:58 +01:00
parent be2227f8a3
commit e1adf93bf0

View File

@ -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