Browse Source

Add number of candidates in each district to districts contested table; make both tables easy to copy and paste

tags/last-sinatra-version
Adrian Short 12 years ago
parent
commit
632db20485
2 changed files with 18 additions and 16 deletions
  1. +2
    -1
      app.rb
  2. +16
    -15
      views/electionsummary.haml

+ 2
- 1
app.rb View File

@@ -118,7 +118,8 @@ get '/bodies/:body/elections/:date' do
d.name, d.name,
d.slug AS district_slug, d.slug AS district_slug,
SUM(c.seats) AS seats, SUM(c.seats) AS seats,
SUM(c.votes) AS votez
SUM(c.votes) AS votez,
COUNT(c.id) AS num_candidates
FROM districts d, candidacies c FROM districts d, candidacies c




+ 16
- 15
views/electionsummary.haml View File

@@ -50,8 +50,8 @@
%table %table
%tr.header %tr.header
%th
%th
%th  
%th  
%th.highlight seats won %th.highlight seats won
%th votes %th votes
%th % seats %th % seats
@@ -82,26 +82,25 @@
%tr.footer %tr.footer
%td
%td
%td  
%td  
%td.right.highlight= @total_seats %td.right.highlight= @total_seats
%td.right= commify(@total_votes) %td.right= commify(@total_votes)
%td
%td
%td
%td
%td
-#
%td
%td  
%td  
%td  
%td  
%td  
%h2 %h2
Results by
= @election.body.district_name
= @election.body.district_name.capitalize.pluralize(2)
contested in this election
%table %table
%tr.header %tr.header
%th
%th  
%th seats %th seats
%th candidates
%th votes %th votes
- @results_by_district.each do |row| - @results_by_district.each do |row|
%tr %tr
@@ -109,10 +108,12 @@
%a{ :href => "/bodies/#{@election.body.slug}/elections/#{@election.d}/#{@election.body.districts_name}/#{row.district_slug}"} %a{ :href => "/bodies/#{@election.body.slug}/elections/#{@election.d}/#{@election.body.districts_name}/#{row.district_slug}"}
= row.name = row.name
%td.right= row.seats %td.right= row.seats
%td.right= row.num_candidates
%td.right= commify(row.votez) %td.right= commify(row.votez)
%tr.footer %tr.footer
%td
%td  
%td.right= @total_seats %td.right= @total_seats
%td.right= @election.candidacies.count
%td.right= commify(@total_votes) %td.right= commify(@total_votes)
- else - else
%p Full details and results will be available on this page. %p Full details and results will be available on this page.

Loading…
Cancel
Save