mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 23:07:42 -02:30
Fixed unit test error caused by extra definition of ActivityStream model. Rearranged imports of signal handlers.
This commit is contained in:
@@ -2,7 +2,7 @@ from django.conf import settings
|
|||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.db.models.signals import pre_save, post_save
|
from django.db.models.signals import pre_save, post_save
|
||||||
from django.utils.functional import curry
|
from django.utils.functional import curry
|
||||||
from awx.main.models.activity_stream import ActivityStream
|
from awx.main.models import ActivityStream
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from awx.main.models.projects import *
|
|||||||
from awx.main.models.inventory import *
|
from awx.main.models.inventory import *
|
||||||
from awx.main.models.jobs import *
|
from awx.main.models.jobs import *
|
||||||
from awx.main.models.activity_stream 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
|
# Monkeypatch Django serializer to ignore django-taggit fields (which break
|
||||||
# the dumpdata command; see https://github.com/alex/django-taggit/issues/155).
|
# 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 signal handlers only after models have been defined.
|
||||||
import awx.main.signals
|
import awx.main.signals
|
||||||
|
|
||||||
|
from awx.main.registrar import activity_stream_registrar
|
||||||
activity_stream_registrar.connect(Organization)
|
activity_stream_registrar.connect(Organization)
|
||||||
activity_stream_registrar.connect(Inventory)
|
activity_stream_registrar.connect(Inventory)
|
||||||
activity_stream_registrar.connect(Host)
|
activity_stream_registrar.connect(Host)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ from django.db import models
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
|
__all__ = ['ActivityStream']
|
||||||
|
|
||||||
|
|
||||||
class ActivityStream(models.Model):
|
class ActivityStream(models.Model):
|
||||||
'''
|
'''
|
||||||
Model used to describe activity stream (audit) events
|
Model used to describe activity stream (audit) events
|
||||||
@@ -39,3 +42,5 @@ class ActivityStream(models.Model):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('api:activity_stream_detail', args=(self.pk,))
|
return reverse('api:activity_stream_detail', args=(self.pk,))
|
||||||
|
|
||||||
|
print ActivityStream._meta.app_label
|
||||||
@@ -370,28 +370,3 @@ class CommonTask(PrimordialModel):
|
|||||||
self.cancel_flag = True
|
self.cancel_flag = True
|
||||||
self.save(update_fields=['cancel_flag'])
|
self.save(update_fields=['cancel_flag'])
|
||||||
return self.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()
|
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ from awx.main.fields import AutoOneToOneField
|
|||||||
from awx.main.utils import encrypt_field, decrypt_field
|
from awx.main.utils import encrypt_field, decrypt_field
|
||||||
from awx.main.models.base import *
|
from awx.main.models.base import *
|
||||||
|
|
||||||
__all__ = ['Organization', 'Team', 'Permission', 'Credential', 'AuthToken']
|
__all__ = ['Organization', 'Team', 'Permission', 'Credential', 'Profile',
|
||||||
|
'AuthToken']
|
||||||
|
|
||||||
|
|
||||||
class Organization(CommonModel):
|
class Organization(CommonModel):
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
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, 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')
|
logger = logging.getLogger('awx.main.registrar')
|
||||||
|
|
||||||
@@ -11,6 +10,8 @@ class ActivityStreamRegistrar(object):
|
|||||||
self.models = []
|
self.models = []
|
||||||
|
|
||||||
def connect(self, model):
|
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))
|
#(receiver, sender=model, dispatch_uid=self._dispatch_uid(signal, model))
|
||||||
if model not in self.models:
|
if model not in self.models:
|
||||||
self.models.append(model)
|
self.models.append(model)
|
||||||
|
|||||||
Reference in New Issue
Block a user