mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -03:30
Merge pull request #3985 from AlanCoding/auditor_optimization
System auditor optimization via cache
This commit is contained in:
@@ -74,7 +74,9 @@ User.add_to_class('auditor_of_organizations', user_get_auditor_of_organizations)
|
||||
|
||||
@property
|
||||
def user_is_system_auditor(user):
|
||||
return Role.singleton('system_auditor').members.filter(id=user.id).exists()
|
||||
if not hasattr(user, '_is_system_auditor'):
|
||||
user._is_system_auditor = Role.objects.filter(role_field='system_auditor', id=user.id).exists()
|
||||
return user._is_system_auditor
|
||||
|
||||
|
||||
@user_is_system_auditor.setter
|
||||
@@ -82,8 +84,10 @@ def user_is_system_auditor(user, tf):
|
||||
if user.id:
|
||||
if tf:
|
||||
Role.singleton('system_auditor').members.add(user)
|
||||
user._is_system_auditor = True
|
||||
else:
|
||||
Role.singleton('system_auditor').members.remove(user)
|
||||
user._is_system_auditor = False
|
||||
|
||||
|
||||
User.add_to_class('is_system_auditor', user_is_system_auditor)
|
||||
|
||||
Reference in New Issue
Block a user