Skip to content

Commit

Permalink
[scorecards] fix section page evidence link display
Browse files Browse the repository at this point in the history
Only display evidence bit if we've selected a council in some way as
otherwise it doesn't make sense to display the evidence section.

Fixes #595
  • Loading branch information
struan committed Oct 23, 2023
1 parent 0d2d34c commit a81fedc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<dd class="col-sm-8">{{ how_marked }}</dd>
<dt class="col-sm-4">Question weight</dt>
<dd class="col-sm-8">{{ weighting }}</dd>
{% if evidence_links != 'CouncilTypeOnly' %}
<dt class="col-sm-4">Evidence</dt>
<dd class="col-sm-8">
{% for link in evidence_links %}
Expand All @@ -40,6 +41,7 @@
No evidence available.
{% endfor %}
</dd>
{% endif %}
</dl>
</div>

Expand Down
12 changes: 12 additions & 0 deletions scoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ def add_comparisons(self, context, comparison_slugs, comparison_questions):
plan_sections=PlanSection.objects.filter(code=section.code),
)

first_comparison = comparison_slugs[0]

comparison_scores = comparison_sections[section.code]

for score in comparison_scores:
Expand All @@ -537,8 +539,17 @@ def add_comparisons(self, context, comparison_slugs, comparison_questions):
if answer.score < 0:
score["negative_points"] += answer.score
score["non_negative_max"] -= answer.score

# need to add this manually to the section question object so it displays
# the evidence if it's relevant
if score["council_slug"] == first_comparison:
comparison_questions[code][
"evidence_links"
] = answer.evidence_links.splitlines()

else:
comparison_questions[code]["comparisons"].append({"score": "-"})
comparison_questions[code]["evidence_links"] = []

if score["negative_points"] < 0:
score["negative_percent"] = (
Expand Down Expand Up @@ -586,6 +597,7 @@ def get_questions(self, context):
for question in questions:
comparison_questions[question.code] = {
"details": question,
"evidence_links": "CouncilTypeOnly",
"comparisons": [],
}

Expand Down

0 comments on commit a81fedc

Please sign in to comment.