diff --git a/app.rb b/app.rb
index 00f98d9..dcf0b10 100644
--- a/app.rb
+++ b/app.rb
@@ -72,6 +72,15 @@ get '/' do
# Postcode is valid and in LB Sutton
@ward = Ward.get(@p.ward_id)
flash[:notice] = "Postcode #{@postcode} is in #{@ward.name} ward"
+
+ if @p.polling_station
+ @ps_postcode = Postcode.get(@p.polling_station.postcode)
+ flash[:polling_station] = "Your polling station is \
+ %s, %s, %s" \
+ % [ @ps_postcode.lat, @ps_postcode.lng, @p.polling_station.name, \
+ @p.polling_station.address, @p.polling_station.postcode]
+ end
+
redirect "/bodies/sutton-council/wards/#{@ward.slug}"
else
flash.now[:error] = "#{@postcode} is not a postcode in Sutton"
diff --git a/models.rb b/models.rb
index 705983d..da8b2e9 100644
--- a/models.rb
+++ b/models.rb
@@ -17,6 +17,21 @@ class Poll
belongs_to :district
end
+class PollingStation
+ include DataMapper::Resource
+
+ property :id, String, :key => true, :length => 2 # e.g. "KA"
+ property :name, String, :length => 255#, :required => true
+ property :address, String, :length => 255#, :required => true
+ property :postcode, String#, :required => true
+ property :easting, Float, :required => true
+ property :northing, Float, :required => true
+ property :lat, Float, :required => true
+ property :lng, Float, :required => true
+
+ has n, :postcodes
+end
+
class Postcode
include DataMapper::Resource
@@ -36,8 +51,10 @@ class Postcode
property :lng, Float, :required => true
property :ward_id, Integer, :required => true # Sutton Council
property :constituency_id, Integer, :required => false # UK Parliament
+ property :polling_station_id, String, :length => 2
belongs_to :district, :child_key => [:ward_id]
+ belongs_to :polling_station
def self.finder(postcode)
postcode = postcode.strip.upcase
diff --git a/public/style.css b/public/style.css
index 9002150..b2a339d 100644
--- a/public/style.css
+++ b/public/style.css
@@ -289,3 +289,9 @@ tr
float: left;
margin: 0 15px 15px 0;
}
+
+#polling_station {
+ background-color: beige;
+ border: 1px solid green;
+ padding: 20px 20px;
+}
\ No newline at end of file
diff --git a/views/district.haml b/views/district.haml
index 9d479e4..899e119 100644
--- a/views/district.haml
+++ b/views/district.haml
@@ -1,3 +1,13 @@
+
+- if flash[:polling_station]
+ %p
+ #polling_station
+ %h2 Where to vote
+ %p
+ = flash[:polling_station]
+ %p Polling stations are open from 7AM to 10PM on Thursday 22 May 2014.
+ %p You don't need your poll card to vote. Just tell the staff your name and address.
+
- @page_title = "#{@district.name} #{@district.body.district_name}, #{@district.body.name}"
.nav