Election results in the London Borough of Sutton.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 

58 satır
1.3 KiB

  1. require 'rubygems'
  2. require 'sinatra'
  3. require 'sinatra-helpers/haml/partials'
  4. require 'haml'
  5. require 'pat'
  6. require 'dm-core'
  7. require 'dm-validations'
  8. require 'dm-timestamps'
  9. require 'lib/models'
  10. get '/' do
  11. haml :home
  12. end
  13. get '/wards/:id' do
  14. @ward = Ward.get(params[:id])
  15. @council_candidates = Councilcandidate.all( :ward_id => @ward.id, :order => [ 'surname' ] )
  16. @parly_candidates = Parliamentcandidate.all( :constituency_id => @ward.constituency.id, :order => [ 'surname' ])
  17. haml :wards
  18. end
  19. get '/wards' do
  20. @postcode = params[:postcode].strip.upcase
  21. # Postcode not found/invalid
  22. # Postcode valid but not in LB Sutton
  23. unless result = Pat.get(@postcode)
  24. redirect '/error'
  25. end
  26. @district_name = result['administrative']['district']['title']
  27. @ward_name = result['administrative']['ward']['title']
  28. @ward = Ward.first( { :name => @ward_name } )
  29. @council_candidates = Councilcandidate.all( :ward_id => @ward.id, :order => [ 'surname' ])
  30. @parly_candidates = Parliamentcandidate.all( :constituency_id => @ward.constituency.id, :order => [ 'surname' ])
  31. haml :wards
  32. end
  33. get '/how-the-council-election-works' do
  34. haml :election
  35. end
  36. get '/how-the-parliament-election-works' do
  37. haml :parliament
  38. end
  39. # get '/voting' do
  40. # haml :voting
  41. # end
  42. get '/error' do
  43. haml :error
  44. end
  45. get '/about' do
  46. haml :about
  47. end