Election results in the London Borough of Sutton.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

68 lignes
1.1 KiB

  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'sinatra-helpers/haml/partials'
  4. require 'haml'
  5. require 'lib/models'
  6. get '/' do
  7. if params[:postcode]
  8. @postcode = params[:postcode].strip.upcase
  9. unless result = Postcode.finder(@postcode)
  10. # Invalid postcode
  11. redirect '/error'
  12. end
  13. # Postcode valid but not in LB Sutton
  14. if result.district_code != "00BF"
  15. redirect '/aliens'
  16. end
  17. # Postcode in LB Sutton
  18. @ward = Ward.first( :ons_id => result.ward_code )
  19. redirect "/wards/#{@ward.slug}/postcode/#{@postcode}"
  20. end
  21. haml :home
  22. end
  23. get '/wards/:slug/postcode/:postcode/?' do
  24. @ward = Ward.first(:slug => params[:slug])
  25. @postcode = params[:postcode]
  26. haml :wards
  27. end
  28. get '/wards/:slug/?' do
  29. @ward = Ward.first(:slug => params[:slug])
  30. haml :wards
  31. end
  32. get '/wards/?' do
  33. @wards = Ward.all
  34. haml :wardlist
  35. end
  36. get '/how-the-council-election-works' do
  37. haml :election
  38. end
  39. get '/how-the-parliament-election-works' do
  40. haml :parliament
  41. end
  42. # get '/voting' do
  43. # haml :voting
  44. # end
  45. get '/error' do
  46. haml :error
  47. end
  48. get '/about' do
  49. haml :about
  50. end
  51. get '/aliens' do
  52. haml :aliens
  53. end