Election results in the London Borough of Sutton.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

159 lines
4.7 KiB

  1. - @page_title = "#{@election.body.name} #{@election.kind} #{long_date(@election.d)}"
  2. .nav
  3. %p
  4. %a{ :href => "/bodies/#{@election.body.slug}" }
  5. «
  6. = @election.body.name
  7. - if @elections_for_this_body.size > 1
  8. %p
  9. - @election_index = @elections_for_this_body.index(@election)
  10. - unless @election_index == 0
  11. - @previous_election = @elections_for_this_body[@election_index - 1]
  12. %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@previous_election.d}", :title => "Previous #{@election.body.name} election" }<
  13. &laquo;
  14. = @previous_election.kind
  15. &nbsp;
  16. = short_date(@previous_election.d)
  17. &nbsp;&nbsp;&nbsp;
  18. - unless @election_index == @elections_for_this_body.size - 1
  19. - @next_election = @elections_for_this_body[@election_index + 1]
  20. %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@next_election.d}", :title => "Next #{@election.body.name} election" }<
  21. = @next_election.kind
  22. &nbsp;
  23. = short_date(@next_election.d)
  24. &raquo;
  25. %h1
  26. = @election.body.name
  27. = @election.kind
  28. %br
  29. = long_date(@election.d)
  30. -# Does this election have any recorded votes, i.e. has it been held?
  31. - @election_held = Candidacy.sum(:votes, :election => @election)
  32. - unless @election_held
  33. .warning
  34. We don't have the results for this election yet.
  35. %p= @polling_station
  36. %p= @election.reason
  37. %p
  38. = @election.candidacies.count
  39. = "candidate".pluralize(@election.candidacies.count)
  40. - if @election_held
  41. contested
  42. - else
  43. will be contesting
  44. -# We can't calculate the number of seats being contested if the election hasn't been held
  45. - if @election_held
  46. = @total_seats
  47. = "seat".pluralize(@total_seats)
  48. in
  49. = @total_districts
  50. = @election.body.district_name.pluralize(@total_districts)
  51. in Sutton.
  52. - if @election_held
  53. %h2 Seats, votes and candidates by party
  54. %table
  55. %tr.header
  56. %th &nbsp;
  57. %th &nbsp;
  58. %th.highlight seats won
  59. %th votes
  60. %th % seats
  61. %th % votes
  62. %th votes per seat
  63. %th candidates
  64. %th votes per candidate
  65. -#
  66. %th relative popularity
  67. - @max_votes_per_candidate = @results_by_party.first.votez.to_f / @results_by_party.first.cands.to_f # We really need to scan the array for the max value
  68. - @results_by_party.each do |row|
  69. %tr
  70. %td{ :style => "background-color: #{row.colour}" } &nbsp;
  71. %td.data_party= row.name
  72. %td.data_seats.right.highlight= row.seatz
  73. %td.data_votes.right= commify(row.votez)
  74. - if @election_held
  75. %td.right= format_percent(row.seatz.to_f / @total_seats * 100)
  76. %td.right= format_percent(row.votez.to_f / @total_votes * 100)
  77. %td.data_votes_per_seat.right
  78. - if row.seatz > 0
  79. = commify(row.votez / row.seatz)
  80. - else
  81. &mdash;
  82. %td.data_candidates.right= row.cands
  83. - if @election_held
  84. %td.right= commify(row.votez / row.cands)
  85. -#
  86. %td.right= format_percent( ( row.votez.to_f / row.cands.to_f ) / @max_votes_per_candidate * 100)
  87. %tr.footer
  88. %td &nbsp;
  89. %td &nbsp;
  90. %td.right.highlight= @total_seats
  91. %td.right= commify(@total_votes)
  92. %td &nbsp;
  93. %td &nbsp;
  94. %td &nbsp;
  95. %td &nbsp;
  96. %td &nbsp;
  97. - if @election.ballot_papers_issued
  98. %table
  99. %tr
  100. %td Electorate
  101. %td.right= commify(@election.electorate)
  102. %tr
  103. %td Ballot papers issued
  104. %td.right= commify(@election.ballot_papers_issued)
  105. %tr
  106. %td Turnout
  107. %td.right= sprintf("%.0f%%", @election.ballot_papers_issued / @election.electorate.to_f * 100)
  108. %h2
  109. = @election.body.district_name.capitalize.pluralize(2)
  110. contested in this election
  111. %table
  112. %tr.header
  113. %th &nbsp;
  114. %th seats
  115. %th candidates
  116. %th votes
  117. - @results_by_district.each do |row|
  118. %tr
  119. %td
  120. %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@election.d}/#{@election.body.districts_name}/#{row.district_slug}"}
  121. = row.name
  122. %td.right= row.seats
  123. %td.right= row.num_candidates
  124. %td.right= commify(row.votez)
  125. %tr.footer
  126. %td &nbsp;
  127. %td.right= @total_seats
  128. %td.right= @election.candidacies.count
  129. %td.right= commify(@total_votes)
  130. - else
  131. %h2
  132. = @election.body.district_name.capitalize.pluralize(2)
  133. being contested at this election
  134. %table
  135. - @districts_in_this_election.each do |d|
  136. %tr
  137. %td
  138. %a{ :href => "/bodies/#{@election.body.slug}/#{@election.body.districts_name}/#{d['slug']}"}
  139. = d['name']