From: Date: Wed, 16 Aug 2006 04:51:17 +0000 (-0400) Subject: Fixed the detailed results so that they return anonymized results in X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/1260415e640fec24f8c970ae8e61f4a7ab4594d4 Fixed the detailed results so that they return anonymized results in aphabetical order and display vote information correct (as per tests at least). --- diff --git a/app/controllers/elections_controller.rb b/app/controllers/elections_controller.rb index 339c77b..4a85c29 100644 --- a/app/controllers/elections_controller.rb +++ b/app/controllers/elections_controller.rb @@ -105,12 +105,20 @@ class ElectionsController < ApplicationController def detailed_results @election = Election.find( params[:id] ) - @voting_rolls = [] + + @voter_list = [] + @vote_list = [] @election.voters.each do |voter| if voter.vote and voter.vote.confirmed? - @voting_rolls << voter + @voter_list << voter.email + @vote_list << voter.vote end end + + @vote_list.sort! + @vote_list.sort! { |a,b| a.token <=> b.token } + #breakpoint + end private diff --git a/app/models/candidate.rb b/app/models/candidate.rb index dfc8b1f..e17ba29 100644 --- a/app/models/candidate.rb +++ b/app/models/candidate.rb @@ -2,7 +2,7 @@ class Candidate < ActiveRecord::Base belongs_to :election def <=>(other) - self.name <=> other.name + self.name <=> other.name end def to_s diff --git a/app/models/ranking.rb b/app/models/ranking.rb index 4b96b54..ba021a9 100644 --- a/app/models/ranking.rb +++ b/app/models/ranking.rb @@ -6,4 +6,8 @@ class Ranking < ActiveRecord::Base self.rank <=> other.rank end + def to_s + self.rank.to_s + end + end diff --git a/app/views/elections/detailed_results.rhtml b/app/views/elections/detailed_results.rhtml index 48296d6..cfb0e5a 100644 --- a/app/views/elections/detailed_results.rhtml +++ b/app/views/elections/detailed_results.rhtml @@ -1,29 +1,35 @@ -

The voting rolls for the last election are are follows.

+<% %> + +

The voting rolls -- displayed here in alphabetical order -- for the +last election are are follows.

Voters

-<% for voter in @voting_rolls.randomize %> +<% for email in @voter_list %> - + <% end %>
<%= voter.email %><%= email %>

Votes (by Token)

+ +

The votes, listed in alphabetical order by token.

+ -<% for candidate in @election.candidates.sort %> +<% for candidate in @election.candidates.sort.reverse %> <% end %> -<% for voter in @voting_rolls.randomize %> +<% for vote in @vote_list %> - -<% for ranking in voter.vote %> + +<% for ranking in vote.rankings %> <% end %>
Token Rank of Candidates
<%= candidate %>
<%= voter.vote.token %><%= vote.token %><%= ranking %>