| @@ -107,6 +107,19 @@ class Candidacy | |||||
| belongs_to :district | belongs_to :district | ||||
| end | end | ||||
| class Campaign | |||||
| include DataMapper::Resource | |||||
| property :party_id, Integer, :key => true | |||||
| property :election_id, Integer, :key => true | |||||
| property :party_url, String, :length => 255 | |||||
| property :manifesto_html_url, String, :length => 255 | |||||
| property :manifesto_pdf_url, String, :length => 255 | |||||
| belongs_to :party | |||||
| belongs_to :election | |||||
| end | |||||
| class Election | class Election | ||||
| include DataMapper::Resource | include DataMapper::Resource | ||||
| @@ -119,7 +132,8 @@ class Election | |||||
| has n, :candidacies | has n, :candidacies | ||||
| has n, :polls | has n, :polls | ||||
| belongs_to :body | belongs_to :body | ||||
| has n, :campaigns | |||||
| def self.past | def self.past | ||||
| self.all(:d.lt => Time.now.to_s, :order => [ :d.desc ]) | self.all(:d.lt => Time.now.to_s, :order => [ :d.desc ]) | ||||
| end | end | ||||
| @@ -170,6 +184,7 @@ class Party | |||||
| property :colour, String | property :colour, String | ||||
| has n, :candidacies | has n, :candidacies | ||||
| has n, :campaigns | |||||
| end | end | ||||
| # These models are now redundant | # These models are now redundant | ||||
| @@ -91,6 +91,17 @@ a:hover | |||||
| color: #fff; | color: #fff; | ||||
| } | } | ||||
| /* | |||||
| Show icon for external links | |||||
| https://stackoverflow.com/questions/18168286/how-can-i-style-external-links-like-wikipedia | |||||
| */ | |||||
| a[href^="//"]:after, | |||||
| a[href^="http://"]:after, | |||||
| a[href^="https://"]:after { | |||||
| content: url(/external-link.png); | |||||
| margin: 0 0 0 5px; | |||||
| } | |||||
| h1 | h1 | ||||
| { | { | ||||
| margin-top: 20px; | margin-top: 20px; | ||||
| @@ -273,3 +284,8 @@ tr | |||||
| .letter_index a { | .letter_index a { | ||||
| margin: 0 10px 0 0; | margin: 0 10px 0 0; | ||||
| } | } | ||||
| #candidate_bio img { | |||||
| float: left; | |||||
| margin: 0 15px 15px 0; | |||||
| } | |||||
| @@ -22,13 +22,24 @@ | |||||
| %table | %table | ||||
| - Candidacy.all(:election => @election, :district => @district).each do |c| | - Candidacy.all(:election => @election, :district => @district).each do |c| | ||||
| - campaign = Campaign.first(:party => c.party, :election => @election) | |||||
| %tr.vcard | %tr.vcard | ||||
| %td{ :style => "background-color: #{c.party.colour}" } | %td{ :style => "background-color: #{c.party.colour}" } | ||||
| %td.candidate_name.fn | %td.candidate_name.fn | ||||
| %a{ :href => "/candidates/#{c.candidate.id}" } | %a{ :href => "/candidates/#{c.candidate.id}" } | ||||
| = c.candidate.short_name | = c.candidate.short_name | ||||
| %td.org | %td.org | ||||
| = party_name(c.labcoop, c.party.name) | |||||
| - if campaign && campaign.party_url | |||||
| %a{ :href => campaign.party_url } | |||||
| = party_name(c.labcoop, c.party.name) | |||||
| - else | |||||
| = party_name(c.labcoop, c.party.name) | |||||
| %td | |||||
| - if campaign && campaign.manifesto_html_url | |||||
| %a{ :href => campaign.manifesto_html_url } | |||||
| manifesto | |||||
| - else | |||||
| | |||||
| -# TODO % turnout plotted over time | -# TODO % turnout plotted over time | ||||
| -# TODO map of district shown within Sutton boundary | -# TODO map of district shown within Sutton boundary | ||||