| @@ -27,7 +27,8 @@ get '/' do | |||||
| @results = repository(:default).adapter.query(" | @results = repository(:default).adapter.query(" | ||||
| SELECT p.name, | SELECT p.name, | ||||
| sum(c.votes_2010) AS votes | |||||
| sum(c.votes_2010) AS votes, | |||||
| p.colour | |||||
| FROM parties p, | FROM parties p, | ||||
| councilcandidates c | councilcandidates c | ||||
| @@ -69,6 +69,7 @@ class Party | |||||
| property :id, Serial | property :id, Serial | ||||
| property :name, String, :required => true | property :name, String, :required => true | ||||
| property :colour, String | |||||
| has n, :councilcandidates, :order => ['surname'] | has n, :councilcandidates, :order => ['surname'] | ||||
| has n, :parliamentcandidates, :order => ['surname'] | has n, :parliamentcandidates, :order => ['surname'] | ||||
| @@ -103,12 +103,30 @@ strong | |||||
| color: #000; | color: #000; | ||||
| } | } | ||||
| table | |||||
| { | |||||
| border-collapse: collapse; | |||||
| } | |||||
| td, th | td, th | ||||
| { | { | ||||
| padding: 0 15px 15px 0; | |||||
| padding: 6px; | |||||
| } | |||||
| tr | |||||
| { | |||||
| border-bottom: 1px solid #eee; | |||||
| } | } | ||||
| .right | .right | ||||
| { | { | ||||
| text-align: right; | text-align: right; | ||||
| } | |||||
| .elected | |||||
| { | |||||
| background-color: #777; | |||||
| color: white; | |||||
| padding: 2px 2px; | |||||
| font-weight: normal; | |||||
| } | } | ||||
| @@ -8,21 +8,21 @@ | |||||
| %p | %p | ||||
| %a{ :href => '/results/uk-parliament/2010-05-06/sutton-and-cheam' } Sutton and Cheam Constituency | %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 | %table | ||||
| %tr | %tr | ||||
| %th | %th | ||||
| %th Votes | |||||
| %th % Votes | |||||
| %th | |||||
| %th Seats | %th Seats | ||||
| %th % Seats | %th % Seats | ||||
| %th Votes | |||||
| %th % Votes | |||||
| - for result in @results | - for result in @results | ||||
| %tr | %tr | ||||
| %td{ :style => "background-color: #{result[2]}" } | |||||
| %td= result[0] | %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! | -# Some pretty serious cheating going on here! | ||||
| %td.right | %td.right | ||||
| - if result[0] == 'Conservative Party' | - if result[0] == 'Conservative Party' | ||||
| @@ -38,13 +38,15 @@ | |||||
| 80% | 80% | ||||
| - else | - else | ||||
| 0% | 0% | ||||
| %td.right= result[1] | |||||
| %td.right= sprintf("%0.1f%%", result[1].to_f / @total_votes * 100) | |||||
| %p | %p | ||||
| Total votes: | Total votes: | ||||
| = @total_votes | = @total_votes | ||||
| %h2 Sutton Council ward results | |||||
| %h2 Sutton Council Results by Ward | |||||
| - for ward in @wards | - for ward in @wards | ||||
| %p | %p | ||||
| @@ -10,17 +10,18 @@ | |||||
| %table | %table | ||||
| %tr | %tr | ||||
| %th | |||||
| %th | %th | ||||
| %th | %th | ||||
| %th.right Votes | %th.right Votes | ||||
| -# | |||||
| %th.right % | |||||
| %th.right Change | |||||
| %th.right % Votes | |||||
| %th | |||||
| - for candidate in @candidates | - for candidate in @candidates | ||||
| - count += 1 | - count += 1 | ||||
| %tr.vcard | %tr.vcard | ||||
| %td= count | %td= count | ||||
| %td{ :style => "background-color: #{candidate.party.colour}" } | |||||
| %td | %td | ||||
| %span.candidate_name.fn | %span.candidate_name.fn | ||||
| = candidate.forenames.split(' ')[0] | = candidate.forenames.split(' ')[0] | ||||
| @@ -42,7 +43,7 @@ | |||||
| %td | %td | ||||
| - if count < 4 | - if count < 4 | ||||
| %strong ELECTED | |||||
| .elected ELECTED | |||||
| %p | %p | ||||
| Total votes: | Total votes: | ||||
| @@ -10,16 +10,20 @@ | |||||
| %table | %table | ||||
| %tr | %tr | ||||
| %th | |||||
| %th | %th | ||||
| %th | %th | ||||
| %th.right Votes | %th.right Votes | ||||
| %th.right % | %th.right % | ||||
| %th.right Change | %th.right Change | ||||
| %th | |||||
| - for candidate in @candidates | - for candidate in @candidates | ||||
| - count += 1 | - count += 1 | ||||
| %tr.vcard | %tr.vcard | ||||
| %td= count | %td= count | ||||
| %td{ :style => "background-color: #{candidate.party.colour}" } | |||||
| %td | %td | ||||
| %span.candidate_name.fn | %span.candidate_name.fn | ||||
| = candidate.forenames.split(' ')[0] | = candidate.forenames.split(' ')[0] | ||||
| @@ -41,7 +45,7 @@ | |||||
| %td | %td | ||||
| - if count == 1 | - if count == 1 | ||||
| %strong ELECTED | |||||
| .elected ELECTED | |||||
| %p | %p | ||||
| Total votes: | Total votes: | ||||