Election results in the London Borough of Sutton.
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. require './app'
  2. require 'pp'
  3. # Load wards as districts
  4. # Ward.all.each do |ward|
  5. # District.create(
  6. # :body_id => 1,
  7. # :name => ward.name,
  8. # :slug => ward.slug
  9. # )
  10. # end
  11. # Load constituencies as districts
  12. # Constituency.all.each do |c|
  13. # District.create(
  14. # :body_id => 2,
  15. # :name => c.name,
  16. # :slug => c.name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  17. # )
  18. # end
  19. # Load council candidates as candidates
  20. # Councilcandidate.all.each do |old_c|
  21. # new_c = Candidate.create!(
  22. # :forenames => old_c.forenames,
  23. # :surname => old_c.surname,
  24. # )
  25. #
  26. # if new_c.saved?
  27. # puts "Created %s OK" % new_c.surname
  28. # else
  29. # pp new_c
  30. # end
  31. #
  32. # candidacy = Candidacy.create!(
  33. # :election_id => 1,
  34. # :candidate => new_c,
  35. # :party_id => old_c.party_id,
  36. # :district => District.first(:slug => old_c.ward.slug),
  37. # :votes => old_c.votes_2010,
  38. # :address => old_c.address,
  39. # :postcode => old_c.postcode
  40. # )
  41. #
  42. # if candidacy.saved?
  43. # puts "Candidacy created ok"
  44. # else
  45. # pp candidacy
  46. # end
  47. # end
  48. # Load parliamentary candidates
  49. Parliamentcandidate.all.each do |old_c|
  50. new_c = Candidate.first_or_create(
  51. :forenames => old_c.forenames,
  52. :surname => old_c.surname,
  53. )
  54. if new_c.saved?
  55. puts "Created %s OK" % new_c.surname
  56. else
  57. pp new_c
  58. end
  59. unless old_c.votes_2010.nil?
  60. candidacy = Candidacy.create!(
  61. :election_id => 2,
  62. :candidate => new_c,
  63. :party_id => old_c.party_id,
  64. :district_id => old_c.constituency_id == 1 ? 19 : 20,
  65. :votes => old_c.votes_2010,
  66. :address => old_c.address,
  67. :postcode => old_c.postcode
  68. )
  69. end
  70. if candidacy.saved?
  71. puts "2010 candidacy created ok"
  72. else
  73. pp candidacy
  74. end
  75. end