Election results in the London Borough of Sutton.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

68 rader
1.4 KiB

  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'haml'
  4. require 'pat'
  5. require 'dm-core'
  6. require 'dm-validations'
  7. require 'dm-timestamps'
  8. require 'lib/models'
  9. get '/' do
  10. haml :home
  11. end
  12. get '/wards/:id' do
  13. @ward = Ward.get(params[:id])
  14. @council_candidates = Councilcandidate.all( :ward_id => @ward.id, :order => [ 'surname' ] )
  15. @parly_candidates = Parliamentcandidate.all( :constituency_id => @ward.constituency.id, :order => [ 'surname' ])
  16. haml :wards
  17. end
  18. get '/wards' do
  19. @postcode = params[:postcode].strip.upcase
  20. # Postcode not found/invalid
  21. # Postcode valid but not in LB Sutton
  22. unless result = Pat.get(@postcode)
  23. redirect '/error'
  24. end
  25. @district_name = result['administrative']['district']['title']
  26. @ward_name = result['administrative']['ward']['title']
  27. @ward = Ward.first( { :name => @ward_name } )
  28. @council_candidates = Councilcandidate.all( :ward_id => @ward.id, :order => [ 'surname' ])
  29. @parly_candidates = Parliamentcandidate.all( :constituency_id => @ward.constituency.id, :order => [ 'surname' ])
  30. haml :wards
  31. end
  32. get '/how-the-council-election-works' do
  33. haml :election
  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. @accounts = %w{
  43. adrianshort
  44. stef
  45. pezholio
  46. countculture
  47. understood
  48. mashthestate
  49. openlylocal
  50. openelection
  51. lbsuttonnews
  52. suttongisteam
  53. stonecothill
  54. sutmoblib
  55. mysociety
  56. }
  57. haml :about
  58. end