From 65f71ba2ab37512c375fb17144497dfb47d957b2 Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Tue, 3 May 2016 13:32:40 -0400 Subject: [PATCH] Fixing issue when Role is not associated with a Resource (generally never) --- awx/main/signals.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/awx/main/signals.py b/awx/main/signals.py index 4f88f5e559..799a70f372 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -397,16 +397,18 @@ def activity_stream_associate(sender, instance, **kwargs): activity_entry.save() getattr(activity_entry, object1).add(obj1) getattr(activity_entry, object2).add(obj2_actual) + # Record the role for RBAC changes if 'role' in kwargs: role = kwargs['role'] - obj_rel = '.'.join([role.content_object.__module__, - role.content_object.__class__.__name__, - role.role_field]) + if role.content_object is not None: + obj_rel = '.'.join([role.content_object.__module__, + role.content_object.__class__.__name__, + role.role_field]) # If the m2m is from the User side we need to # 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) activity_entry.role.add(role)