Election results in the London Borough of Sutton.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435
  1. require './models'
  2. desc "Set the candidate positions for an election (will prompt you for election ID)."
  3. task :set_positions do
  4. Election.all.each do |e|
  5. puts "%d %s %s" % [ e.id, e.d, e.body.name ]
  6. end
  7. puts "Which election ID?"
  8. STDOUT.flush
  9. id = STDIN.gets.chomp.to_i
  10. if e = Election.get(id)
  11. puts "%d %s %s" % [ e.id, e.d,e.body.name ]
  12. e.polls.each do |poll|
  13. poll.set_positions
  14. separator = '-' * poll.district.name.size
  15. puts
  16. puts separator
  17. puts poll.district.name
  18. puts separator
  19. ccys = Candidacy.all(:conditions => { :district_id => poll.district_id, :election_id => e.id }, :order => [:votes.desc])
  20. ccys.each do |cand|
  21. puts "%-25s %-25s %-40s %5d %2d %s" % [ cand.candidate.surname, cand.candidate.forenames, cand.party.name, cand.votes, cand.position, cand.seats == 1 ? 'elected' : '' ]
  22. end
  23. end
  24. else
  25. puts "Election ID #{id} not found."
  26. return 1
  27. end
  28. end