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
879 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. unless result = Postcode.finder(@postcode)
  17. # Invalid postcode
  18. redirect '/error'
  19. end
  20. # Postcode valid but not in LB Sutton
  21. if result.district_code != "00BF"
  22. redirect '/aliens'
  23. end
  24. # Postcode in LB Sutton
  25. @ward = Ward.first( :ons_id => result.ward_code )
  26. haml :wards
  27. end
  28. get '/how-the-council-election-works' do
  29. haml :election
  30. end
  31. get '/how-the-parliament-election-works' do
  32. haml :parliament
  33. end
  34. # get '/voting' do
  35. # haml :voting
  36. # end
  37. get '/error' do
  38. haml :error
  39. end
  40. get '/about' do
  41. haml :about
  42. end
  43. get '/aliens' do
  44. haml :aliens
  45. end