diff --git a/awx/main/middleware.py b/awx/main/middleware.py index c5982d9ed1..2af11b3bf2 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, post_save from django.utils.functional import curry -from awx.main.models.activity_stream import ActivityStream +from awx.main.models import ActivityStream import json import uuid import urllib2 diff --git a/awx/main/models/__init__.py b/awx/main/models/__init__.py index 63cc7ddafa..254330c5d0 100644 --- a/awx/main/models/__init__.py +++ b/awx/main/models/__init__.py @@ -7,7 +7,6 @@ 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 # the dumpdata command; see https://github.com/alex/django-taggit/issues/155). @@ -30,6 +29,7 @@ User.add_to_class('can_access', check_user_access) # Import signal handlers only after models have been defined. import awx.main.signals +from awx.main.registrar import activity_stream_registrar activity_stream_registrar.connect(Organization) activity_stream_registrar.connect(Inventory) activity_stream_registrar.connect(Host) diff --git a/awx/main/models/activity_stream.py b/awx/main/models/activity_stream.py index 76333bd564..f47fb8deb0 100644 --- a/awx/main/models/activity_stream.py +++ b/awx/main/models/activity_stream.py @@ -6,6 +6,9 @@ from django.db import models from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +__all__ = ['ActivityStream'] + + class ActivityStream(models.Model): ''' Model used to describe activity stream (audit) events @@ -39,3 +42,5 @@ class ActivityStream(models.Model): def get_absolute_url(self): return reverse('api:activity_stream_detail', args=(self.pk,)) + +print ActivityStream._meta.app_label \ No newline at end of file diff --git a/awx/main/models/base.py b/awx/main/models/base.py index 8c36e1516f..8304144f50 100644 --- a/awx/main/models/base.py +++ b/awx/main/models/base.py @@ -370,28 +370,3 @@ class CommonTask(PrimordialModel): self.cancel_flag = True self.save(update_fields=['cancel_flag']) return self.cancel_flag - -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/organization.py b/awx/main/models/organization.py index 903474401f..5b1c37bd8d 100644 --- a/awx/main/models/organization.py +++ b/awx/main/models/organization.py @@ -33,7 +33,8 @@ from awx.main.fields import AutoOneToOneField from awx.main.utils import encrypt_field, decrypt_field from awx.main.models.base import * -__all__ = ['Organization', 'Team', 'Permission', 'Credential', 'AuthToken'] +__all__ = ['Organization', 'Team', 'Permission', 'Credential', 'Profile', + 'AuthToken'] class Organization(CommonModel): diff --git a/awx/main/registrar.py b/awx/main/registrar.py index c339c17116..137759dd56 100644 --- a/awx/main/registrar.py +++ b/awx/main/registrar.py @@ -1,7 +1,6 @@ import logging from django.db.models.signals import pre_save, post_save, post_delete, m2m_changed -from signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate logger = logging.getLogger('awx.main.registrar') @@ -11,6 +10,8 @@ class ActivityStreamRegistrar(object): self.models = [] def connect(self, model): + from awx.main.signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate + #(receiver, sender=model, dispatch_uid=self._dispatch_uid(signal, model)) if model not in self.models: self.models.append(model)