From 9cf115441b9efdf39640d64df07ae8bc2a59d866 Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Thu, 21 May 2015 22:37:53 +0100 Subject: [PATCH] Store & display breakdown of rejected ballot papers --- models.rb | 13 ++++++++++++- views/resultsdistrict.haml | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/models.rb b/models.rb index 8c009e6..bcee4dd 100644 --- a/models.rb +++ b/models.rb @@ -8,11 +8,22 @@ class Poll property :electorate, Integer # The number of people eligible to vote in this district in this election property :ballot_papers_issued, Integer # The number of ballot papers issued (includes spoiled ballots) property :seats, Integer, :required => true # The number of seats to be elected in this district in this election - + property :rejected_no_official_mark, Integer + property :rejected_too_many_candidates, Integer + property :rejected_identifiable_voter, Integer + property :rejected_blank_or_uncertain, Integer + def turnout_percent @ballot_papers_issued.to_f / @electorate.to_f * 100.0 end + def total_rejected_ballots + @rejected_no_official_mark + \ + @rejected_too_many_candidates + \ + @rejected_identifiable_voter + \ + @rejected_blank_or_uncertain + end + belongs_to :election belongs_to :district end diff --git a/views/resultsdistrict.haml b/views/resultsdistrict.haml index e7f541b..9e150bd 100644 --- a/views/resultsdistrict.haml +++ b/views/resultsdistrict.haml @@ -149,3 +149,23 @@ %td Turnout %td.right= sprintf("%.0f%%", @poll.turnout_percent) + -# Show this table conditionally as sometimes we have electorate data but no + -# breakdown of rejected ballot papers + - if @poll.rejected_no_official_mark + %h2 Rejected ballot papers + %table + %tr + %td Want of official mark + %td.right= commify(@poll.rejected_no_official_mark) + %tr + %td Voting for too many candidates + %td.right= commify(@poll.rejected_too_many_candidates) + %tr + %td Writing or mark by which the voter could be identified + %td.right= commify(@poll.rejected_identifiable_voter) + %tr + %td Unmarked or void for uncertainty + %td.right= commify(@poll.rejected_blank_or_uncertain) + %tr.footer + %td   + %td.right= commify(@poll.total_rejected_ballots)