Merge branch 'bug-published_comments_not_displayed_v2' into 'develop'

published_comments_not_displayed

See merge request gm/gm-backend!260
This commit is contained in:
Олег Хаятов 2020-02-04 12:13:44 +00:00
commit 9982c2ca77

View File

@ -17,7 +17,7 @@ class CommentLstView(generics.ListCreateAPIView):
"establishment": Establishment.__name__.lower()
}
qs = models.Comment.objects.with_base_related().filter(status=models.Comment.WAITING)
qs = models.Comment.objects.with_base_related()
if "object" in self.kwargs:
qs = qs.by_object_id(self.kwargs["object"])
@ -25,6 +25,8 @@ class CommentLstView(generics.ListCreateAPIView):
if "type" in self.kwargs and self.kwargs["type"] in allowed:
model = allowed[self.kwargs["type"]]
qs = qs.by_content_type(self.kwargs["type"], model)
if self.kwargs["type"] == allowed["establishment"] and "object" not in self.kwargs:
qs = qs.filter(status=models.Comment.WAITING)
return qs.order_by('-created')