diff --git a/awx/main/registrar.py b/awx/main/registrar.py index c78bf22f7c..de6673fc5a 100644 --- a/awx/main/registrar.py +++ b/awx/main/registrar.py @@ -3,7 +3,7 @@ import logging -from django.db.models.signals import pre_save, post_save, post_delete, m2m_changed +from django.db.models.signals import pre_save, post_save, pre_delete, m2m_changed logger = logging.getLogger('awx.main.registrar') @@ -17,12 +17,12 @@ class ActivityStreamRegistrar(object): if not getattr(tower_settings, 'ACTIVITY_STREAM_ENABLED', True): return from awx.main.signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate - + if model not in self.models: self.models.append(model) post_save.connect(activity_stream_create, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_create") pre_save.connect(activity_stream_update, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_update") - post_delete.connect(activity_stream_delete, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_delete") + pre_delete.connect(activity_stream_delete, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_delete") for m2mfield in model._meta.many_to_many: try: @@ -36,7 +36,7 @@ class ActivityStreamRegistrar(object): if model in self.models: post_save.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_create") pre_save.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_update") - post_delete.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_delete") + pre_delete.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_delete") self.models.pop(model) diff --git a/awx/main/signals.py b/awx/main/signals.py index 9b574fea65..b404d4eb81 100644 --- a/awx/main/signals.py +++ b/awx/main/signals.py @@ -340,14 +340,10 @@ def activity_stream_update(sender, instance, **kwargs): def activity_stream_delete(sender, instance, **kwargs): if not activity_stream_enabled: return - try: - old = sender.objects.get(id=instance.id) - except sender.DoesNotExist: - return # Skip recording any inventory source directly associated with a group. if isinstance(instance, InventorySource) and instance.group: return - changes = model_instance_diff(old, instance) + changes = model_to_dict(instance) object1 = camelcase_to_underscore(instance.__class__.__name__) activity_entry = ActivityStream( operation='delete',