small refactoring
This commit is contained in:
parent
8af8cf92e9
commit
f1fa8a58de
|
|
@ -114,10 +114,7 @@ class EstablishmentCommentListView(generics.ListAPIView):
|
|||
"""Override get_queryset method"""
|
||||
|
||||
establishment = get_object_or_404(models.Establishment, slug=self.kwargs['slug'])
|
||||
return comment_models.Comment.objects.by_content_type(app_label='establishment',
|
||||
model='establishment') \
|
||||
.by_object_id(object_id=establishment.pk) \
|
||||
.order_by('-created')
|
||||
return establishment.comments.order_by('-created')
|
||||
|
||||
|
||||
class EstablishmentCommentRUDView(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
|
|
|||
|
|
@ -60,10 +60,7 @@ class ProductCommentListView(generics.ListAPIView):
|
|||
def get_queryset(self):
|
||||
"""Override get_queryset method"""
|
||||
product = get_object_or_404(Product, slug=self.kwargs['slug'])
|
||||
return Comment.objects.by_content_type(app_label='product',
|
||||
model='product') \
|
||||
.by_object_id(object_id=product.pk) \
|
||||
.order_by('-created')
|
||||
return product.comments.order_by('-created')
|
||||
|
||||
|
||||
class ProductCommentRUDView(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user