mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Merge pull request #1723 from anoek/activity-stream-delete-fix
Fixed and updated activity stream delete operations
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import logging
|
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')
|
logger = logging.getLogger('awx.main.registrar')
|
||||||
|
|
||||||
@@ -17,12 +17,12 @@ class ActivityStreamRegistrar(object):
|
|||||||
if not getattr(tower_settings, 'ACTIVITY_STREAM_ENABLED', True):
|
if not getattr(tower_settings, 'ACTIVITY_STREAM_ENABLED', True):
|
||||||
return
|
return
|
||||||
from awx.main.signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate
|
from awx.main.signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate
|
||||||
|
|
||||||
if model not in self.models:
|
if model not in self.models:
|
||||||
self.models.append(model)
|
self.models.append(model)
|
||||||
post_save.connect(activity_stream_create, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_create")
|
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")
|
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:
|
for m2mfield in model._meta.many_to_many:
|
||||||
try:
|
try:
|
||||||
@@ -36,7 +36,7 @@ class ActivityStreamRegistrar(object):
|
|||||||
if model in self.models:
|
if model in self.models:
|
||||||
post_save.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_create")
|
post_save.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_create")
|
||||||
pre_save.disconnect(dispatch_uid=str(self.__class__) + str(model) + "_update")
|
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)
|
self.models.pop(model)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -340,14 +340,10 @@ def activity_stream_update(sender, instance, **kwargs):
|
|||||||
def activity_stream_delete(sender, instance, **kwargs):
|
def activity_stream_delete(sender, instance, **kwargs):
|
||||||
if not activity_stream_enabled:
|
if not activity_stream_enabled:
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
old = sender.objects.get(id=instance.id)
|
|
||||||
except sender.DoesNotExist:
|
|
||||||
return
|
|
||||||
# Skip recording any inventory source directly associated with a group.
|
# Skip recording any inventory source directly associated with a group.
|
||||||
if isinstance(instance, InventorySource) and instance.group:
|
if isinstance(instance, InventorySource) and instance.group:
|
||||||
return
|
return
|
||||||
changes = model_instance_diff(old, instance)
|
changes = model_to_dict(instance)
|
||||||
object1 = camelcase_to_underscore(instance.__class__.__name__)
|
object1 = camelcase_to_underscore(instance.__class__.__name__)
|
||||||
activity_entry = ActivityStream(
|
activity_entry = ActivityStream(
|
||||||
operation='delete',
|
operation='delete',
|
||||||
|
|||||||
Reference in New Issue
Block a user