From 87fa24af2a5c1ab312d5379c1343075e8eeea483 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Sat, 16 Sep 2017 19:50:08 +0200
Subject: [PATCH] Show brief EC-rec results on admin page

---
 submissions/models.py                                    | 6 +++---
 .../submissions/admin/recommendation_tooltip.html        | 9 +++++++++
 .../templates/submissions/admin/editorial_admin.html     | 5 +++--
 .../templates/submissions/admin/recommendation.html      | 4 ++--
 4 files changed, 17 insertions(+), 7 deletions(-)
 create mode 100644 submissions/templates/partials/submissions/admin/recommendation_tooltip.html

diff --git a/submissions/models.py b/submissions/models.py
index 65896271e..c7b1dee29 100644
--- a/submissions/models.py
+++ b/submissions/models.py
@@ -502,9 +502,9 @@ class EICRecommendation(SubmissionRelatedObjectMixin, models.Model):
     # Editorial Fellows who have assessed this recommendation:
     eligible_to_vote = models.ManyToManyField('scipost.Contributor', blank=True,
                                               related_name='eligible_to_vote')
-    voted_for = models.ManyToManyField(Contributor, blank=True, related_name='voted_for')
-    voted_against = models.ManyToManyField(Contributor, blank=True, related_name='voted_against')
-    voted_abstain = models.ManyToManyField(Contributor, blank=True, related_name='voted_abstain')
+    voted_for = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_for')
+    voted_against = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_against')
+    voted_abstain = models.ManyToManyField('scipost.Contributor', blank=True, related_name='voted_abstain')
     voting_deadline = models.DateTimeField('date submitted', default=timezone.now)
 
     objects = EICRecommendationManager()
diff --git a/submissions/templates/partials/submissions/admin/recommendation_tooltip.html b/submissions/templates/partials/submissions/admin/recommendation_tooltip.html
new file mode 100644
index 000000000..79e47405e
--- /dev/null
+++ b/submissions/templates/partials/submissions/admin/recommendation_tooltip.html
@@ -0,0 +1,9 @@
+<i class="fa fa-info-circle {{ classes }}" data-toggle="tooltip" data-html="true" title="
+    Eligible to vote ({{ recommendation.eligible_to_vote.count }})
+    <hr>
+    Agreed ({{ recommendation.voted_for.count }})
+    <br>
+    Disagreed ({{ recommendation.voted_against.count }})
+    <br>
+    Abstained ({{ recommendation.voted_abstain.count }})
+"></i>
diff --git a/submissions/templates/submissions/admin/editorial_admin.html b/submissions/templates/submissions/admin/editorial_admin.html
index 9aad2991f..b1145975f 100644
--- a/submissions/templates/submissions/admin/editorial_admin.html
+++ b/submissions/templates/submissions/admin/editorial_admin.html
@@ -35,9 +35,10 @@
 
         {% if recommendations_undergoing_voting %}
             <h3>Recommendations undergoing voting <i class="fa fa-exclamation-circle text-warning"></i></h3>
-            <ul>
+            <ul class="fa-ul">
                 {% for recommendation in recommendations_undergoing_voting %}
-                    <li>On Editorial Recommendation: {{ recommendation }}<br>
+                    <li>{% include 'partials/submissions/admin/recommendation_tooltip.html' with classes='fa-li' recommendation=recommendation %}
+                        On Editorial Recommendation: {{ recommendation }}<br>
                         <a href="{% url 'submissions:admin_recommendation' recommendation.submission.arxiv_identifier_w_vn_nr %}">See Editorial Recommendation</a>
                     </li>
                 {% endfor %}
diff --git a/submissions/templates/submissions/admin/recommendation.html b/submissions/templates/submissions/admin/recommendation.html
index fb6bb8b0e..a4eed96cb 100644
--- a/submissions/templates/submissions/admin/recommendation.html
+++ b/submissions/templates/submissions/admin/recommendation.html
@@ -47,8 +47,8 @@
                     {% endfor %}
                 </li>
                 <li>
-                    Disagreed:&nbsp;({{ rec.voted_against.all.count }})
-                    {% for disagreed in rec.voted_against.all|sort_by:'user__last_name' %}
+                    Disagreed:&nbsp;({{ object.voted_against.all.count }})
+                    {% for disagreed in object.voted_against.all|sort_by:'user__last_name' %}
                         {{ disagreed.user.last_name }},&nbsp;
                     {% endfor %}
                 </li>
-- 
GitLab