]> projects.mako.cc - selectricity-live/commitdiff
small number of cosmetic fixes to quickvotes and a minor bugfix that had
author<mako@atdot.cc> <>
Mon, 16 Oct 2006 13:45:41 +0000 (09:45 -0400)
committer<mako@atdot.cc> <>
Mon, 16 Oct 2006 13:45:41 +0000 (09:45 -0400)
confused Condorcet and the Schulze Method for QuickVotes

app/controllers/quickvote_controller.rb
app/models/vote.rb
app/views/quickvote/_candidate_list.rhtml
app/views/quickvote/create.rhtml
config/environment.rb

index c897f369f33018bd9c3b5ffec552e20bdc0585ce..7c754746959b70573da798003fb63643b81ea899 100644 (file)
@@ -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
 
index 33927cd16db995528e15da3aa6ab943353d5bc09..f263a75bb687d332527bc5ce938ada35ab4eb9b2 100644 (file)
@@ -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
index 1176e9768d4afb7aa24b7c6d8a3646671226b574..5c76d62d8c3bd380cf39b254c0b423109270fc4f 100644 (file)
@@ -12,6 +12,6 @@
                     :url => { :action => 'add_candidate' } %>
 <p>
   <%= text_field "ajax", "newcandidate", :size => 40 %>
-  <%= submit_tag "Add" %>
+  <%= submit_tag "Add(+)" %>
 </p>
 <%= end_form_tag %>
index b4304953f1823e28f06e80b34b83cfe48b7ed45c..360a6900608f17d744064682bda738fe8763b41e 100644 (file)
@@ -13,7 +13,7 @@
 <%= form_tag :action => 'create' %>
 <!--[form:election]-->
 
-<p><label for="quickvote_name">Super-short name (for URL)<br />
+<p><label for="quickvote_name">One Word Description (for URL)<br />
 
 <em><font size="-1">required; 5-12 characters; only letters and numbers; no spaces</font></em></label><br/>
 
index f432b2dcb7e089cfa97d94bcce9907adfd019ab2..d97fd3b6ea3e45c6b91dbee361089bbc43e42fde 100644 (file)
@@ -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

Benjamin Mako Hill || Want to submit a patch?