From cc753fdb961722fa2d4b2ab2fd31e067d9ec517c Mon Sep 17 00:00:00 2001 From: Erin Mullaney <erin.mullaney@torchbox.com> Date: Wed, 20 Feb 2019 08:36:37 -0500 Subject: [PATCH] #962 opinion display review detail block --- .../templates/funds/includes/review_table.html | 4 ++-- .../funds/includes/review_table_row.html | 12 ++++++++++++ opentech/apply/review/views.py | 16 ++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/opentech/apply/funds/templates/funds/includes/review_table.html b/opentech/apply/funds/templates/funds/includes/review_table.html index ef85008ac..e01ffccdc 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 %} + {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer role=review_data.role opinions=review_data.opinions %} {% 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 %} + {% include 'funds/includes/review_table_row.html' with review=review_data.review reviewer=review_data.reviewer opinions=review_data.opinions %} {% endfor %} {% for review_data in reviews_block.role_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 8e5190c29..d212a6474 100644 --- a/opentech/apply/funds/templates/funds/includes/review_table_row.html +++ b/opentech/apply/funds/templates/funds/includes/review_table_row.html @@ -31,3 +31,15 @@ <td>{{ review.get_score_display }}</td> {% endif %} </tr> +{% for opinion in opinions %} +<tr class="tr--subchild"> + <td class="reviews-sidebar__author" colspan="2"> + <span> + {{ opinion.author }} + {% if opinion.role %}{% image opinion.role.icon max-12x12 %}{% endif %} + </span> + </td> + <td></td> + <td>{{ opinion.opinion }}</td> +</tr> +{% endfor %} diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py index c8605b2eb..03514f515 100644 --- a/opentech/apply/review/views.py +++ b/opentech/apply/review/views.py @@ -51,11 +51,23 @@ class ReviewContextMixin: else: key = 'external_not_reviewed' - reviews_block[key].append({ + review_info_dict = { 'reviewer': reviewer, 'review': review, 'role': role, - }) + } + opinions_list = [] + if review and review.opinions: + for opinion in review.opinions.all(): + author_role = self.object.assigned.with_roles().filter(reviewer=opinion.author).first() + role = author_role.role if author_role else None + opinions_list.append({ + 'author': opinion.author, + 'opinion': opinion.get_opinion_display(), + 'role': role, + }) + review_info_dict['opinions'] = opinions_list + reviews_block[key].append(review_info_dict) # Calculate the recommendation based on role and staff reviews recommendation = self.object.reviews.by_staff().recommendation() -- GitLab