From 4a4a41d09618d5864c4cc7ea8a19ebfe011c6a18 Mon Sep 17 00:00:00 2001 From: Erin Mullaney <erin.mullaney@torchbox.com> Date: Thu, 21 Feb 2019 12:11:43 -0500 Subject: [PATCH] #962 move opinion check out of context and into template for all reviews page --- .../review/includes/review_opinions_list.html | 20 ++++++++++--------- opentech/apply/review/views.py | 9 +++------ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/opentech/apply/review/templates/review/includes/review_opinions_list.html b/opentech/apply/review/templates/review/includes/review_opinions_list.html index d26a90645..0cc942d17 100644 --- a/opentech/apply/review/templates/review/includes/review_opinions_list.html +++ b/opentech/apply/review/templates/review/includes/review_opinions_list.html @@ -1,11 +1,13 @@ {% load wagtailimages_tags %} -<ul> -{% for opinion in opinions %} - <li> - {{ opinion.author }} - {% if opinion.get_author_assignment %}{% image opinion.get_author_assignment.icon max-12x12 %}{% endif %} - {{ opinion.get_opinion_display }}s - </li> -{% endfor %} -</ul> \ No newline at end of file +{% if opinions %} + <ul> + {% for opinion in opinions %} + <li> + {{ opinion.author }} + {% if opinion.get_author_assignment %}{% image opinion.get_author_assignment.icon max-12x12 %}{% endif %} + {{ opinion.get_opinion_display }}s + </li> + {% endfor %} + </ul> +{% endif %} \ No newline at end of file diff --git a/opentech/apply/review/views.py b/opentech/apply/review/views.py index fc08fea90..09752f6ae 100644 --- a/opentech/apply/review/views.py +++ b/opentech/apply/review/views.py @@ -243,12 +243,9 @@ class ReviewListView(ListView): for i, review in enumerate(self.object_list): review_data['title']['answers'].append('<a href="{}">{}</a>'.format(review.get_absolute_url(), review.author)) - if review.opinions: - opinions_template = get_template('review/includes/review_opinions_list.html') - opinions_html = opinions_template.render({'opinions': review.opinions.all()}) - review_data['opinions']['answers'].append(opinions_html) - else: - review_data['opinions']['answers'].append("") + opinions_template = get_template('review/includes/review_opinions_list.html') + opinions_html = opinions_template.render({'opinions': review.opinions.select_related('author').all()}) + review_data['opinions']['answers'].append(opinions_html) review_data['score']['answers'].append(str(review.get_score_display())) review_data['recommendation']['answers'].append(review.get_recommendation_display()) review_data['comments']['answers'].append(review.get_comments_display(include_question=False)) -- GitLab