1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

avoid every-request user signals

This commit is contained in:
AlanCoding 2017-08-19 23:25:23 -04:00
parent 3957797815
commit 50ff18ba25
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -140,6 +140,9 @@ def rebuild_role_ancestor_list(reverse, model, instance, pk_set, action, **kwarg
def sync_superuser_status_to_rbac(instance, **kwargs): def sync_superuser_status_to_rbac(instance, **kwargs):
'When the is_superuser flag is changed on a user, reflect that in the membership of the System Admnistrator role' 'When the is_superuser flag is changed on a user, reflect that in the membership of the System Admnistrator role'
update_fields = kwargs.get('update_fields', None)
if update_fields and 'is_superuser' not in update_fields:
return
if instance.is_superuser: if instance.is_superuser:
Role.singleton(ROLE_SINGLETON_SYSTEM_ADMINISTRATOR).members.add(instance) Role.singleton(ROLE_SINGLETON_SYSTEM_ADMINISTRATOR).members.add(instance)
else: else:
@ -147,6 +150,8 @@ def sync_superuser_status_to_rbac(instance, **kwargs):
def create_user_role(instance, **kwargs): def create_user_role(instance, **kwargs):
if not kwargs.get('created', True):
return
try: try:
Role.objects.get( Role.objects.get(
content_type=ContentType.objects.get_for_model(instance), content_type=ContentType.objects.get_for_model(instance),