mirror of
https://github.com/ansible/awx.git
synced 2026-04-11 13:09:21 -02:30
avoid activity stream entries of singleton implicit role associations
This commit is contained in:
@@ -180,8 +180,16 @@ def rbac_activity_stream(instance, sender, **kwargs):
|
|||||||
elif sender.__name__ == 'Role_parents':
|
elif sender.__name__ == 'Role_parents':
|
||||||
role = kwargs['model'].objects.filter(pk__in=kwargs['pk_set']).first()
|
role = kwargs['model'].objects.filter(pk__in=kwargs['pk_set']).first()
|
||||||
# don't record implicit creation / parents
|
# don't record implicit creation / parents
|
||||||
if role is not None and role.content_type is not None:
|
if role is not None:
|
||||||
parent = role.content_type.name + "." + role.role_field
|
if role.content_type is None:
|
||||||
|
if role.is_singleton():
|
||||||
|
parent = 'singleton:' + role.singleton_name
|
||||||
|
else:
|
||||||
|
# Ill-defined role, may need additional logic in the
|
||||||
|
# case of future expansions of the RBAC system
|
||||||
|
parent = str(role.role_field)
|
||||||
|
else:
|
||||||
|
parent = role.content_type.name + "." + role.role_field
|
||||||
# Get the list of implicit parents that were defined at the class level.
|
# Get the list of implicit parents that were defined at the class level.
|
||||||
# We have to take this list from the class property to avoid including parents
|
# We have to take this list from the class property to avoid including parents
|
||||||
# that may have been added since the creation of the ImplicitRoleField
|
# that may have been added since the creation of the ImplicitRoleField
|
||||||
|
|||||||
13
awx/main/tests/functional/models/test_activity_stream.py
Normal file
13
awx/main/tests/functional/models/test_activity_stream.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
# AWX models
|
||||||
|
from awx.main.models.organization import Organization
|
||||||
|
from awx.main.models import ActivityStream
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_activity_stream_create_entries():
|
||||||
|
Organization.objects.create(name='test-organization2')
|
||||||
|
assert ActivityStream.objects.filter(organization__isnull=False).count() == 1
|
||||||
|
|
||||||
Reference in New Issue
Block a user