fix product in_fav
This commit is contained in:
parent
0dbb2c64cd
commit
4d302395a9
|
|
@ -10,14 +10,15 @@ from comment.serializers import CommentRUDSerializer
|
||||||
|
|
||||||
class ProductBaseView(generics.GenericAPIView):
|
class ProductBaseView(generics.GenericAPIView):
|
||||||
"""Product base view"""
|
"""Product base view"""
|
||||||
permission_classes = (permissions.AllowAny, )
|
permission_classes = (permissions.AllowAny,)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""Override get_queryset method."""
|
"""Override get_queryset method."""
|
||||||
return Product.objects.published() \
|
return Product.objects.published() \
|
||||||
.with_base_related() \
|
.with_base_related() \
|
||||||
.by_country_code(self.request.country_code) \
|
.annotate_in_favorites(self.request.user) \
|
||||||
.order_by('-created')
|
.by_country_code(self.request.country_code) \
|
||||||
|
.order_by('-created')
|
||||||
|
|
||||||
|
|
||||||
class ProductListView(ProductBaseView, generics.ListAPIView):
|
class ProductListView(ProductBaseView, generics.ListAPIView):
|
||||||
|
|
@ -67,9 +68,9 @@ class ProductCommentListView(generics.ListAPIView):
|
||||||
"""Override get_queryset method"""
|
"""Override get_queryset method"""
|
||||||
product = get_object_or_404(Product, slug=self.kwargs['slug'])
|
product = get_object_or_404(Product, slug=self.kwargs['slug'])
|
||||||
return Comment.objects.by_content_type(app_label='product',
|
return Comment.objects.by_content_type(app_label='product',
|
||||||
model='product')\
|
model='product') \
|
||||||
.by_object_id(object_id=product.pk)\
|
.by_object_id(object_id=product.pk) \
|
||||||
.order_by('-created')
|
.order_by('-created')
|
||||||
|
|
||||||
|
|
||||||
class ProductCommentRUDView(generics.RetrieveUpdateDestroyAPIView):
|
class ProductCommentRUDView(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user