Only rebuild ancestor list on post_* events

This commit is contained in:
Akita Noek
2016-04-18 08:53:40 -04:00
parent 2a676d80ce
commit 6d8bab97df

View File

@@ -106,13 +106,14 @@ def emit_update_inventory_on_created_or_deleted(sender, **kwargs):
if inventory is not None: if inventory is not None:
update_inventory_computed_fields.delay(inventory.id, True) update_inventory_computed_fields.delay(inventory.id, True)
def rebuild_role_ancestor_list(reverse, model, instance, pk_set, **kwargs): def rebuild_role_ancestor_list(reverse, model, instance, pk_set, action, **kwargs):
'When a role parent is added or removed, update our role hierarchy list' 'When a role parent is added or removed, update our role hierarchy list'
if reverse: if action in ['post_add', 'post_remove', 'post_clear']:
for id in pk_set: if reverse:
model.objects.get(id=id).rebuild_role_ancestor_list() for id in pk_set:
else: model.objects.get(id=id).rebuild_role_ancestor_list()
instance.rebuild_role_ancestor_list() else:
instance.rebuild_role_ancestor_list()
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'