From 598925047176729e11fc7fb2cf21b0710a176fa4 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Fri, 8 Nov 2013 11:16:04 -0500 Subject: [PATCH] Move ActivityStream to it's own model file --- awx/main/middleware.py | 2 +- awx/main/models/__init__.py | 1 + awx/main/models/activity_stream.py | 30 ++++++++++++++++++++++++++++++ awx/main/models/base.py | 2 +- 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 awx/main/models/activity_stream.py diff --git a/awx/main/middleware.py b/awx/main/middleware.py index 3ac7e059fd..2426d58790 100644 --- a/awx/main/middleware.py +++ b/awx/main/middleware.py @@ -2,7 +2,7 @@ from django.conf import settings from django.contrib.auth.models import User from django.db.models.signals import pre_save from django.utils.functional import curry -from awx.main.models.base import ActivityStream +from awx.main.models.activity_stream import ActivityStream class ActivityStreamMiddleware(object): diff --git a/awx/main/models/__init__.py b/awx/main/models/__init__.py index 150741c440..63cc7ddafa 100644 --- a/awx/main/models/__init__.py +++ b/awx/main/models/__init__.py @@ -6,6 +6,7 @@ from awx.main.models.organization import * from awx.main.models.projects import * from awx.main.models.inventory import * from awx.main.models.jobs import * +from awx.main.models.activity_stream import * from awx.main.registrar import activity_stream_registrar # Monkeypatch Django serializer to ignore django-taggit fields (which break diff --git a/awx/main/models/activity_stream.py b/awx/main/models/activity_stream.py new file mode 100644 index 0000000000..57cbff7b73 --- /dev/null +++ b/awx/main/models/activity_stream.py @@ -0,0 +1,30 @@ +# Copyright (c) 2013 AnsibleWorks, Inc. +# All Rights Reserved. + + +from django.db import models + +class ActivityStream(models.Model): + ''' + Model used to describe activity stream (audit) events + ''' + OPERATION_CHOICES = [ + ('create', _('Entity Created')), + ('update', _("Entity Updated")), + ('delete', _("Entity Deleted")), + ('associate', _("Entity Associated with another Entity")), + ('disaassociate', _("Entity was Disassociated with another Entity")) + ] + + user = models.ForeignKey('auth.User', null=True, on_delete=models.SET_NULL) + operation = models.CharField(max_length=9, choices=OPERATION_CHOICES) + timestamp = models.DateTimeField(auto_now_add=True) + changes = models.TextField(blank=True) + + object1_id = models.PositiveIntegerField(db_index=True) + object1_type = models.TextField() + + object2_id = models.PositiveIntegerField(db_index=True) + object2_type = models.TextField() + + object_relationship_type = models.TextField() diff --git a/awx/main/models/base.py b/awx/main/models/base.py index 99c530004d..53fc46326d 100644 --- a/awx/main/models/base.py +++ b/awx/main/models/base.py @@ -22,7 +22,7 @@ from taggit.managers import TaggableManager # Django-Celery from djcelery.models import TaskMeta -__all__ = ['VarsDictProperty', 'PrimordialModel', 'CommonModel', 'ActivityStream', +__all__ = ['VarsDictProperty', 'PrimordialModel', 'CommonModel', 'CommonModelNameNotUnique', 'CommonTask', 'PERM_INVENTORY_ADMIN', 'PERM_INVENTORY_READ', 'PERM_INVENTORY_WRITE', 'PERM_INVENTORY_DEPLOY', 'PERM_INVENTORY_CHECK', 'JOB_TYPE_CHOICES',