- @page_title = "#{@election.body.name} #{@election.kind} #{long_date(@election.d)}" %nav %a{ :href => "/bodies/#{@election.body.slug}" } « = @election.body.name - if @elections_for_this_body.size > 1 %p - @election_index = @elections_for_this_body.index(@election) - unless @election_index == 0 - @previous_election = @elections_for_this_body[@election_index - 1] %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@previous_election.d}", :title => "#{@previous_election.kind} #{short_date(@previous_election.d)}" }< « Previous = @election.body.name election     - unless @election_index == @elections_for_this_body.size - 1 - @next_election = @elections_for_this_body[@election_index + 1] %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@next_election.d}", :title => "#{@next_election.kind} #{short_date(@next_election.d)}" }< Next = @election.body.name election » %h1 = @election.body.name = @election.kind %br = long_date(@election.d) -# Does this election have any recorded votes, i.e. has it been held? - @election_held = Candidacy.sum(:votes, :election => @election) - unless @election_held .warning We don't have the results for this election yet. %p= @polling_station %p= @election.reason %p = @election.candidacies.count = "candidate".pluralize(@election.candidacies.count) - if @election_held contested - else will be contesting -# We can't calculate the number of seats being contested if the election hasn't been held - if @election_held = @total_seats = "seat".pluralize(@total_seats) in = @total_districts = @election.body.district_name.pluralize(@total_districts) in Sutton. - if @election_held %table %tr.header %th   %th   %th.highlight seats won %th votes %th % votes %th % seats %th votes per seat %th candidates %th votes per candidate -# %th relative popularity - @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 - @results_by_party.each do |row| %tr %td{ :style => "background-color: #{row.colour}" }   %td.data_party= row.name %td.data_seats.right.highlight= row.seatz %td.data_votes.right= commify(row.votez) - if @election_held %td.right= format_percent(row.votez.to_f / @total_votes * 100) %td.right= format_percent(row.seatz.to_f / @total_seats * 100) %td.data_votes_per_seat.right - if row.seatz > 0 = commify(row.votez / row.seatz) - else — %td.data_candidates.right= row.cands - if @election_held %td.right= commify(row.votez / row.cands) -# %td.right= format_percent( ( row.votez.to_f / row.cands.to_f ) / @max_votes_per_candidate * 100) %tr.footer %td   %td   %td.right.highlight= @total_seats %td.right= commify(@total_votes) %td   %td   %td   %td   %td   - if @election.ballot_papers_issued %table %tr %td Electorate %td.right= commify(@election.electorate) %tr %td Ballot papers issued %td.right= commify(@election.ballot_papers_issued) %tr %td Turnout %td.right= sprintf("%.0f%%", @election.ballot_papers_issued / @election.electorate.to_f * 100) %h2 = @election.body.district_name.capitalize.pluralize(2) contested in this election %table %tr.header %th   %th seats %th candidates %th votes - @results_by_district.each do |row| %tr %td %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@election.d}/#{@election.body.districts_name}/#{row.district_slug}"} = row.name %td.right= row.seats %td.right= row.num_candidates %td.right= commify(row.votez) %tr.footer %td   %td.right= @total_seats %td.right= @election.candidacies.count %td.right= commify(@total_votes) - else %h2 = @election.body.district_name.capitalize.pluralize(2) being contested at this election %table - @districts_in_this_election.each do |d| %tr %td %a{ :href => "/bodies/#{@election.body.slug}/#{@election.body.districts_name}/#{d['slug']}"} = d['name']