Exemplo n.º 1
0
 def collections(self, request, collection_type=None):
     filters = request.GET.dict()
     if collection_type is not None:
         qs = Collection.public.filter(collection_type=collection_type)
     else:
         qs = Collection.public.all()
     filterset = CollectionFilterSetWithFallback(filters, queryset=qs)
     serializer = CollectionSerializer(filterset,
                                       context={'request': request})
     return serializer.data
Exemplo n.º 2
0
 def collections(self, request, collection_type=None, limit=1):
     filters = request.GET.dict()
     filters.setdefault('region', self.get_region(request).slug)
     if collection_type is not None:
         qs = Collection.public.filter(collection_type=collection_type)
     else:
         qs = Collection.public.all()
     qs = CollectionFilterSetWithFallback(filters, queryset=qs).qs
     serializer = CollectionSerializer(qs[:limit],
                                       context={'request': request})
     return serializer.data, getattr(qs, 'filter_fallback', None)
Exemplo n.º 3
0
 def collections(self, request, collection_type=None, limit=1):
     filters = request.GET.dict()
     region = self.get_region(request)
     if region:
         filters.setdefault('region', region.slug)
     if collection_type is not None:
         qs = Collection.public.filter(collection_type=collection_type)
     else:
         qs = Collection.public.all()
     qs = CollectionFilterSetWithFallback(filters, queryset=qs).qs
     preview_mode = filters.get('preview', False)
     serializer = CollectionSerializer(qs[:limit], many=True, context={
         'request': request,
         'view': self,
         'use-es-for-apps': not preview_mode
     })
     return serializer.data, getattr(qs, 'filter_fallback', None)