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.
 
 
 
 

36 líneas
1.0 KiB

  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