summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--awx/api/generics.py9
-rw-r--r--awx/main/middleware.py3
2 files changed, 12 insertions, 0 deletions
diff --git a/awx/api/generics.py b/awx/api/generics.py
index 54bbdea2cc..e48c6aa6fa 100644
--- a/awx/api/generics.py
+++ b/awx/api/generics.py
@@ -70,6 +70,15 @@ def get_view_description(cls, html=False):
class APIView(views.APIView):
+ def initialize_request(self, request, *args, **kwargs):
+ '''
+ Store the Django REST Framework Request object as an attribute on the
+ normal Django request.
+ '''
+ drf_request = super(APIView, self).initialize_request(request, *args, **kwargs)
+ request.drf_request = drf_request
+ return drf_request
+
def get_authenticate_header(self, request):
"""
Determine the WWW-Authenticate header to use for 401 responses. Try to
diff --git a/awx/main/middleware.py b/awx/main/middleware.py
index 858f68d60a..9306213ba0 100644
--- a/awx/main/middleware.py
+++ b/awx/main/middleware.py
@@ -24,6 +24,9 @@ class ActivityStreamMiddleware(object):
post_save.connect(set_actor, sender=ActivityStream, dispatch_uid=self.disp_uid, weak=False)
def process_response(self, request, response):
+ drf_request = getattr(request, 'drf_request', None)
+ drf_user = getattr(drf_request, 'user', None)
+ # FIXME: Associate the user above from Django REST framework with instances.
post_save.disconnect(dispatch_uid=self.disp_uid)
self.finished = True
if self.isActivityStreamEvent: