Allow custimizable graph sizes, to fit with newly modular results page. Also,
author<jlsharps@mit.edu> <>
Thu, 23 Aug 2007 19:20:00 +0000 (15:20 -0400)
committer<jlsharps@mit.edu> <>
Thu, 23 Aug 2007 19:20:00 +0000 (15:20 -0400)
beginning a method that will allow users to track the QuickVotes they create.

14 files changed:
app/controllers/graph_controller.rb
app/controllers/quickvote_controller.rb
app/models/quick_vote.rb
app/views/quickvote/_advanced.rhtml
app/views/quickvote/_pref_tables.rhtml
app/views/quickvote/_result_approval.rhtml
app/views/quickvote/_result_borda.rhtml
app/views/quickvote/_result_condorcet.rhtml
app/views/quickvote/_result_plurality.rhtml
app/views/quickvote/_result_ssd.rhtml
app/views/quickvote/results.rhtml
app/views/site/index.rhtml
public/stylesheets/main.css
test/unit/quickvote_test.rb

index 69577c6df84e1cf80566748993209eb145965027..814eb363c437a0074abea9113fdc7e30e4a1a455 100644 (file)
@@ -3,11 +3,13 @@ class GraphController < ApplicationController
   class GruffGraff
   
     def initialize(options)
-      size = "700x400"
+      size = options[:size] ? options[:size] : "400x300" #allow custom sizing
       @graph = options[:graph_type].new(size)
-
-      @graph.theme = { :colors => ['#000000', '#00FFFF', '#FFCC00', '#990033'],
-                       :background_colors => ['#74ce00', '#ffffff'] }
+      
+      @graph.no_data_message = "No Voters"
+      
+      @graph.theme = { :colors => ['#005CD9', '#DC0D13', '#131313', '#990033'],
+                       :background_colors => ['#74CE00', '#FFFFFF'] }
       @graph.font = File.expand_path('/usr/X11R6/lib/X11/fonts/TTF/Vera.ttf',
                                    RAILS_ROOT)
       
@@ -72,6 +74,7 @@ class GraphController < ApplicationController
                             :data => data,
                             :interval_labels => labels,
                             :title => "Voters Over Time",
+                            :size => "700x400",
                             :x_axis_label => scale,
                             :y_axis_label => "Number of Votes")
     send_data(*graph.output)
index 0d165cbd458c1f94f9d4569936c92e9bb80d9f80..031c0755adb2a7f38b2d8c1b9c7b632778d0c99d 100644 (file)
@@ -4,7 +4,7 @@ class QuickvoteController < ApplicationController
   require_dependency "quick_vote"
   require_dependency "vote"
   require_dependency "election"
-
+  
   #############################################################
   # the following methods pertain to creating quickvotes
   #############################################################
@@ -166,6 +166,7 @@ class QuickvoteController < ApplicationController
     @candidates = {}
     @election.candidates.each {|c| @candidates[c.id] = c}
   end
+  
+  
 end
 
-
index c04b0d7a3fe3a3539012ba45c50f4cc5632f2687..494f7ac364bfb6b7dd53226bce0f138f05c10c60 100644 (file)
@@ -47,6 +47,11 @@ class QuickVote < Election
     if name =~ /^(create|index|confirm|change|results)$/
       errors.add(:name, " is a reserved word.")
     end
+    
+    if enddate < startdate
+      errors.add(nil, "QuickVotes can't end before they start!")
+    end
+    
   end
 
   def candidatelist=(candlist)
index 5699fd06b82a60fa41a35f8647fd1d4ac158032f..3037ccc7c6b70e5a0d45adf846b9ac0a2b513d3b 100644 (file)
@@ -2,10 +2,10 @@
 <% fields_for 'quickvote', quickvote do |quickform| %>
 
 <span><label for="quickvote_election_method">Election Method</span><br />
-<%= quickform.select ('election_method', 
+<%= quickform.select('election_method', 
     %w(ssd condorcet plurality approval borda) ) %><br />
 
 <span><label for="quickvote_enddate">End Time</span><br />
-<%= quickform.date_select(:enddate) %><br />
+<%= quickform.date_select(:enddate, :start_year => Time.now.year) %><br />
 
 <% end %>
index 66e0cbf2df1fbf7870581ca6ed849b66db2c7f21..0d2b020f654c6de57a5f145d009da14c28e8d5d8 100644 (file)
@@ -4,7 +4,6 @@
 <% victories = @election.condorcet_result.victories_and_ties %>
 <% names = @election.names_by_id %>
 
-
 <!-- This table shows how many times each choice was ranked above the other, 
        with percentages-->
 <table class="voterbox">
@@ -46,9 +45,8 @@
                <% else -%>
                  (<%= margin%>)
                <% end -%>
-                 </td>
+       </td>
        <% end -%>
   </tr>
   <% end -%>
 </table>
-
index 12c7958741f67e47407483d683941eab63d00878..c93ce1d5a34f4952ea0e718260595c00308989a3 100644 (file)
@@ -1,7 +1,8 @@
-<div class="resultbox">
 <h3>Approval Result</h3>
 <p><font size="-1">(This algorithm assumes that top two choices are "approved.")</font></p>
 
+<%= render :partial => 'result', :object => @election.approval_result %>
+
 <div class="rbmoreinfo">
 <h4>About Approval Voting</h4>
 
@@ -12,6 +13,4 @@ chooses.  Approval voting is a limited form of range voting, where the
 range that voters are allowed to express is extremely constrained:
 accept or not.</p>
 
-</div>
-
 </div>
\ No newline at end of file
index 97d82e5eaa24902dccac39b5fe7625c3913a001d..f81cbdba2814bb7dc31209597d2dfa53e928b848 100644 (file)
@@ -1,6 +1,7 @@
-<div class="resultbox">
 <h3>Borda Count Results</h3>
 
+<%= render :partial => 'result', :object => @election.borda_result %>
+
 <div class="rbmoreinfo">
 <h4>About Borda Count</h4>
 
@@ -13,4 +14,4 @@ corresponding to the position in which he or she is ranked by each
 voter. Once all votes have been counted the candidate with the most
 points is the winner.</p>
 </div>
-</div>
\ No newline at end of file
+<%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %>
index 4279bbd1b2dfa0e004656e7cb772ba4344d72101..77ce6585f8bc88b7133d0d7ce150f263f836178f 100644 (file)
@@ -1,6 +1,7 @@
-<div class="resultbox">
 <h3>Simple Condorcet Results</h3>
 
+<%= render :partial => 'result', :object => @election.condorcet_result %>
+
 <div class="rbmoreinfo">
 <h4>About Simple Cordorcet Voting</h4>
 
@@ -15,4 +16,3 @@ will be the winner.</p>
 another Condorcet system.</p>
 
 </div>
-</div>
\ No newline at end of file
index 121c1dc9acac23f1d06ce4ab03c34f322ef4dcde..86a94691170027c538c96ec7755c1aab8adb843d 100644 (file)
@@ -1,6 +1,7 @@
-<div class="resultbox">
 <h3>Plurality Results</h3>
 
+<%= render :partial => 'result', :object => @election.plurality_result %>
+
 <div class="rbmoreinfo">
 <h4>About Plurality Voting</h4>
 
@@ -14,4 +15,4 @@ post," "winner-take-all," "majoritarian" or "simple majority"
 voting.</p>
 
 </div>
-</div>
\ No newline at end of file
+<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
index 436dd6701f3163229d53c070ef09128c731b1be4..e1811840828a9c52e19a629b45b92bc872ca5717 100644 (file)
@@ -1,6 +1,7 @@
-<div class="mainresultbox">
 <h3>Schulze Method Results</h3>
 
+<%= render :partial => 'result', :object => @election.ssd_result %>
+
 <div class="rbmoreinfo">
 <h4>About the Schulze Method</h4>
 
@@ -14,4 +15,5 @@ methods for resolving "circular" defeats.</p>
 Beatpath Winner, Path Voting, and Path Winner.</p>
 </div>
 
-</div>
+<%= render :partial => 'pref_tables' %>
+
index 9727d81289e6690597f298f4d5a0d8bb4a545e5e..0383b5e4434c0acfba9b9e391b16e463687b91b5 100644 (file)
 
 <h2>Winners</h2>
 
+<div class="mainresultbox">
 <%= render :partial => 'result_' + @election.election_method,
            :object => @results[@election.election_method] %>
-
+</div>
 
 <h3> Other Voting Methods </h3>
 <% for result_type in @election.other_methods %>
+<div class="resultbox">
 <%= render :partial => 'result_' + result_type, 
            :object => @results[result_type] %>
+</div>
 <% end %>
 
 
 <% end %>
 </table>
 
-<%= render :partial => 'pref_tables' %>
-
 <%=image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
 <br />
-<%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %><br />
+
 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %><br />
-<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
+
index 1b994b0e16ebf84e29e1b7df89c1c9298cb81e44..0c442189e1f573c463be20a72c1c884e88da303d 100644 (file)
@@ -11,8 +11,12 @@ without the complex features of <em>Selectricity</em>. They are the
 quickest way to make a decision or to compare between voting
 methods.</p>
 
-<p><%= link_to "Create a QuickVote", :controller => 'quickvote', :action => 'create' %></p>
+<p><%= link_to( "Create a QuickVote", :controller => 'quickvote',
+                :action => 'create') %></p>
 
+<p>Take a look at the QuickVotes you've made recently: <br />
+<%= link_to( "My Recent QuickVotes", :controller => 'quickvote',
+                :action => 'my_quickvotes')%></p>
 <p>Recent <em>QuickVotes</em> include:</p>
 
 <ul>
@@ -21,6 +25,8 @@ methods.</p>
 <% end %>
 </ul>
 
+
+
 <h2>Selectricity <em>Anywhere</em></h2>
 
 <p>You can also access Selectricity entirely over email or via SMS/text
index 86cf84b2ac856f01547ad20befc745c83d3e3fc9..5072139da2df3066848d748920a125c7d604f89c 100644 (file)
@@ -167,6 +167,7 @@ a:active { color: #FFFFFF; text-decoration: none; background: #0259C4; }
   color: #fff;
   border-bottom: 0px;
 }
+
 .resultbox {
   text-align: center;
   width: 400px;
index 4282a70ee88db0ba2b80135b29c3ca7ae2f37ce7..99274e4b7b2bd1b6c9ec14bb7294afe112eaf96d 100644 (file)
@@ -1,9 +1,10 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
 class QuickVoteTest < Test::Unit::TestCase
+  fixtures :quickvote
   
   def correct_enddate
-    
+    true
   end
   
   

Benjamin Mako Hill || Want to submit a patch?