mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-11 08:43:10 +00:00
cleanup(api/2): No longer need "show_details"
This commit is contained in:
parent
7d24d56493
commit
ada810cce3
1 changed files with 2 additions and 7 deletions
|
|
@ -140,7 +140,7 @@ class BaseAPIEndpoint(GenericViewSet):
|
|||
fields = ['id', 'meta'] + fields
|
||||
|
||||
# If showing details, add the parent field
|
||||
if isinstance(self, PagesAPIEndpoint) and self.get_serializer_context().get('show_details', False):
|
||||
if isinstance(self, PagesAPIEndpoint) and self.action == 'detail_view':
|
||||
fields.insert(2, 'parent')
|
||||
|
||||
return get_serializer_class(model, fields, base=self.base_serializer_class)
|
||||
|
|
@ -149,17 +149,12 @@ class BaseAPIEndpoint(GenericViewSet):
|
|||
"""
|
||||
The serialization context differs between listing and detail views.
|
||||
"""
|
||||
context = {
|
||||
return {
|
||||
'request': self.request,
|
||||
'view': self,
|
||||
'router': self.request.wagtailapi_router
|
||||
}
|
||||
|
||||
if self.action == 'detail_view':
|
||||
context['show_details'] = True
|
||||
|
||||
return context
|
||||
|
||||
def get_renderer_context(self):
|
||||
context = super(BaseAPIEndpoint, self).get_renderer_context()
|
||||
context['indent'] = 4
|
||||
|
|
|
|||
Loading…
Reference in a new issue