From 24cb6ed6ee9d7931503f18352819313931739274 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 20 Feb 2020 16:35:20 +0200 Subject: [PATCH] Also serve an item's snapshots. --- django_etesync/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/django_etesync/views.py b/django_etesync/views.py index 9d816ec..f44f79a 100644 --- a/django_etesync/views.py +++ b/django_etesync/views.py @@ -34,6 +34,8 @@ from .serializers import ( CollectionSerializer, CollectionItemSerializer, CollectionItemInlineSerializer, + CollectionItemSnapshotSerializer, + CollectionItemSnapshotInlineSerializer, CollectionItemChunkSerializer ) @@ -146,6 +148,14 @@ class CollectionItemViewSet(BaseViewSet): # FIXME: implement, or should it be implemented elsewhere? return Response(status=status.HTTP_405_METHOD_NOT_ALLOWED) + @action_decorator(detail=True, methods=['GET']) + def snapshots(self, request, collection_uid=None, uid=None): + col = get_object_or_404(Collection.objects, uid=collection_uid) + col_it = get_object_or_404(col.items, uid=uid) + + serializer = CollectionItemSnapshotSerializer(col_it.snapshots, many=True) + return Response(serializer.data) + class CollectionItemChunkViewSet(viewsets.ViewSet): allowed_methods = ['GET', 'POST']