From: Date: Thu, 23 Aug 2007 19:20:00 +0000 (-0400) Subject: Allow custimizable graph sizes, to fit with newly modular results page. Also, X-Git-Url: https://projects.mako.cc/source/selectricity-live/commitdiff_plain/823d530ba46c1fb3518c4deef0081738503837eb?ds=sidebyside Allow custimizable graph sizes, to fit with newly modular results page. Also, beginning a method that will allow users to track the QuickVotes they create. --- diff --git a/app/controllers/graph_controller.rb b/app/controllers/graph_controller.rb index 69577c6..814eb36 100644 --- a/app/controllers/graph_controller.rb +++ b/app/controllers/graph_controller.rb @@ -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) diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index 0d165cb..031c075 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -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 - diff --git a/app/models/quick_vote.rb b/app/models/quick_vote.rb index c04b0d7..494f7ac 100644 --- a/app/models/quick_vote.rb +++ b/app/models/quick_vote.rb @@ -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) diff --git a/app/views/quickvote/_advanced.rhtml b/app/views/quickvote/_advanced.rhtml index 5699fd0..3037ccc 100644 --- a/app/views/quickvote/_advanced.rhtml +++ b/app/views/quickvote/_advanced.rhtml @@ -2,10 +2,10 @@ <% fields_for 'quickvote', quickvote do |quickform| %>
-<%= quickform.select ('election_method', +<%= quickform.select('election_method', %w(ssd condorcet plurality approval borda) ) %>

-<%= quickform.date_select(:enddate) %>
+<%= quickform.date_select(:enddate, :start_year => Time.now.year) %>
<% end %> diff --git a/app/views/quickvote/_pref_tables.rhtml b/app/views/quickvote/_pref_tables.rhtml index 66e0cbf..0d2b020 100644 --- a/app/views/quickvote/_pref_tables.rhtml +++ b/app/views/quickvote/_pref_tables.rhtml @@ -4,7 +4,6 @@ <% victories = @election.condorcet_result.victories_and_ties %> <% names = @election.names_by_id %> - @@ -46,9 +45,8 @@ <% else -%> (<%= margin%>) <% end -%> - + <% end -%> <% end -%>
- diff --git a/app/views/quickvote/_result_approval.rhtml b/app/views/quickvote/_result_approval.rhtml index 12c7958..c93ce1d 100644 --- a/app/views/quickvote/_result_approval.rhtml +++ b/app/views/quickvote/_result_approval.rhtml @@ -1,7 +1,8 @@ -

Approval Result

(This algorithm assumes that top two choices are "approved.")

+<%= render :partial => 'result', :object => @election.approval_result %> +

About Approval Voting

@@ -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.

-
-
\ No newline at end of file diff --git a/app/views/quickvote/_result_borda.rhtml b/app/views/quickvote/_result_borda.rhtml index 97d82e5..f81cbdb 100644 --- a/app/views/quickvote/_result_borda.rhtml +++ b/app/views/quickvote/_result_borda.rhtml @@ -1,6 +1,7 @@ -

Borda Count Results

+<%= render :partial => 'result', :object => @election.borda_result %> +

About Borda Count

@@ -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.

-
\ No newline at end of file +<%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %> diff --git a/app/views/quickvote/_result_condorcet.rhtml b/app/views/quickvote/_result_condorcet.rhtml index 4279bbd..77ce658 100644 --- a/app/views/quickvote/_result_condorcet.rhtml +++ b/app/views/quickvote/_result_condorcet.rhtml @@ -1,6 +1,7 @@ -

Simple Condorcet Results

+<%= render :partial => 'result', :object => @election.condorcet_result %> +

About Simple Cordorcet Voting

@@ -15,4 +16,3 @@ will be the winner.

another Condorcet system.

-
\ No newline at end of file diff --git a/app/views/quickvote/_result_plurality.rhtml b/app/views/quickvote/_result_plurality.rhtml index 121c1dc..86a9469 100644 --- a/app/views/quickvote/_result_plurality.rhtml +++ b/app/views/quickvote/_result_plurality.rhtml @@ -1,6 +1,7 @@ -

Plurality Results

+<%= render :partial => 'result', :object => @election.plurality_result %> +

About Plurality Voting

@@ -14,4 +15,4 @@ post," "winner-take-all," "majoritarian" or "simple majority" voting.

-
\ No newline at end of file +<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%> diff --git a/app/views/quickvote/_result_ssd.rhtml b/app/views/quickvote/_result_ssd.rhtml index 436dd67..e181184 100644 --- a/app/views/quickvote/_result_ssd.rhtml +++ b/app/views/quickvote/_result_ssd.rhtml @@ -1,6 +1,7 @@ -

Schulze Method Results

+<%= render :partial => 'result', :object => @election.ssd_result %> +

About the Schulze Method

@@ -14,4 +15,5 @@ methods for resolving "circular" defeats.

Beatpath Winner, Path Voting, and Path Winner.

-
+<%= render :partial => 'pref_tables' %> + diff --git a/app/views/quickvote/results.rhtml b/app/views/quickvote/results.rhtml index 9727d81..0383b5e 100644 --- a/app/views/quickvote/results.rhtml +++ b/app/views/quickvote/results.rhtml @@ -27,14 +27,17 @@

Winners

+
<%= render :partial => 'result_' + @election.election_method, :object => @results[@election.election_method] %> - +

Other Voting Methods

<% for result_type in @election.other_methods %> +
<%= render :partial => 'result_' + result_type, :object => @results[result_type] %> +
<% end %> @@ -75,10 +78,8 @@ <% end %> -<%= render :partial => 'pref_tables' %> - <%=image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
-<%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %>
+ <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %>
-<%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%> + diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index 1b994b0..0c44218 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -11,8 +11,12 @@ without the complex features of Selectricity. They are the quickest way to make a decision or to compare between voting methods.

-

<%= link_to "Create a QuickVote", :controller => 'quickvote', :action => 'create' %>

+

<%= link_to( "Create a QuickVote", :controller => 'quickvote', + :action => 'create') %>

+

Take a look at the QuickVotes you've made recently:
+<%= link_to( "My Recent QuickVotes", :controller => 'quickvote', + :action => 'my_quickvotes')%>

Recent QuickVotes include:

+ +

Selectricity Anywhere

You can also access Selectricity entirely over email or via SMS/text diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 86cf84b..5072139 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -167,6 +167,7 @@ a:active { color: #FFFFFF; text-decoration: none; background: #0259C4; } color: #fff; border-bottom: 0px; } + .resultbox { text-align: center; width: 400px; diff --git a/test/unit/quickvote_test.rb b/test/unit/quickvote_test.rb index 4282a70..99274e4 100644 --- a/test/unit/quickvote_test.rb +++ b/test/unit/quickvote_test.rb @@ -1,9 +1,10 @@ require File.dirname(__FILE__) + '/../test_helper' class QuickVoteTest < Test::Unit::TestCase + fixtures :quickvote def correct_enddate - + true end