mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 00:37:37 -02:30
Add a field to the activity stream model that more closely identifies the api object type for aid in api querying
This commit is contained in:
@@ -12,7 +12,7 @@ from django.dispatch import receiver
|
||||
|
||||
# AWX
|
||||
from awx.main.models import *
|
||||
from awx.main.utils import model_instance_diff, model_to_dict
|
||||
from awx.main.utils import model_instance_diff, model_to_dict, camelcase_to_underscore
|
||||
|
||||
__all__ = []
|
||||
|
||||
@@ -178,6 +178,7 @@ def activity_stream_create(sender, instance, created, **kwargs):
|
||||
activity_entry = ActivityStream(
|
||||
operation='create',
|
||||
object1_id=instance.id,
|
||||
object1=camelcase_to_underscore(instance.__class__.__name__),
|
||||
object1_type=instance.__class__.__module__ + "." + instance.__class__.__name__,
|
||||
changes=json.dumps(model_to_dict(instance)))
|
||||
activity_entry.save()
|
||||
@@ -193,6 +194,7 @@ def activity_stream_update(sender, instance, **kwargs):
|
||||
activity_entry = ActivityStream(
|
||||
operation='update',
|
||||
object1_id=instance.id,
|
||||
object1=camelcase_to_underscore(instance.__class__.__name__),
|
||||
object1_type=instance.__class__.__module__ + "." + instance.__class__.__name__,
|
||||
changes=json.dumps(changes))
|
||||
activity_entry.save()
|
||||
@@ -202,6 +204,7 @@ def activity_stream_delete(sender, instance, **kwargs):
|
||||
activity_entry = ActivityStream(
|
||||
operation='delete',
|
||||
object1_id=instance.id,
|
||||
object1=camelcase_to_underscore(instance.__class__.__name__),
|
||||
object1_type=instance.__class__.__module__ + "." + instance.__class__.__name__)
|
||||
activity_entry.save()
|
||||
|
||||
@@ -222,8 +225,10 @@ def activity_stream_associate(sender, instance, **kwargs):
|
||||
activity_entry = ActivityStream(
|
||||
operation=action,
|
||||
object1_id=obj1_id,
|
||||
object1=camelcase_to_underscore(obj1.__class__.__name__),
|
||||
object1_type=obj1.__class__.__module__ + "." + obj1.__class__.__name__,
|
||||
object2_id=obj2_id,
|
||||
object2=camelcase_to_underscore(obj2.__name__),
|
||||
object2_type=obj2.__module__ + "." + obj2.__name__,
|
||||
object_relationship_type=obj_rel)
|
||||
activity_entry.save()
|
||||
|
||||
Reference in New Issue
Block a user