mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 03:01:06 -03:30
Catch some errors that pop up during ActivityStream testing
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models.signals import pre_save
|
from django.db.models.signals import pre_save
|
||||||
from django.utils.functional import curry
|
from django.utils.functional import curry
|
||||||
from awx.main.models import ActivityStream
|
from awx.main.models.base import ActivityStream
|
||||||
|
|
||||||
|
|
||||||
class ActvitiyStreamMiddleware(object):
|
class ActivityStreamMiddleware(object):
|
||||||
|
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated') and request.user.is_authenticated():
|
if hasattr(request, 'user') and hasattr(request.user, 'is_authenticated') and request.user.is_authenticated():
|
||||||
|
|||||||
@@ -44,4 +44,4 @@ activity_stream_registrar.connect(JobTemplate)
|
|||||||
activity_stream_registrar.connect(Job)
|
activity_stream_registrar.connect(Job)
|
||||||
activity_stream_registrar.connect(JobHostSummary)
|
activity_stream_registrar.connect(JobHostSummary)
|
||||||
activity_stream_registrar.connect(JobEvent)
|
activity_stream_registrar.connect(JobEvent)
|
||||||
activity_stream_registrar.connect(Profile)
|
#activity_stream_registrar.connect(Profile)
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
|
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
|
from signals import activity_stream_create, activity_stream_update, activity_stream_delete, activity_stream_associate
|
||||||
|
|
||||||
|
logger = logging.getLogger('awx.main.registrar')
|
||||||
|
|
||||||
class ActivityStreamRegistrar(object):
|
class ActivityStreamRegistrar(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -15,9 +19,12 @@ class ActivityStreamRegistrar(object):
|
|||||||
post_delete.connect(activity_stream_delete, sender=model, dispatch_uid=str(self.__class__) + str(model) + "_delete")
|
post_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:
|
||||||
m2m_attr = getattr(model, m2mfield.name)
|
try:
|
||||||
m2m_changed.connect(activity_stream_associate, sender=m2m_attr.through,
|
m2m_attr = getattr(model, m2mfield.name)
|
||||||
dispatch_uid=str(self.__class__) + str(m2m_attr.through) + "_associate")
|
m2m_changed.connect(activity_stream_associate, sender=m2m_attr.through,
|
||||||
|
dispatch_uid=str(self.__class__) + str(m2m_attr.through) + "_associate")
|
||||||
|
except AttributeError:
|
||||||
|
logger.warning("Failed to attach m2m activity stream tracker on class %s attribute %s" % (model, m2mfield.name))
|
||||||
|
|
||||||
def disconnect(self, model):
|
def disconnect(self, model):
|
||||||
if model in self.models:
|
if model in self.models:
|
||||||
|
|||||||
Reference in New Issue
Block a user