From 18f4d0bd0025dd963b5fab238964de6d20e0d354 Mon Sep 17 00:00:00 2001 From: Date: Thu, 30 Aug 2007 21:00:22 -0400 Subject: [PATCH 1/1] refactored the results page --- ...roval.rhtml => _methodinfo_approval.rhtml} | 5 --- ...lt_borda.rhtml => _methodinfo_borda.rhtml} | 4 --- ...rcet.rhtml => _methodinfo_condorcet.rhtml} | 4 --- ...lity.rhtml => _methodinfo_plurality.rhtml} | 5 +-- ..._runoff.rhtml => _methodinfo_runoff.rhtml} | 5 --- ...result_ssd.rhtml => _methodinfo_ssd.rhtml} | 4 --- app/views/quickvote/_result.rhtml | 11 +++--- app/views/quickvote/_result_box.rhtml | 16 +++++++++ app/views/quickvote/_results_sidebar.rhtml | 35 +++++++++++++++++++ app/views/quickvote/results.rhtml | 30 ++++++---------- config/environment.rb | 8 ++--- public/stylesheets/common.css | 2 +- public/stylesheets/main.css | 2 +- 13 files changed, 75 insertions(+), 56 deletions(-) rename app/views/quickvote/{_result_approval.rhtml => _methodinfo_approval.rhtml} (77%) rename app/views/quickvote/{_result_borda.rhtml => _methodinfo_borda.rhtml} (84%) rename app/views/quickvote/{_result_condorcet.rhtml => _methodinfo_condorcet.rhtml} (82%) rename app/views/quickvote/{_result_plurality.rhtml => _methodinfo_plurality.rhtml} (83%) rename app/views/quickvote/{_result_runoff.rhtml => _methodinfo_runoff.rhtml} (90%) rename app/views/quickvote/{_result_ssd.rhtml => _methodinfo_ssd.rhtml} (83%) create mode 100644 app/views/quickvote/_result_box.rhtml diff --git a/app/views/quickvote/_result_approval.rhtml b/app/views/quickvote/_methodinfo_approval.rhtml similarity index 77% rename from app/views/quickvote/_result_approval.rhtml rename to app/views/quickvote/_methodinfo_approval.rhtml index a7e11ce..979c876 100644 --- a/app/views/quickvote/_result_approval.rhtml +++ b/app/views/quickvote/_methodinfo_approval.rhtml @@ -1,8 +1,5 @@ -

Approval Result

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

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

About Approval Voting

@@ -14,5 +11,3 @@ range that voters are allowed to express is extremely constrained: accept or not.

- -<%= render :partial => 'approval_table' %> \ No newline at end of file diff --git a/app/views/quickvote/_result_borda.rhtml b/app/views/quickvote/_methodinfo_borda.rhtml similarity index 84% rename from app/views/quickvote/_result_borda.rhtml rename to app/views/quickvote/_methodinfo_borda.rhtml index f81cbdb..cc3167c 100644 --- a/app/views/quickvote/_result_borda.rhtml +++ b/app/views/quickvote/_methodinfo_borda.rhtml @@ -1,7 +1,3 @@ -

Borda Count Results

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

About Borda Count

diff --git a/app/views/quickvote/_result_condorcet.rhtml b/app/views/quickvote/_methodinfo_condorcet.rhtml similarity index 82% rename from app/views/quickvote/_result_condorcet.rhtml rename to app/views/quickvote/_methodinfo_condorcet.rhtml index 77ce658..a02c1d7 100644 --- a/app/views/quickvote/_result_condorcet.rhtml +++ b/app/views/quickvote/_methodinfo_condorcet.rhtml @@ -1,7 +1,3 @@ -

Simple Condorcet Results

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

About Simple Cordorcet Voting

diff --git a/app/views/quickvote/_result_plurality.rhtml b/app/views/quickvote/_methodinfo_plurality.rhtml similarity index 83% rename from app/views/quickvote/_result_plurality.rhtml rename to app/views/quickvote/_methodinfo_plurality.rhtml index 86a9469..9411611 100644 --- a/app/views/quickvote/_result_plurality.rhtml +++ b/app/views/quickvote/_methodinfo_plurality.rhtml @@ -1,7 +1,3 @@ -

Plurality Results

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

About Plurality Voting

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

+ <%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%> diff --git a/app/views/quickvote/_result_runoff.rhtml b/app/views/quickvote/_methodinfo_runoff.rhtml similarity index 90% rename from app/views/quickvote/_result_runoff.rhtml rename to app/views/quickvote/_methodinfo_runoff.rhtml index f242290..eaba2b1 100644 --- a/app/views/quickvote/_result_runoff.rhtml +++ b/app/views/quickvote/_methodinfo_runoff.rhtml @@ -1,6 +1,3 @@ -
-

Instant Runoff (IRV) Results

-

About Instant Runoff Voting

@@ -16,5 +13,3 @@ preferences (and so on), until one candidate achieves a majority.

by several other names.

- -
\ No newline at end of file diff --git a/app/views/quickvote/_result_ssd.rhtml b/app/views/quickvote/_methodinfo_ssd.rhtml similarity index 83% rename from app/views/quickvote/_result_ssd.rhtml rename to app/views/quickvote/_methodinfo_ssd.rhtml index e181184..e3ff831 100644 --- a/app/views/quickvote/_result_ssd.rhtml +++ b/app/views/quickvote/_methodinfo_ssd.rhtml @@ -1,7 +1,3 @@ -

Schulze Method Results

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

About the Schulze Method

diff --git a/app/views/quickvote/_result.rhtml b/app/views/quickvote/_result.rhtml index b643224..e0ead6d 100644 --- a/app/views/quickvote/_result.rhtml +++ b/app/views/quickvote/_result.rhtml @@ -1,9 +1,10 @@ -<% %> +
<% if result.winner? and result.winners.length == 1%> -

The winner is: - <%=h @candidates[result.winner].name.capitalize %>

+

The winner is: + <%=h @candidates[result.winner].name.capitalize %>

<% elsif result.winner? and result.winners.length > 1 %> -

There was a tie. The winners are: <%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%>

+

There was a tie. The winners are: <%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%>

<% else %> -

There is no winner using this method.

+

There is no winner using this method.

<% end %> +
diff --git a/app/views/quickvote/_result_box.rhtml b/app/views/quickvote/_result_box.rhtml new file mode 100644 index 0000000..41d9d17 --- /dev/null +++ b/app/views/quickvote/_result_box.rhtml @@ -0,0 +1,16 @@ +
> +
+ <%= ELECTION_TYPES[method]%> + + <% if @election.election_method == method %> + Selected Method + <% else %> + Alternative Method + <% end %> +
+ +<%= render :partial => 'methodinfo_' + method, + :object => @results[@election.election_method] %> + +
+ diff --git a/app/views/quickvote/_results_sidebar.rhtml b/app/views/quickvote/_results_sidebar.rhtml index 704c052..c60ed3d 100644 --- a/app/views/quickvote/_results_sidebar.rhtml +++ b/app/views/quickvote/_results_sidebar.rhtml @@ -1,2 +1,37 @@ +

Winner

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

This election was run using: +<%= ELECTION_TYPES[@election.election_method] %>

+ +

View results with other methods:
+<% type_hash = {}; ELECTION_TYPES.each {|k,v| type_hash[v] = k} %> +<%= select_tag 'election_type_select', options_for_select(type_hash, @election.election_method) %>

+ + + +

Statistics

<%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%> diff --git a/app/views/quickvote/results.rhtml b/app/views/quickvote/results.rhtml index a51ca1d..f4f6f2d 100644 --- a/app/views/quickvote/results.rhtml +++ b/app/views/quickvote/results.rhtml @@ -28,33 +28,25 @@ <%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details) -
- Winner - Computed with - <%= ELECTION_TYPES[@election.election_method] %> -
+<%= render :partial => 'result_box', + :locals => { :method => @election.election_method } %> -
-<%= render :partial => 'result_' + @election.election_method, - :object => @results[@election.election_method] %> -
+<% for result_type in @election.other_methods %> -
- Other Voting Methods - -
+<%= render :partial => 'result_box', + :locals => { :method => result_type } %> -<% for result_type in @election.other_methods %> -
-<%= render :partial => 'result_' + result_type, - :object => @results[result_type] %> -
<% end %>
-

Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %>

+
+ Voter Report + +
+ +

<%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %>

diff --git a/config/environment.rb b/config/environment.rb index 82c7466..ccd9ad0 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -66,10 +66,10 @@ require 'randarray' require 'gruff-0.2.8/lib/gruff' require 'sparklines' require 'rubyvote' -ELECTION_TYPES = {'ssd' => "Schulze Sequential Dropping", - 'plurality' => "Plurality/First Past the Post", - 'approval' => "Approval (Top Two)", - 'condorcet' => "Simple Condorcet", +ELECTION_TYPES = {'ssd' => "Schulze Method", + 'plurality' => "Plurality", + 'approval' => "Approval", + 'condorcet' => "Condorcet", 'borda' => "Borda Count"} class String diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index 01cd7c0..42390e3 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -29,7 +29,7 @@ table, caption, tbody, tfoot, thead, tr, th, td { } body { - font-size: 11px; + font-size: 0.9em; font-family: Trebuchet, Verdana, Arial, Helvetica, sans-serif; } diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index 3608063..13626a1 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -160,7 +160,7 @@ h5 { } .normal-header { - margin: 0 -20px 1em -20px; + margin: 1.3em -20px 1.3em -20px; height: 32px; background-color: #e5e5e5; } -- 2.39.2
IP/Host