Election results in the London Borough of Sutton.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.1 KiB

  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'pat'
  4. require 'dm-core'
  5. require 'dm-validations'
  6. require 'dm-timestamps'
  7. require 'lib/models'
  8. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  9. DataMapper.auto_upgrade!
  10. get '/' do
  11. @wards = Ward.all( :order => 'name' )
  12. haml :home
  13. end
  14. get '/wards/:id' do
  15. @ward = Ward.get(params[:id])
  16. @candidates = Councilcandidate.all( :ward_id => @ward.id, :order => 'surname' )
  17. haml :wards
  18. end
  19. get '/wards' do
  20. @postcode = params[:postcode].strip.upcase
  21. result = Pat.get(@postcode)
  22. @district_name = result['administrative']['district']['title']
  23. @ward_name = result['administrative']['ward']['title']
  24. @ward = Ward.first( :name => @ward_name )
  25. @candidates = Councilcandidate.all( :ward_id => @ward.id, :order => 'surname')
  26. haml :wards
  27. end
  28. get '/how-the-election-works' do
  29. haml :election
  30. end
  31. # get '/voting' do
  32. # haml :voting
  33. # end
  34. get '/about' do
  35. @accounts = %w{
  36. adrianshort
  37. mashthestate
  38. openlylocal
  39. openelection
  40. lbsuttonnews
  41. stef
  42. stonecothill
  43. sutmoblib
  44. mysociety
  45. pezholio
  46. stonecotparking
  47. }
  48. haml :about
  49. end