mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 21:07:39 -02:30
handle is_system_auditor case with unsaved users
This commit is contained in:
@@ -76,8 +76,12 @@ User.add_to_class('auditor_of_organizations', user_get_auditor_of_organizations)
|
||||
@property
|
||||
def user_is_system_auditor(user):
|
||||
if not hasattr(user, '_is_system_auditor'):
|
||||
user._is_system_auditor = user.roles.filter(
|
||||
singleton_name='system_auditor', role_field='system_auditor').exists()
|
||||
if user.pk:
|
||||
user._is_system_auditor = user.roles.filter(
|
||||
singleton_name='system_auditor', role_field='system_auditor').exists()
|
||||
else:
|
||||
# Odd case where user is unsaved, this should never be relied on
|
||||
user._is_system_auditor = False
|
||||
return user._is_system_auditor
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user