mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 20:07:37 -02:30
Update get_view_description to conform to changes in DRF's version
related encode/django-rest-framework#5605
This commit is contained in:
@@ -119,21 +119,12 @@ class LoggedLogoutView(auth_views.LogoutView):
|
|||||||
return ret
|
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
|
desc = views.get_view_description(view, html=html)
|
||||||
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)
|
|
||||||
if html:
|
if html:
|
||||||
desc = '<div class="description">%s</div>' % desc
|
desc = '<div class="description">%s</div>' % desc
|
||||||
return mark_safe(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/`
|
# `curl https://user:pass@tower.example.org/api/v2/job_templates/N/launch/`
|
||||||
return 'Bearer realm=api authorization_url=/api/o/authorize/'
|
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):
|
def get_description_context(self):
|
||||||
return {
|
return {
|
||||||
'view': self,
|
'view': self,
|
||||||
@@ -262,8 +245,8 @@ class APIView(views.APIView):
|
|||||||
'swagger_method': getattr(self.request, 'swagger_method', None),
|
'swagger_method': getattr(self.request, 'swagger_method', None),
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_description(self, request, html=False):
|
@property
|
||||||
self.request = request
|
def description(self):
|
||||||
template_list = []
|
template_list = []
|
||||||
for klass in inspect.getmro(type(self)):
|
for klass in inspect.getmro(type(self)):
|
||||||
template_basename = camelcase_to_underscore(klass.__name__)
|
template_basename = camelcase_to_underscore(klass.__name__)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ class AutoSchema(DRFAuthSchema):
|
|||||||
return link
|
return link
|
||||||
|
|
||||||
def get_description(self, path, method):
|
def get_description(self, path, method):
|
||||||
self.view._request = self.view.request
|
|
||||||
setattr(self.view.request, 'swagger_method', method)
|
setattr(self.view.request, 'swagger_method', method)
|
||||||
description = super(AutoSchema, self).get_description(path, method)
|
description = super(AutoSchema, self).get_description(path, method)
|
||||||
return description
|
return description
|
||||||
|
|||||||
Reference in New Issue
Block a user