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.
 
 
 
 

59 lines
954 B

  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'sinatra-helpers/haml/partials'
  4. require 'haml'
  5. require 'pat'
  6. require 'lib/models'
  7. get '/' do
  8. haml :home
  9. end
  10. get '/wards/:id' do
  11. @ward = Ward.get(params[:id])
  12. haml :wards
  13. end
  14. get '/wards' do
  15. @postcode = params[:postcode].strip.upcase
  16. result = Pat.get(@postcode)
  17. # Invalid postcode
  18. if result.code == 404
  19. redirect '/error'
  20. end
  21. # Postcode valid but not in LB Sutton
  22. if result['administrative']['district']['title'] != "Sutton London Borough Council"
  23. redirect '/aliens'
  24. end
  25. # Postcode in LB Sutton
  26. @ward = Ward.first( :name => result['administrative']['ward']['title'] )
  27. haml :wards
  28. end
  29. get '/how-the-council-election-works' do
  30. haml :election
  31. end
  32. get '/how-the-parliament-election-works' do
  33. haml :parliament
  34. end
  35. # get '/voting' do
  36. # haml :voting
  37. # end
  38. get '/error' do
  39. haml :error
  40. end
  41. get '/about' do
  42. haml :about
  43. end
  44. get '/aliens' do
  45. haml :aliens
  46. end