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.
 
 
 
 

90 lignes
1.8 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 '/results/uk-parliament/2010-05-06/:constituency' do
  37. if params[:constituency] == 'carshalton-and-wallington'
  38. const = 1
  39. else
  40. const = 2
  41. end
  42. @constituency = Constituency.get(const)
  43. @candidates = Parliamentcandidate.all(:constituency_id => const, :order => [ :votes_2010.desc ])
  44. @total_2010 = Parliamentcandidate.sum(:votes_2010, :constituency_id => const)
  45. haml :resultsukparliament
  46. end
  47. get '/results/sutton-council/2010-05-06/:slug' do
  48. @ward = Ward.first(:slug => params[:slug])
  49. @candidates = Councilcandidate.all(:ward => @ward, :order => [ :votes_2010.desc ])
  50. @total_2010 = Councilcandidate.sum(:votes_2010, :ward_id => @ward.id)
  51. haml :resultssuttoncouncil
  52. end
  53. get '/how-the-council-election-works' do
  54. haml :election
  55. end
  56. get '/how-the-parliament-election-works' do
  57. haml :parliament
  58. end
  59. # get '/voting' do
  60. # haml :voting
  61. # end
  62. get '/error' do
  63. haml :error
  64. end
  65. get '/about' do
  66. haml :about
  67. end
  68. get '/aliens' do
  69. haml :aliens
  70. end
  71. not_found do
  72. haml :not_found
  73. end