From ca532d91ebd00fa97e5f3e3ede7cb7fb6c2f2e7c Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Wed, 20 Feb 2019 09:08:44 +0100
Subject: [PATCH] Fix counting query going wrong

---
 .../colleges/_potentialfellowship_voting_table.html         | 6 +++---
 colleges/views.py                                           | 6 ++----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/colleges/templates/colleges/_potentialfellowship_voting_table.html b/colleges/templates/colleges/_potentialfellowship_voting_table.html
index c0361456b..84e009e54 100644
--- a/colleges/templates/colleges/_potentialfellowship_voting_table.html
+++ b/colleges/templates/colleges/_potentialfellowship_voting_table.html
@@ -17,15 +17,15 @@
         Click to vote:
 	<form action="{% url 'colleges:vote_on_potential_fellowship' potfel_id=potfel.id vote='A' %}" method="post">
           {% csrf_token %}
-          <input type="submit" class="agree" value="Agree {{ potfel.nr_A }} "/>
+          <input type="submit" class="agree" value="Agree {{ potfel.in_agreement.count }} "/>
         </form>
         <form action="{% url 'colleges:vote_on_potential_fellowship' potfel_id=potfel.id vote='N' %}" method="post">
           {% csrf_token %}
-          <input type="submit" class="notsure" value="Abstain {{ potfel.nr_N }}"/>
+          <input type="submit" class="notsure" value="Abstain {{ potfel.in_abstain.count }}"/>
         </form>
         <form action="{% url 'colleges:vote_on_potential_fellowship' potfel_id=potfel.id vote='D' %}" method="post">
           {% csrf_token %}
-          <input type="submit" class="disagree" value="Disagree {{ potfel.nr_D }}"/>
+          <input type="submit" class="disagree" value="Disagree {{ potfel.in_disagreement.count }}"/>
         </form>
         {% if request.user.contributor in potfel.in_agreement.all %}
         <strong>(you have voted: Agreed)</strong>
diff --git a/colleges/views.py b/colleges/views.py
index 10b007036..e5cf6c497 100644
--- a/colleges/views.py
+++ b/colleges/views.py
@@ -380,11 +380,9 @@ class PotentialFellowshipListView(PermissionsMixin, PaginationMixin, ListView):
     def get_context_data(self, **kwargs):
         context = super().get_context_data(**kwargs)
         context['potfels_to_vote_on'] = PotentialFellowship.objects.to_vote_on(
-            self.request.user.contributor).annotate(
-                nr_A=Count('in_agreement'), nr_N=Count('in_abstain'), nr_D=Count('in_disagreement'))
+            self.request.user.contributor)
         context['potfels_voted_on'] = PotentialFellowship.objects.voted_on(
-            self.request.user.contributor).annotate(
-                nr_A=Count('in_agreement'), nr_N=Count('in_abstain'), nr_D=Count('in_disagreement'))
+            self.request.user.contributor)
         context['subject_areas'] = SCIPOST_SUBJECT_AREAS
         context['statuses'] = POTENTIAL_FELLOWSHIP_STATUSES
         return context
-- 
GitLab