@@ -42,6 +42,18 @@ get '/wards/?' do | |||||
haml :wardlist | haml :wardlist | ||||
end | end | ||||
get '/results/uk-parliament/2010-05-06/:constituency' do | |||||
if params[:constituency] == 'carshalton-and-wallington' | |||||
const = 1 | |||||
else | |||||
const = 2 | |||||
end | |||||
@constituency = Constituency.get(const) | |||||
@candidates = Parliamentcandidate.all(:constituency_id => const, :order => [ :votes_2010.desc ]) | |||||
@total_2010 = Parliamentcandidate.sum(:votes_2010, :constituency_id => const) | |||||
haml :resultsukparliament | |||||
end | |||||
get '/how-the-council-election-works' do | get '/how-the-council-election-works' do | ||||
haml :election | haml :election | ||||
end | end | ||||
@@ -1,6 +1,7 @@ | |||||
require 'dm-core' | require 'dm-core' | ||||
require 'dm-validations' | require 'dm-validations' | ||||
require 'dm-timestamps' | require 'dm-timestamps' | ||||
require 'dm-aggregates' | |||||
require 'pat' | require 'pat' | ||||
class Postcode | class Postcode | ||||
@@ -91,13 +92,17 @@ end | |||||
class Parliamentcandidate | class Parliamentcandidate | ||||
include DataMapper::Resource | include DataMapper::Resource | ||||
property :id, Serial | |||||
property :constituency_id, Integer, :required => true | |||||
property :party_id, Integer, :required => true | |||||
property :forenames, String, :required => true | |||||
property :surname, String, :required => true | |||||
property :address, String, :length => 200 | |||||
property :postcode, String | |||||
property :id, Serial | |||||
property :constituency_id, Integer, :required => true | |||||
property :party_id, Integer, :required => true | |||||
property :forenames, String, :required => true | |||||
property :surname, String, :required => true | |||||
property :address, String, :length => 200 | |||||
property :postcode, String | |||||
property :votes_2010, Integer | |||||
property :votes_2005, Integer | |||||
property :percent_2005, Float | |||||
belongs_to :party | belongs_to :party | ||||
belongs_to :constituency | belongs_to :constituency | ||||
@@ -101,4 +101,14 @@ form | |||||
strong | strong | ||||
{ | { | ||||
color: #000; | color: #000; | ||||
} | |||||
td, th | |||||
{ | |||||
padding: 0 15px 15px 0; | |||||
} | |||||
.right | |||||
{ | |||||
text-align: right; | |||||
} | } |
@@ -22,4 +22,3 @@ | |||||
%input{ :type => 'submit', :value => "Find it" } | %input{ :type => 'submit', :value => "Find it" } | ||||
.grid_3 | .grid_3 | ||||
<iframe src="http://www.thestraightchoice.org/api/call.php?method=constituency&output=html&constituency=sutton_and_cheam&count=2" style="border:none; overflow:hidden;height: 800px;"></iframe> |