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.
 
 
 
 

59 lignes
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