kopia lustrzana https://github.com/wagtail/wagtail
cleanup(api/2): No longer need "show_details"
rodzic
7d24d56493
commit
ada810cce3
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue