Skip to content
Snippets Groups Projects
Commit 1b7fbdb3 authored by Jean-Baptiste's avatar Jean-Baptiste
Browse files

update: fix default depth to 0 and fix auto_author

parent 55ccaef4
No related branches found
No related tags found
No related merge requests found
Pipeline #1021 passed
......@@ -94,7 +94,6 @@ class LDPViewSet(LDPViewSetGenerator):
"""An automatically generated viewset that serves models following the Linked Data Platform convention"""
fields = None
exclude = None
depth = 1
renderer_classes = (JSONLDRenderer,)
parser_classes = (JSONLDParser,)
authentication_classes = (NoCSRFAuthentication,)
......@@ -114,7 +113,7 @@ class LDPViewSet(LDPViewSetGenerator):
lookup_field = get_resolver().reverse_dict[model_name + '-detail'][0][0][1][0]
meta_args = {'model': self.model, 'extra_kwargs': {
'@id': {'lookup_field': lookup_field}},
'depth': self.depth,
'depth': getattr(self, 'depth', Model.get_meta(self.model, 'depth', 0)),
'extra_fields': self.nested_fields}
return self.build_serializer(meta_args, 'Read')
......@@ -143,6 +142,20 @@ class LDPViewSet(LDPViewSetGenerator):
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)
def update(self, request, *args, **kwargs):
partial = kwargs.pop('partial', False)
instance = self.get_object()
serializer = self.get_write_serializer(instance, data=request.data, partial=partial)
serializer.is_valid(raise_exception=True)
self.perform_update(serializer)
if getattr(instance, '_prefetched_objects_cache', None):
# If 'prefetch_related' has been applied to a queryset, we need to
# forcibly invalidate the prefetch cache on the instance.
instance._prefetched_objects_cache = {}
return Response(serializer.data)
def get_write_serializer(self, *args, **kwargs):
"""
Return the serializer instance that should be used for validating and
......@@ -201,10 +214,6 @@ class LDPViewSet(LDPViewSetGenerator):
pass
return response
def update(self, request, *args, **kwargs):
response = super().update(request, *args, **kwargs)
return response
class LDPNestedViewSet(LDPViewSet):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment