From 3217f43af2c5a296e7e76225dce5186a082eb027 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Mon, 15 Aug 2016 10:41:51 +1000 Subject: [PATCH] Adds abstains and averages to the reviewers scores list. --- symposion/reviews/views.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index b4dd8d99..97ccb156 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -258,23 +258,30 @@ def review_admin(request, section_slug): already_seen.add(user.pk) user.comment_count = Review.objects.filter(user=user).count() - user.total_votes = LatestVote.objects.filter(user=user).count() - user.plus_two = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.PLUS_TWO + user_votes = LatestVote.objects.filter( + user=user + ) + user.total_votes = user_votes.exclude( + vote=LatestVote.VOTES.ABSTAIN, ).count() - user.plus_one = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.PLUS_ONE + user.plus_two = user_votes.filter( + vote=LatestVote.VOTES.PLUS_TWO, ).count() - user.minus_one = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.MINUS_ONE + user.plus_one = user_votes.filter( + vote=LatestVote.VOTES.PLUS_ONE, ).count() - user.minus_two = LatestVote.objects.filter( - user=user, - vote=LatestVote.VOTES.MINUS_TWO + user.minus_one = user_votes.filter( + vote=LatestVote.VOTES.MINUS_ONE, ).count() + user.minus_two = user_votes.filter( + vote=LatestVote.VOTES.MINUS_TWO, + ).count() + user.abstain = user_votes.filter( + vote=LatestVote.VOTES.ABSTAIN, + ).count() + user.average = ( + user.plus_two + user.plus_one + user.minus_one + user.minus_two + ) / (user.total_votes * 1.0) yield user