filtration only in moderation v2

This commit is contained in:
Kirill 2020-02-04 15:50:57 +03:00
parent f3a5605111
commit 6030b438a0

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')