Browse Source

Store & display breakdown of rejected ballot papers

tags/last-sinatra-version
Adrian Short 9 years ago
parent
commit
9cf115441b
2 changed files with 32 additions and 1 deletions
  1. +12
    -1
      models.rb
  2. +20
    -0
      views/resultsdistrict.haml

+ 12
- 1
models.rb View File

@@ -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


+ 20
- 0
views/resultsdistrict.haml View File

@@ -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)

Loading…
Cancel
Save