mirror of
https://github.com/etesync/server
synced 2024-11-22 08:48:07 +00:00
Chunk view: unify how we get the wanted collection queryset.
This commit is contained in:
parent
24cb6ed6ee
commit
0a40a04d3b
@ -165,9 +165,11 @@ class CollectionItemChunkViewSet(viewsets.ViewSet):
|
||||
serializer_class = CollectionItemChunkSerializer
|
||||
lookup_field = 'uid'
|
||||
|
||||
def get_collection_queryset(self, queryset=Collection.objects):
|
||||
return queryset.all()
|
||||
|
||||
def create(self, request, collection_uid=None, collection_item_uid=None):
|
||||
# FIXME: we are potentially not getting the correct queryset
|
||||
col = get_object_or_404(Collection.objects, uid=collection_uid)
|
||||
col = get_object_or_404(self.get_collection_queryset(), uid=collection_uid)
|
||||
col_it = get_object_or_404(col.items, uid=collection_item_uid)
|
||||
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
@ -187,7 +189,7 @@ class CollectionItemChunkViewSet(viewsets.ViewSet):
|
||||
import os
|
||||
from django.views.static import serve
|
||||
|
||||
col = get_object_or_404(Collection.objects, uid=collection_uid)
|
||||
col = get_object_or_404(self.get_collection_queryset(), uid=collection_uid)
|
||||
col_it = get_object_or_404(col.items, uid=collection_item_uid)
|
||||
chunk = get_object_or_404(col_it.chunks, uid=uid)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user