Collection update: support limiting vs not limiting based on stoken.

This commit is contained in:
Tom Hacohen
2020-05-31 13:29:03 +03:00
parent 64b947d455
commit 9347682997
2 changed files with 8 additions and 5 deletions

View File

@@ -163,6 +163,13 @@ class CollectionViewSet(BaseViewSet):
def update(self, request, *args, **kwargs):
instance = self.get_object()
stoken = request.GET.get('stoken', None)
if stoken is not None and stoken != instance.stoken:
content = {'code': 'stale_stoken', 'detail': 'Stoken is too old'}
return Response(content, status=status.HTTP_400_BAD_REQUEST)
serializer = self.get_serializer(instance, data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_update(serializer)