From b20f94abeb93d9380de2fa1ab6f8c5dcfdc3dbd7 Mon Sep 17 00:00:00 2001
From: Erin Mullaney <erin.mullaney@torchbox.com>
Date: Thu, 21 Feb 2019 11:46:39 -0500
Subject: [PATCH] GH-962 simplify opinion data on the review block on the
 submission detail page

---
 .../funds/templates/funds/includes/review_table.html   |  6 +++---
 .../templates/funds/includes/review_table_row.html     |  9 +++++----
 opentech/apply/review/views.py                         | 10 ----------
 3 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/opentech/apply/funds/templates/funds/includes/review_table.html b/opentech/apply/funds/templates/funds/includes/review_table.html
index 7b724dae3..ef85008ac 100644
--- a/opentech/apply/funds/templates/funds/includes/review_table.html
+++ b/opentech/apply/funds/templates/funds/includes/review_table.html
@@ -13,11 +13,11 @@
     {% endif %}
 
     {% for review_data in reviews_block.role_reviewed %}
-        {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer role=review_data.role opinions=review_data.opinions %}
+        {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer role=review_data.role %}
     {% endfor %}
 
     {% for review_data in reviews_block.staff_reviewed %}
-        {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer opinions=review_data.opinions %}
+        {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer %}
     {% endfor %}
 
     {% for review_data in reviews_block.role_not_reviewed %}
@@ -33,7 +33,7 @@
         {% if reviews_block.external_reviewed or reviews_block.external_not_reviewed %}
 
             {% for review_data in reviews_block.external_reviewed %}
-                {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer opinions=review_data.opinions %}
+                {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer %}
             {% endfor %}
 
             {% for review_data in reviews_block.external_not_reviewed %}
diff --git a/opentech/apply/funds/templates/funds/includes/review_table_row.html b/opentech/apply/funds/templates/funds/includes/review_table_row.html
index d212a6474..1e30276ad 100644
--- a/opentech/apply/funds/templates/funds/includes/review_table_row.html
+++ b/opentech/apply/funds/templates/funds/includes/review_table_row.html
@@ -31,15 +31,16 @@
         <td>{{ review.get_score_display }}</td>
     {% endif %}
 </tr>
-{% for opinion in opinions %}
+
+{% for opinion in review.opinions.all %}
 <tr class="tr--subchild">
     <td class="reviews-sidebar__author" colspan="2">
         <span>
             {{ opinion.author }}
-            {% if opinion.role %}{% image opinion.role.icon max-12x12 %}{% endif %}
+            {% if opinion.get_author_assignment %}{% image opinion.get_author_assignment.icon max-12x12 %}{% endif %}
         </span>
     </td>
     <td></td>
-    <td>{{ opinion.opinion }}</td>
+    <td>{{ opinion.get_opinion_display }}</td>
 </tr>
-{% endfor %}
+{% endfor %}
\ No newline at end of file
diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py
index 0f7e0c46d..fc08fea90 100644
--- a/opentech/apply/review/views.py
+++ b/opentech/apply/review/views.py
@@ -62,16 +62,6 @@ class ReviewContextMixin:
                     'review': review,
                     'role': role,
                 }
-                opinions_list = []
-                if review:
-                    # Loop through all opinions and include the current author's role for this submission
-                    for opinion in review.opinions.all():
-                        opinions_list.append({
-                            'author': opinion.author,
-                            'opinion': opinion.get_opinion_display(),
-                            'role': opinion.get_author_role(),
-                        })
-                    review_info_dict['opinions'] = opinions_list
                 reviews_block[key].append(review_info_dict)
 
         # Calculate the recommendation based on role and staff reviews
-- 
GitLab