From ab587e7e6c3ce3baa6019ce5130d5a3681c9acca Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Thu, 6 Jun 2019 18:27:43 -0400 Subject: [PATCH] Update get_view_description to conform to changes in DRF's version related encode/django-rest-framework#5605 --- awx/api/generics.py | 31 +++++++------------------------ awx/api/swagger.py | 1 - 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/awx/api/generics.py b/awx/api/generics.py index 1ab4674b6d..5d2e38d50e 100644 --- a/awx/api/generics.py +++ b/awx/api/generics.py @@ -119,21 +119,12 @@ class LoggedLogoutView(auth_views.LogoutView): return ret -def get_view_description(cls, request, html=False): +def get_view_description(view, html=False): + '''Wrapper around REST framework get_view_description() to continue + to support our historical div. + ''' - Wrapper around REST framework get_view_description() to support - get_description() method and view_description property on a view class. - ''' - if hasattr(cls, 'get_description') and callable(cls.get_description): - desc = cls().get_description(request, html=html) - cls = type(cls.__name__, (object,), {'__doc__': desc}) - elif hasattr(cls, 'view_description'): - if callable(cls.view_description): - view_desc = cls.view_description() - else: - view_desc = cls.view_description - cls = type(cls.__name__, (object,), {'__doc__': view_desc}) - desc = views.get_view_description(cls, html=html) + desc = views.get_view_description(view, html=html) if html: desc = '
%s
' % desc return mark_safe(desc) @@ -246,14 +237,6 @@ class APIView(views.APIView): # `curl https://user:pass@tower.example.org/api/v2/job_templates/N/launch/` return 'Bearer realm=api authorization_url=/api/o/authorize/' - def get_view_description(self, html=False): - """ - Return some descriptive text for the view, as used in OPTIONS responses - and in the browsable API. - """ - func = self.settings.VIEW_DESCRIPTION_FUNCTION - return func(self.__class__, getattr(self, '_request', None), html) - def get_description_context(self): return { 'view': self, @@ -262,8 +245,8 @@ class APIView(views.APIView): 'swagger_method': getattr(self.request, 'swagger_method', None), } - def get_description(self, request, html=False): - self.request = request + @property + def description(self): template_list = [] for klass in inspect.getmro(type(self)): template_basename = camelcase_to_underscore(klass.__name__) diff --git a/awx/api/swagger.py b/awx/api/swagger.py index ae774e78f0..fd54928251 100644 --- a/awx/api/swagger.py +++ b/awx/api/swagger.py @@ -53,7 +53,6 @@ class AutoSchema(DRFAuthSchema): return link def get_description(self, path, method): - self.view._request = self.view.request setattr(self.view.request, 'swagger_method', method) description = super(AutoSchema, self).get_description(path, method) return description