| @@ -218,70 +218,5 @@ class Party | |||||
| has n, :campaigns | has n, :campaigns | ||||
| end | end | ||||
| # These models are now redundant | |||||
| class Ward | |||||
| include DataMapper::Resource | |||||
| property :id, Serial | |||||
| property :slug, String, :required => true | |||||
| property :ons_id, String, :required => true | |||||
| property :name, String, :required => true | |||||
| property :constituency_id, Integer, :required => true | |||||
| has n, :councilcandidates, :order => ['surname'] | |||||
| belongs_to :constituency | |||||
| def self.slugify(name) | |||||
| name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase | |||||
| end | |||||
| end | |||||
| class Councilcandidate | |||||
| include DataMapper::Resource | |||||
| property :id, Serial | |||||
| property :ward_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, :required => true | |||||
| property :votes_2010, Integer | |||||
| belongs_to :party | |||||
| belongs_to :ward | |||||
| end | |||||
| class Parliamentcandidate | |||||
| 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 :votes_2010, Integer | |||||
| property :votes_2005, Integer | |||||
| property :percent_2005, Float | |||||
| belongs_to :party | |||||
| belongs_to :constituency | |||||
| end | |||||
| class Constituency | |||||
| include DataMapper::Resource | |||||
| property :id, Serial | |||||
| property :name, String, :required => true | |||||
| has n, :wards, :order => ['name'] | |||||
| has n, :parliamentcandidates, :order => ['surname'] | |||||
| end | |||||
| DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://postgres@localhost:5432/suttonelections") | DataMapper.setup(:default, ENV['DATABASE_URL'] || "postgres://postgres@localhost:5432/suttonelections") | ||||
| DataMapper.auto_upgrade! | DataMapper.auto_upgrade! | ||||