From: Date: Mon, 16 Oct 2006 13:45:41 +0000 (-0400) Subject: small number of cosmetic fixes to quickvotes and a minor bugfix that had X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/49997d3063f434e33e64040fdb57ba30f4e4c2a8?ds=sidebyside;hp=8dc61228b74613a5e585ef0a8cf7b4352e208717 small number of cosmetic fixes to quickvotes and a minor bugfix that had confused Condorcet and the Schulze Method for QuickVotes --- diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index c897f36..7c75474 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -158,8 +158,8 @@ class QuickvoteController < ApplicationController @plurality_result = PluralityVote.new(plurality_tally).result @approval_result = ApprovalVote.new(approval_tally).result - @condorcet_result = CloneproofSSDVote.new(preference_tally).result - @ssd_result = PureCondorcetVote.new(preference_tally).result + @condorcet_result = PureCondorcetVote.new(preference_tally).result + @ssd_result = CloneproofSSDVote.new(preference_tally).result @borda_result = BordaVote.new(preference_tally).result @runoff_result = InstantRunoffVote.new(preference_tally).result diff --git a/app/models/vote.rb b/app/models/vote.rb index 33927cd..f263a75 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -77,7 +77,15 @@ class Vote < ActiveRecord::Base end def votestring - self.votes.join("") + # create a mapping of candidates ids and the relative order of the + # candidates as they appear when sorted alphabetically + cand_relnums = {} + self.voter.election.candidates.sort.each_with_index do |c, i| + cand_relnums[c.id] = i + 1 + end + + # assemble the votestring + self.votes.collect {|v| cand_relnums[v]}.join("") end # the following subroutine is used for quickvotes. it creates a vote diff --git a/app/views/quickvote/_candidate_list.rhtml b/app/views/quickvote/_candidate_list.rhtml index 1176e97..5c76d62 100644 --- a/app/views/quickvote/_candidate_list.rhtml +++ b/app/views/quickvote/_candidate_list.rhtml @@ -12,6 +12,6 @@ :url => { :action => 'add_candidate' } %>

<%= text_field "ajax", "newcandidate", :size => 40 %> - <%= submit_tag "Add" %> + <%= submit_tag "Add(+)" %>

<%= end_form_tag %> diff --git a/app/views/quickvote/create.rhtml b/app/views/quickvote/create.rhtml index b430495..360a690 100644 --- a/app/views/quickvote/create.rhtml +++ b/app/views/quickvote/create.rhtml @@ -13,7 +13,7 @@ <%= form_tag :action => 'create' %> -


diff --git a/config/environment.rb b/config/environment.rb index f432b2d..d97fd3b 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -36,7 +36,7 @@ Rails::Initializer.run do |config| # config.active_record.observers = :cacher, :garbage_collector # Make Active Record use UTC-base instead of local time - # config.active_record.default_timezone = :utc + config.active_record.default_timezone = :utc # See Rails::Configuration for more options end