Fixing issue when Role is not associated with a Resource (generally never)

This commit is contained in:
Wayne Witzel III 2016-05-03 13:32:40 -04:00
parent f60ce147f4
commit 65f71ba2ab

View File

@ -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)