mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Fixing issue when Role is not associated with a Resource (generally never)
This commit is contained in:
@@ -397,16 +397,18 @@ def activity_stream_associate(sender, instance, **kwargs):
|
|||||||
activity_entry.save()
|
activity_entry.save()
|
||||||
getattr(activity_entry, object1).add(obj1)
|
getattr(activity_entry, object1).add(obj1)
|
||||||
getattr(activity_entry, object2).add(obj2_actual)
|
getattr(activity_entry, object2).add(obj2_actual)
|
||||||
|
|
||||||
# Record the role for RBAC changes
|
# Record the role for RBAC changes
|
||||||
if 'role' in kwargs:
|
if 'role' in kwargs:
|
||||||
role = kwargs['role']
|
role = kwargs['role']
|
||||||
obj_rel = '.'.join([role.content_object.__module__,
|
if role.content_object is not None:
|
||||||
role.content_object.__class__.__name__,
|
obj_rel = '.'.join([role.content_object.__module__,
|
||||||
role.role_field])
|
role.content_object.__class__.__name__,
|
||||||
|
role.role_field])
|
||||||
|
|
||||||
# If the m2m is from the User side we need to
|
# If the m2m is from the User side we need to
|
||||||
# set the content_object of the Role for our entry.
|
# set the content_object of the Role for our entry.
|
||||||
if type(instance) == User:
|
if type(instance) == User and role.content_object is not None:
|
||||||
getattr(activity_entry, role.content_type.name).add(role.content_object)
|
getattr(activity_entry, role.content_type.name).add(role.content_object)
|
||||||
|
|
||||||
activity_entry.role.add(role)
|
activity_entry.role.add(role)
|
||||||
|
|||||||
Reference in New Issue
Block a user