Election results in the London Borough of Sutton.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

hace 14 años
hace 14 años
hace 14 años
hace 14 años
hace 14 años
hace 14 años
hace 14 años
hace 14 años
hace 14 años
hace 14 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. @results = repository(:default).adapter.query("
  22. SELECT p.name,
  23. sum(c.votes_2010) AS votes,
  24. p.colour
  25. FROM parties p,
  26. councilcandidates c
  27. WHERE p.id = c.party_id
  28. GROUP BY p.name, p.colour
  29. ORDER BY votes desc
  30. ;")
  31. # select p.name, count(c.*) AS seats
  32. # FROM parties p, councilcandidates c
  33. # GROUP BY p.id
  34. @total_votes = Councilcandidate.sum(:votes_2010)
  35. haml :home
  36. end
  37. get '/wards/:slug/postcode/:postcode/?' do
  38. @ward = Ward.first(:slug => params[:slug])
  39. @postcode = params[:postcode]
  40. haml :wards
  41. end
  42. get '/wards/:slug/?' do
  43. @ward = Ward.first(:slug => params[:slug])
  44. haml :wards
  45. end
  46. get '/wards/?' do
  47. @wards = Ward.all
  48. haml :wardlist
  49. end
  50. get '/results/uk-parliament/2010-05-06/:constituency' do
  51. if params[:constituency] == 'carshalton-and-wallington'
  52. const = 1
  53. else
  54. const = 2
  55. end
  56. @constituency = Constituency.get(const)
  57. @candidates = Parliamentcandidate.all(:constituency_id => const, :order => [ :votes_2010.desc ])
  58. @total_2010 = Parliamentcandidate.sum(:votes_2010, :constituency_id => const)
  59. haml :resultsukparliament
  60. end
  61. get '/results/sutton-council/2010-05-06/:slug' do
  62. @ward = Ward.first(:slug => params[:slug])
  63. @candidates = Councilcandidate.all(:ward_id => @ward.id, :order => [ :votes_2010.desc ])
  64. @total_2010 = Councilcandidate.sum(:votes_2010, :ward_id => @ward.id)
  65. haml :resultssuttoncouncil
  66. end
  67. get '/results/sutton-council/2010-05-06.csv' do
  68. @ward = Ward.first(:slug => params[:slug])
  69. @candidates = Councilcandidate.all(:ward_id => @ward.id, :order => [ :votes_2010.desc ])
  70. @total_2010 = Councilcandidate.sum(:votes_2010, :ward_id => @ward.id)
  71. haml :resultssuttoncouncil
  72. end
  73. get '/how-the-council-election-works' do
  74. haml :election
  75. end
  76. get '/how-the-parliament-election-works' do
  77. haml :parliament
  78. end
  79. # get '/voting' do
  80. # haml :voting
  81. # end
  82. get '/error' do
  83. haml :error
  84. end
  85. get '/about' do
  86. haml :about
  87. end
  88. get '/aliens' do
  89. haml :aliens
  90. end
  91. get '/wardmap' do
  92. haml :wardmap
  93. end
  94. not_found do
  95. haml :not_found
  96. end