move comments filtration from model to view

This commit is contained in:
Kirill 2020-02-03 10:46:44 +03:00
parent 2dc1674f81
commit 8d8a5f50fb
2 changed files with 5 additions and 2 deletions

View File

@ -17,7 +17,7 @@ class CommentLstView(generics.ListCreateAPIView):
"establishment": Establishment.__name__.lower()
}
qs = models.Comment.objects.with_base_related()
qs = models.Comment.objects.with_base_related().filter(status=models.Comment.WAITING)
if "object" in self.kwargs:
qs = qs.by_object_id(self.kwargs["object"])

View File

@ -52,7 +52,10 @@ def parse_cookies(get_response):
# processing country country cookie
country_code = get_country_code(cookie_dict)
request.country_code = country_code
if country_code and country_code != 'None':
request.country_code = country_code
else:
request.country_code = None
response = get_response(request)
return response