From cc03b69dba6c96f557e52ce5464e56c1d1dca21f Mon Sep 17 00:00:00 2001 From: Virginia Dooley Date: Thu, 24 Aug 2023 11:16:30 +0100 Subject: [PATCH] Display election results in table - Includes turnout (ballot_papers_issued), electorate, percentage turnout and spoilt ballots --- .../elections/includes/_single_ballot.html | 41 ++++++++++++++++++- .../elections/tests/test_election_views.py | 12 ++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/wcivf/apps/elections/templates/elections/includes/_single_ballot.html b/wcivf/apps/elections/templates/elections/includes/_single_ballot.html index 297080a20..9780500bd 100644 --- a/wcivf/apps/elections/templates/elections/includes/_single_ballot.html +++ b/wcivf/apps/elections/templates/elections/includes/_single_ballot.html @@ -121,7 +121,46 @@

{% if postelection.is_london_assembly_additional %}{% trans "Additional memb {% endif %}

{% endif %} - + {% if postelection.election.in_past %} +
+
+ + + + + + + + + + + + + +
ElectorateTurnoutBallot Papers IssuedSpoilt Ballots
{% if postelection.election.electorate %} + {{ postelection.election.electorate }} + {% else %} + {% trans "Electorate not available" %} + {% endif %} + {% if postelection.election.turnout %} + {{ postelection.election.turnout|stringformat:"d%%" }} + {% else %} + {% trans "Turnout not available" %} + {% endif %} + {% if postelection.election.ballot_papers_issued %} + {{ postelection.election.ballot_papers_issued }} + {% else %} + {% trans "Number of ballot papers issued not available" %} + {% endif %} + {% if postelection.election.spoilt_ballots %} + {{ postelection.election.spoilt_ballots }} + {% else %} + {% trans "Number of spoilt ballots not available" %} + {% endif %} +
+
+
+ {% endif %} {% if postelection.people and postelection.should_show_candidates %} {% if postelection.display_as_party_list %} {% include "elections/includes/_people_list_with_lists.html" with people=postelection.people %} diff --git a/wcivf/apps/elections/tests/test_election_views.py b/wcivf/apps/elections/tests/test_election_views.py index b8b8d6a76..1a5c073f1 100644 --- a/wcivf/apps/elections/tests/test_election_views.py +++ b/wcivf/apps/elections/tests/test_election_views.py @@ -137,6 +137,18 @@ def setUp(self): election=self.election, post=self.post ) + def test_ballot_table(self): + """check that the table containing the electorate, + turnout, spoilt ballots, ballot papers exist + for past elections""" + response = self.client.get( + self.post_election.get_absolute_url(), follow=True + ) + self.assertContains(response, "Electorate") + self.assertContains(response, "Turnout") + self.assertContains(response, "Spoilt Ballots") + self.assertContains(response, "Ballot Papers Issued") + def test_zero_candidates(self): response = self.client.get( self.post_election.get_absolute_url(), follow=True