Skip to content

Commit

Permalink
Show results table only when data exists
Browse files Browse the repository at this point in the history
  • Loading branch information
VirginiaDooley committed Sep 14, 2023
1 parent b933119 commit 78c2f4a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 12 additions & 0 deletions wcivf/apps/elections/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,18 @@ def pluralized_division_name(self):

return pluralise.get(suffix, f"{suffix}s")

@property
def has_results(self):
"""
Returns a boolean for if the election has results
"""
return bool(
self.spoilt_ballots
or self.ballot_papers_issued
or self.turnout
or self.electorate
)


class Post(models.Model):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h3>{% if postelection.is_london_assembly_additional %}{% trans "Additional memb
{% endif %}
</p>
{% endif %}
{% if postelection.election.in_past %}
{% if postelection.election.in_past and postelection.election.has_results %}
<section class="ds-card">
<div class="ds-table">
<table>
Expand All @@ -135,25 +135,25 @@ <h3>{% if postelection.is_london_assembly_additional %}{% trans "Additional memb
<td>{% if postelection.election.electorate %}
{{ postelection.election.electorate }}
{% else %}
{% trans "Electorate not available" %}
{% trans "None" %}
{% endif %}
</td>
<td>{% if postelection.election.turnout %}
{{ postelection.election.turnout|stringformat:"d%%" }}
{% else %}
{% trans "Turnout not available" %}
{% trans "None" %}
{% endif %}
</td>
<td>{% if postelection.election.ballot_papers_issued %}
{{ postelection.election.ballot_papers_issued }}
{% else %}
{% trans "Number of ballot papers issued not available" %}
{% trans "None" %}
{% endif %}
</td>
<td>{% if postelection.election.spoilt_ballots %}
{{ postelection.election.spoilt_ballots }}
{% else %}
{% trans "Number of spoilt ballots not available" %}
{% trans "None" %}
{% endif %}
</td>
</tr>
Expand Down

0 comments on commit 78c2f4a

Please sign in to comment.