summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
a8006b0)
beginning a method that will allow users to track the QuickVotes they create.
14 files changed:
class GruffGraff
def initialize(options)
class GruffGraff
def initialize(options)
+ size = options[:size] ? options[:size] : "400x300" #allow custom sizing
@graph = options[:graph_type].new(size)
@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)
@graph.font = File.expand_path('/usr/X11R6/lib/X11/fonts/TTF/Vera.ttf',
RAILS_ROOT)
:data => data,
:interval_labels => labels,
:title => "Voters Over Time",
:data => data,
:interval_labels => labels,
:title => "Voters Over Time",
:x_axis_label => scale,
:y_axis_label => "Number of Votes")
send_data(*graph.output)
:x_axis_label => scale,
:y_axis_label => "Number of Votes")
send_data(*graph.output)
require_dependency "quick_vote"
require_dependency "vote"
require_dependency "election"
require_dependency "quick_vote"
require_dependency "vote"
require_dependency "election"
#############################################################
# the following methods pertain to creating quickvotes
#############################################################
#############################################################
# the following methods pertain to creating quickvotes
#############################################################
@candidates = {}
@election.candidates.each {|c| @candidates[c.id] = c}
end
@candidates = {}
@election.candidates.each {|c| @candidates[c.id] = c}
end
if name =~ /^(create|index|confirm|change|results)$/
errors.add(:name, " is a reserved word.")
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)
end
def candidatelist=(candlist)
<% fields_for 'quickvote', quickvote do |quickform| %>
<span><label for="quickvote_election_method">Election Method</span><br />
<% 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 />
%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 />
<% victories = @election.condorcet_result.victories_and_ties %>
<% names = @election.names_by_id %>
<% 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">
<!-- This table shows how many times each choice was ranked above the other,
with percentages-->
<table class="voterbox">
<% else -%>
(<%= margin%>)
<% end -%>
<% else -%>
(<%= margin%>)
<% end -%>
<% end -%>
</tr>
<% end -%>
</table>
<% end -%>
</tr>
<% end -%>
</table>
<h3>Approval Result</h3>
<p><font size="-1">(This algorithm assumes that top two choices are "approved.")</font></p>
<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>
<div class="rbmoreinfo">
<h4>About Approval Voting</h4>
range that voters are allowed to express is extremely constrained:
accept or not.</p>
range that voters are allowed to express is extremely constrained:
accept or not.</p>
</div>
\ No newline at end of file
</div>
\ No newline at end of file
<h3>Borda Count Results</h3>
<h3>Borda Count Results</h3>
+<%= render :partial => 'result', :object => @election.borda_result %>
+
<div class="rbmoreinfo">
<h4>About Borda Count</h4>
<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>
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 ) ) %>
<h3>Simple Condorcet Results</h3>
<h3>Simple Condorcet Results</h3>
+<%= render :partial => 'result', :object => @election.condorcet_result %>
+
<div class="rbmoreinfo">
<h4>About Simple Cordorcet Voting</h4>
<div class="rbmoreinfo">
<h4>About Simple Cordorcet Voting</h4>
another Condorcet system.</p>
</div>
another Condorcet system.</p>
</div>
-</div>
\ No newline at end of file
<h3>Plurality Results</h3>
<h3>Plurality Results</h3>
+<%= render :partial => 'result', :object => @election.plurality_result %>
+
<div class="rbmoreinfo">
<h4>About Plurality Voting</h4>
<div class="rbmoreinfo">
<h4>About Plurality Voting</h4>
-</div>
\ No newline at end of file
+<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
-<div class="mainresultbox">
<h3>Schulze Method Results</h3>
<h3>Schulze Method Results</h3>
+<%= render :partial => 'result', :object => @election.ssd_result %>
+
<div class="rbmoreinfo">
<h4>About the Schulze Method</h4>
<div class="rbmoreinfo">
<h4>About the Schulze Method</h4>
Beatpath Winner, Path Voting, and Path Winner.</p>
</div>
Beatpath Winner, Path Voting, and Path Winner.</p>
</div>
+<%= render :partial => 'pref_tables' %>
+
+<div class="mainresultbox">
<%= render :partial => 'result_' + @election.election_method,
:object => @results[@election.election_method] %>
<%= render :partial => 'result_' + @election.election_method,
:object => @results[@election.election_method] %>
<h3> Other Voting Methods </h3>
<% for result_type in @election.other_methods %>
<h3> Other Voting Methods </h3>
<% for result_type in @election.other_methods %>
<%= render :partial => 'result_' + result_type,
:object => @results[result_type] %>
<%= render :partial => 'result_' + result_type,
:object => @results[result_type] %>
-<%= render :partial => 'pref_tables' %>
-
<%=image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
<br />
<%=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 => '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>
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>
<p>Recent <em>QuickVotes</em> include:</p>
<ul>
<h2>Selectricity <em>Anywhere</em></h2>
<p>You can also access Selectricity entirely over email or via SMS/text
<h2>Selectricity <em>Anywhere</em></h2>
<p>You can also access Selectricity entirely over email or via SMS/text
color: #fff;
border-bottom: 0px;
}
color: #fff;
border-bottom: 0px;
}
.resultbox {
text-align: center;
width: 400px;
.resultbox {
text-align: center;
width: 400px;
require File.dirname(__FILE__) + '/../test_helper'
class QuickVoteTest < Test::Unit::TestCase
require File.dirname(__FILE__) + '/../test_helper'
class QuickVoteTest < Test::Unit::TestCase