diff --git a/app.rb b/app.rb index 08e7a56..8fe3392 100644 --- a/app.rb +++ b/app.rb @@ -27,7 +27,8 @@ get '/' do @results = repository(:default).adapter.query(" SELECT p.name, - sum(c.votes_2010) AS votes + sum(c.votes_2010) AS votes, + p.colour FROM parties p, councilcandidates c diff --git a/lib/models.rb b/lib/models.rb index 7be3a6d..c1852e1 100644 --- a/lib/models.rb +++ b/lib/models.rb @@ -69,6 +69,7 @@ class Party property :id, Serial property :name, String, :required => true + property :colour, String has n, :councilcandidates, :order => ['surname'] has n, :parliamentcandidates, :order => ['surname'] diff --git a/public/style.css b/public/style.css index e1a5f63..d1c4d5a 100644 --- a/public/style.css +++ b/public/style.css @@ -103,12 +103,30 @@ strong color: #000; } +table +{ + border-collapse: collapse; +} + td, th { - padding: 0 15px 15px 0; + padding: 6px; +} + +tr +{ + border-bottom: 1px solid #eee; } .right { text-align: right; +} + +.elected +{ + background-color: #777; + color: white; + padding: 2px 2px; + font-weight: normal; } \ No newline at end of file diff --git a/views/home.haml b/views/home.haml index 39e607a..49dc668 100644 --- a/views/home.haml +++ b/views/home.haml @@ -8,21 +8,21 @@ %p %a{ :href => '/results/uk-parliament/2010-05-06/sutton-and-cheam' } Sutton and Cheam Constituency - %h2 Sutton Council Election Results + %h2 Sutton Council Election Results Summary %table %tr %th - %th Votes - %th % Votes + %th %th Seats %th % Seats + %th Votes + %th % Votes - for result in @results %tr + %td{ :style => "background-color: #{result[2]}" }   %td= result[0] - %td.right= result[1] - %td.right= sprintf("%0.1f%%", result[1].to_f / @total_votes * 100) -# Some pretty serious cheating going on here! %td.right - if result[0] == 'Conservative Party' @@ -38,13 +38,15 @@ 80% - else 0% + %td.right= result[1] + %td.right= sprintf("%0.1f%%", result[1].to_f / @total_votes * 100) %p Total votes: = @total_votes - %h2 Sutton Council ward results + %h2 Sutton Council Results by Ward - for ward in @wards %p diff --git a/views/resultssuttoncouncil.haml b/views/resultssuttoncouncil.haml index fbd767c..b5de808 100644 --- a/views/resultssuttoncouncil.haml +++ b/views/resultssuttoncouncil.haml @@ -10,17 +10,18 @@ %table %tr + %th %th %th %th.right Votes - -# - %th.right % - %th.right Change + %th.right % Votes + %th + - for candidate in @candidates - count += 1 %tr.vcard %td= count - + %td{ :style => "background-color: #{candidate.party.colour}" }   %td %span.candidate_name.fn = candidate.forenames.split(' ')[0] @@ -42,7 +43,7 @@ %td - if count < 4 - %strong ELECTED + .elected ELECTED %p Total votes: diff --git a/views/resultsukparliament.haml b/views/resultsukparliament.haml index a279670..7e964a6 100644 --- a/views/resultsukparliament.haml +++ b/views/resultsukparliament.haml @@ -10,16 +10,20 @@ %table %tr + %th %th %th %th.right Votes %th.right % %th.right Change + %th - for candidate in @candidates - count += 1 %tr.vcard %td= count + %td{ :style => "background-color: #{candidate.party.colour}" }   + %td %span.candidate_name.fn = candidate.forenames.split(' ')[0] @@ -41,7 +45,7 @@ %td - if count == 1 - %strong ELECTED + .elected ELECTED %p Total votes: