Browse Source

Add external links for party websites and manifestos

tags/last-sinatra-version
Adrian Short 10 years ago
parent
commit
4584019111
4 changed files with 44 additions and 2 deletions
  1. +16
    -1
      models.rb
  2. BIN
      public/external-link.png
  3. +16
    -0
      public/style.css
  4. +12
    -1
      views/district.haml

+ 16
- 1
models.rb View File

@@ -107,6 +107,19 @@ class Candidacy
belongs_to :district
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
include DataMapper::Resource

@@ -119,7 +132,8 @@ class Election
has n, :candidacies
has n, :polls
belongs_to :body
has n, :campaigns

def self.past
self.all(:d.lt => Time.now.to_s, :order => [ :d.desc ])
end
@@ -170,6 +184,7 @@ class Party
property :colour, String
has n, :candidacies
has n, :campaigns
end

# These models are now redundant


BIN
public/external-link.png View File

Before After
Width: 12  |  Height: 12  |  Size: 144 B

+ 16
- 0
public/style.css View File

@@ -91,6 +91,17 @@ a:hover
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
{
margin-top: 20px;
@@ -273,3 +284,8 @@ tr
.letter_index a {
margin: 0 10px 0 0;
}

#candidate_bio img {
float: left;
margin: 0 15px 15px 0;
}

+ 12
- 1
views/district.haml View File

@@ -22,13 +22,24 @@

%table
- Candidacy.all(:election => @election, :district => @district).each do |c|
- campaign = Campaign.first(:party => c.party, :election => @election)
%tr.vcard
%td{ :style => "background-color: #{c.party.colour}" }  
%td.candidate_name.fn
%a{ :href => "/candidates/#{c.candidate.id}" }
= c.candidate.short_name
%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 map of district shown within Sutton boundary


Loading…
Cancel
Save