Merge branch 'bug-published_comments_not_displayed_v2' into 'develop'

filtration only in moderation v2

See merge request gm/gm-backend!261
This commit is contained in:
Олег Хаятов 2020-02-04 12:53:50 +00:00
commit 6bf5b2a75b

View File

@ -19,14 +19,15 @@ class CommentLstView(generics.ListCreateAPIView):
qs = models.Comment.objects.with_base_related()
if "object" not in self.kwargs and "type" not in self.kwargs:
qs = qs.filter(status=models.Comment.WAITING)
if "object" in self.kwargs:
qs = qs.by_object_id(self.kwargs["object"])
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')