beginning a method that will allow users to track the QuickVotes they create.
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)
: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)
require_dependency "quick_vote"
require_dependency "vote"
require_dependency "election"
-
+
#############################################################
# the following methods pertain to creating quickvotes
#############################################################
@candidates = {}
@election.candidates.each {|c| @candidates[c.id] = c}
end
+
+
end
-
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)
<% 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 %>
<% 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">
<% else -%>
(<%= margin%>)
<% end -%>
- </td>
+ </td>
<% end -%>
</tr>
<% end -%>
</table>
-
-<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>
range that voters are allowed to express is extremely constrained:
accept or not.</p>
-</div>
-
</div>
\ No newline at end of file
-<div class="resultbox">
<h3>Borda Count Results</h3>
+<%= render :partial => 'result', :object => @election.borda_result %>
+
<div class="rbmoreinfo">
<h4>About Borda Count</h4>
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 ) ) %>
-<div class="resultbox">
<h3>Simple Condorcet Results</h3>
+<%= render :partial => 'result', :object => @election.condorcet_result %>
+
<div class="rbmoreinfo">
<h4>About Simple Cordorcet Voting</h4>
another Condorcet system.</p>
</div>
-</div>
\ No newline at end of file
-<div class="resultbox">
<h3>Plurality Results</h3>
+<%= render :partial => 'result', :object => @election.plurality_result %>
+
<div class="rbmoreinfo">
<h4>About Plurality Voting</h4>
voting.</p>
</div>
-</div>
\ No newline at end of file
+<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
-<div class="mainresultbox">
<h3>Schulze Method Results</h3>
+<%= render :partial => 'result', :object => @election.ssd_result %>
+
<div class="rbmoreinfo">
<h4>About the Schulze Method</h4>
Beatpath Winner, Path Voting, and Path Winner.</p>
</div>
-</div>
+<%= render :partial => 'pref_tables' %>
+
<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 ) )%>
+
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>
<% end %>
</ul>
+
+
<h2>Selectricity <em>Anywhere</em></h2>
<p>You can also access Selectricity entirely over email or via SMS/text
color: #fff;
border-bottom: 0px;
}
+
.resultbox {
text-align: center;
width: 400px;
require File.dirname(__FILE__) + '/../test_helper'
class QuickVoteTest < Test::Unit::TestCase
+ fixtures :quickvote
def correct_enddate
-
+ true
end