Commit 2a9a9a99 authored by cynddl's avatar cynddl

Fix broken calls to voting fields

parent 47231fb7
......@@ -30,11 +30,11 @@ class ArticleViewSet(viewsets.ModelViewSet):
@detail_route(methods=["post"], url_path="upvote")
def upvote(self, request, pk=None):
article = self.get_object()
article.upvote(username=request.user.username)
article.upvote(request.user)
return self.response_serialized_object(article)
@detail_route(methods=["post"], url_path="downvote")
def downvote(self, request, pk=None):
article = self.get_object()
article.downvote(username=request.user.username)
article.downvote(request.user)
return self.response_serialized_object(article)
......@@ -12,7 +12,10 @@ class ArticleListFlux(UDList):
if filter_view == "published":
qs = Article.objects.filter(status="PUBLISHED")
elif filter_view == "draft":
qs = Article.objects.filter(und_score__gte=3, status="PENDING")
qs = Article.objects.extra(where=[
"und_score_up + und_score_down >= 3",
"status='PENDING'"
])
elif filter_view == "rejected":
qs = Article.objects.filter(status="REJECTED")
else:
......@@ -23,6 +26,8 @@ class ArticleListFlux(UDList):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["filter_view"] = self.kwargs.get("filter_view", "draft")
context["nb_draft"] = Article.objects.filter(
und_score__gte=3, status="PENDING").count()
context["nb_draft"] = Article.objects.extra(where=[
"und_score_up + und_score_down >= 3",
"status='PENDING'"
]).count()
return context
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment