From be4404c60283672b343eeedbd55356d67fcce4f9 Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Sat, 18 Jun 2016 11:40:18 +1000 Subject: [PATCH 1/3] #2 Adds abstain vote type and revises vote score to account for abstention. --- symposion/reviews/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/symposion/reviews/models.py b/symposion/reviews/models.py index 8cf828b7..77acb1dd 100644 --- a/symposion/reviews/models.py +++ b/symposion/reviews/models.py @@ -19,10 +19,13 @@ def score_expression(): return ( (2 * F("plus_two") + F("plus_one")) - (F("minus_one") + 2 * F("minus_two")) + ) / ( + F("vote_count") - F("abstain") ) class Votes(object): + ABSTAIN = "0" PLUS_TWO = "+2" PLUS_ONE = "+1" MINUS_ONE = "−1" @@ -33,6 +36,7 @@ class Votes(object): (PLUS_ONE, _("+1 — OK proposal, but I will not argue for it to be accepted.")), (MINUS_ONE, _("−1 — Weak proposal, but I will not argue strongly against acceptance.")), (MINUS_TWO, _("−2 — Serious issues and I will argue to reject this proposal.")), + (ABSTAIN, _("Abstain - I do not want to review this proposal and I do not want to see it again.")), ] VOTES = Votes() @@ -177,6 +181,7 @@ class Review(models.Model): def css_class(self): return { + self.VOTES.ABSTAIN: "abstain", self.VOTES.PLUS_TWO: "plus-two", self.VOTES.PLUS_ONE: "plus-one", self.VOTES.MINUS_ONE: "minus-one", @@ -210,6 +215,7 @@ class LatestVote(models.Model): def css_class(self): return { + self.VOTES.ABSTAIN: "abstain", self.VOTES.PLUS_TWO: "plus-two", self.VOTES.PLUS_ONE: "plus-one", self.VOTES.MINUS_ONE: "minus-one", @@ -222,6 +228,7 @@ class ProposalResult(models.Model): score = models.DecimalField(max_digits=5, decimal_places=2, default=Decimal("0.00"), verbose_name=_("Score")) comment_count = models.PositiveIntegerField(default=0, verbose_name=_("Comment count")) vote_count = models.PositiveIntegerField(default=0, verbose_name=_("Vote count")) + abstain = models.PositiveIntegerField(default=0, verbose_name=_("Abstain")) plus_two = models.PositiveIntegerField(default=0, verbose_name=_("Plus two")) plus_one = models.PositiveIntegerField(default=0, verbose_name=_("Plus one")) minus_one = models.PositiveIntegerField(default=0, verbose_name=_("Minus one")) @@ -244,6 +251,10 @@ class ProposalResult(models.Model): result, created = cls._default_manager.get_or_create(proposal=proposal) result.comment_count = Review.objects.filter(proposal=proposal).count() result.vote_count = LatestVote.objects.filter(proposal=proposal).count() + result.abstain = LatestVote.objects.filter( + proposal=proposal, + vote=VOTES.ABSTAIN, + ).count() result.plus_two = LatestVote.objects.filter( proposal=proposal, vote=VOTES.PLUS_TWO From 28592e352c21cda97ec14fdddec7643669c7339b Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Sat, 18 Jun 2016 13:07:13 +1000 Subject: [PATCH 2/3] More changes that make abstention work --- symposion/reviews/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/symposion/reviews/models.py b/symposion/reviews/models.py index 77acb1dd..f6234d51 100644 --- a/symposion/reviews/models.py +++ b/symposion/reviews/models.py @@ -20,7 +20,7 @@ def score_expression(): (2 * F("plus_two") + F("plus_one")) - (F("minus_one") + 2 * F("minus_two")) ) / ( - F("vote_count") - F("abstain") + F("vote_count") - F("abstain") * 1.0 ) @@ -276,6 +276,7 @@ class ProposalResult(models.Model): def update_vote(self, vote, previous=None, removal=False): mapping = { + VOTES.ABSTAIN: "abstain", VOTES.PLUS_TWO: "plus_two", VOTES.PLUS_ONE: "plus_one", VOTES.MINUS_ONE: "minus_one", From 47a6f212f21792fe339de277303600c5fa72f43f Mon Sep 17 00:00:00 2001 From: Christopher Neugebauer Date: Sat, 18 Jun 2016 13:13:18 +1000 Subject: [PATCH 3/3] Add display of scores to the review list --- symposion/reviews/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/symposion/reviews/views.py b/symposion/reviews/views.py index f6b967e3..7a854f7e 100644 --- a/symposion/reviews/views.py +++ b/symposion/reviews/views.py @@ -40,6 +40,7 @@ def proposals_generator(request, queryset, user_pk=None, check_speaker=True): ProposalResult.objects.get_or_create(proposal=obj) obj.comment_count = obj.result.comment_count + obj.score = obj.result.score obj.total_votes = obj.result.vote_count obj.plus_two = obj.result.plus_two obj.plus_one = obj.result.plus_one