]> projects.mako.cc - selectricity/blobdiff - app/views/quickvote/_pref_table.rhtml
Add some empty request testcases.
[selectricity] / app / views / quickvote / _pref_table.rhtml
index dfcb6cca9ea31438ad480ce56b8814761743b1b8..4576a0fafb8e7971af4499ba88b9501bacb1a2aa 100644 (file)
@@ -1,19 +1,30 @@
-<% candidates = @election.candidates.sort.collect {|candidate| candidate.id} -%>
+<% candidates = @election.candidates.sort.collect {|candidate| candidate.id}-%>
+<% voters = @election.voters.size %>
+
+<% names = Hash.new -%>
+<% candidates.each do |candidate| -%>
+       <%names[candidate] = Candidate.find(candidate).name -%>
+<% end -%>
 <table class="voterbox">
   <tr>
        <td> </td>
        <% candidates.each do |candidate| -%>
 <table class="voterbox">
   <tr>
        <td> </td>
        <% candidates.each do |candidate| -%>
-         <th><%= candidate -%></th>
+         <th><%= names[candidate] -%></th>
        <% end -%>
 <% candidates.each do |winner| -%>
   <tr>
        <% end -%>
 <% candidates.each do |winner| -%>
   <tr>
-       <th><%= winner %></th>
+       <th><%= names[winner] %></th>
   <% candidates.each do |loser| -%> 
     <% if winner == loser -%>
       <td> -- </td>
     <% else %>         
   <% candidates.each do |loser| -%> 
     <% if winner == loser -%>
       <td> -- </td>
     <% else %>         
-      <td><%= @election.condorcet_result.matrix[winner][loser] %></td>
+      <td><% wins = @election.condorcet_result.matrix[winner][loser]%>
+          <%= wins %>
+             <%= sparkline_tag [(wins.to_f/voters.to_f)*100.0], :type => 'pie', 
+                                :diameter => 25, :share_color => '#74ce00' %>
+         </td>
     <% end -%>
   <% end -%>
  </tr>
     <% end -%>
   <% end -%>
  </tr>
-<%end -%>
\ No newline at end of file
+<% end -%>
+

Benjamin Mako Hill || Want to submit a patch?