Fix an activity stream associate with deleted obj

In some scenarios the activity stream associate could be invoked where
obj2 doesn't exist... the .get() will fail and tank the caller
preventing the save.   This guards that and blocks the activity stream
event, saving the save (whew!)
This commit is contained in:
Matthew Jones 2016-07-08 12:54:42 -04:00
parent 52997ae0ac
commit 4c7f54cf72

View File

@ -410,7 +410,10 @@ def activity_stream_associate(sender, instance, **kwargs):
for entity_acted in kwargs['pk_set']:
obj2 = kwargs['model']
obj2_id = entity_acted
obj2_actual = obj2.objects.get(id=obj2_id)
obj2_actual = obj2.objects.filter(id=obj2_id)
if not obj2_actual.exists():
continue
obj2_actual = obj2_actual[0]
if isinstance(obj2_actual, Role) and obj2_actual.content_object is not None:
obj2_actual = obj2_actual.content_object
object2 = camelcase_to_underscore(obj2_actual.__class__.__name__)