Fix: edition des users sans dept
This commit is contained in:
parent
be2227f8a3
commit
e1adf93bf0
@ -152,7 +152,6 @@ def user_info(user_name, format="json"):
|
|||||||
def create_user_form(user_name=None, edit=0, all_roles=1):
|
def create_user_form(user_name=None, edit=0, all_roles=1):
|
||||||
"form. création ou edition utilisateur"
|
"form. création ou edition utilisateur"
|
||||||
auth_dept = current_user.dept
|
auth_dept = current_user.dept
|
||||||
auth_username = current_user.user_name
|
|
||||||
from_mail = current_user.email
|
from_mail = current_user.email
|
||||||
initvalues = {}
|
initvalues = {}
|
||||||
edit = int(edit)
|
edit = int(edit)
|
||||||
@ -204,7 +203,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
|
|||||||
administrable_dept_acronyms = sorted(
|
administrable_dept_acronyms = sorted(
|
||||||
set(
|
set(
|
||||||
[
|
[
|
||||||
x.dept
|
x.dept or ""
|
||||||
for x in UserRole.query.filter_by(user=current_user)
|
for x in UserRole.query.filter_by(user=current_user)
|
||||||
if x.role.has_permission(Permission.ScoUsersAdmin) and x.dept
|
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
|
r.name + "_" + (dept or "") for (r, dept) in displayed_roles
|
||||||
]
|
]
|
||||||
displayed_roles_labels = [f"{dept}: {r.name}" 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)):
|
for i in range(len(displayed_roles_strings)):
|
||||||
if displayed_roles_strings[i] not in editable_roles_strings:
|
if displayed_roles_strings[i] not in editable_roles_strings:
|
||||||
disabled_roles[i] = True
|
disabled_roles[i] = True
|
||||||
@ -375,7 +374,7 @@ def create_user_form(user_name=None, edit=0, all_roles=1):
|
|||||||
can_choose_dept = True
|
can_choose_dept = True
|
||||||
else:
|
else:
|
||||||
selectable_dept_acronyms = set(administrable_dept_acronyms)
|
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}
|
selectable_dept_acronyms |= {the_user.dept}
|
||||||
if len(selectable_dept_acronyms) > 1:
|
if len(selectable_dept_acronyms) > 1:
|
||||||
can_choose_dept = True
|
can_choose_dept = True
|
||||||
|
Loading…
Reference in New Issue
Block a user