diff --git a/opentech/apply/review/models.py b/opentech/apply/review/models.py index 294b622e86c225e0ef4d4bb4e72d8e6d1f234ee4..59f4b19b307d75a623d44e43c8a97893637006bb 100644 --- a/opentech/apply/review/models.py +++ b/opentech/apply/review/models.py @@ -184,3 +184,8 @@ class ReviewOpinion(models.Model): @property def opinion_display(self): return self.get_opinion_display() + + def get_author_role(self): + role = self.review.submission.assigned.with_roles().filter(reviewer=self.author).first() + role = role.role if role else None + return role diff --git a/opentech/apply/review/templates/review/includes/review_opinions_list.html b/opentech/apply/review/templates/review/includes/review_opinions_list.html new file mode 100644 index 0000000000000000000000000000000000000000..60078d119e7a753add78204af126089e762d5928 --- /dev/null +++ b/opentech/apply/review/templates/review/includes/review_opinions_list.html @@ -0,0 +1,10 @@ +{% load wagtailimages_tags %} + +<ul> +{% for opinion in opinions %} + <li> + {% if opinion.get_author_role %}{% image opinion.get_author_role.icon max-12x12 %}{% endif %} + {{ opinion.author }} {{ opinion.get_opinion_display }}s + </li> +{% endfor %} +</ul> \ No newline at end of file diff --git a/opentech/apply/review/templates/review/review_detail.html b/opentech/apply/review/templates/review/review_detail.html index 36be8624007eea2d350ca28780390d9bda3ee173..ef40757784276d254162cf1db75854d36e3bd698 100644 --- a/opentech/apply/review/templates/review/review_detail.html +++ b/opentech/apply/review/templates/review/review_detail.html @@ -7,12 +7,7 @@ <h1 class="beta heading heading--no-margin heading--bold">Review</h1> <h5>For <a href="{% url "funds:submissions:detail" review.submission.id %}">{{ review.submission.title }}</a> by {{ review.author }} at {{ review.updated_at|date:"Y-m-d" }}</h5> - {% for opinion in review.opinions.all %} - <div> - {# TODO: role icon #} {{ opinion.author }} {{ opinion.get_opinion_display }}s - </div> - {% endfor %} - + {% include 'review/includes/review_opinions_list.html' with opinions=review.opinions.all %} </div> </div> diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py index 2fae0ed088a81501d84c858ea1ebe2725cceb816..4778993102a444bb2b4b07e471c2a25902ab425b 100644 --- a/opentech/apply/review/views.py +++ b/opentech/apply/review/views.py @@ -63,14 +63,13 @@ class ReviewContextMixin: 'role': role, } opinions_list = [] - if review and review.opinions: + if review: + # Loop through all opinions and include the current author's role for this submission 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, + 'role': opinion.get_author_role(), }) review_info_dict['opinions'] = opinions_list reviews_block[key].append(review_info_dict)