]> projects.mako.cc - selectricity-live/blobdiff - app/views/quickvote/_defeats_list.rhtml
The defeats lsit partial contains the display logic for the mehtod added to condorcet...
[selectricity-live] / app / views / quickvote / _defeats_list.rhtml
diff --git a/app/views/quickvote/_defeats_list.rhtml b/app/views/quickvote/_defeats_list.rhtml
new file mode 100644 (file)
index 0000000..248c294
--- /dev/null
@@ -0,0 +1,15 @@
+<% victories, tied =@election.condorcet_result.list_defeats -%>
+<%candidates = @election.candidates.sort.collect {|candidate| candidate.id}%>
+<% names = Hash.new -%>
+<% candidates.each do |candidate| -%>
+       <%names[candidate] = Candidate.find(candidate).name -%>
+<% end -%>
+
+<% victories.each do |victory| -%>
+<%= names[victory[0]] %> beat <%= names[victory[1]] %> by <%= victory[2]%> 
+votes.<br />
+<% end -%>
+
+<% tied.each do |tie| -%>
+<%= names[tie[0]]%> tied with <%= names[tie[1]]%><br />
+<% end -%>

Benjamin Mako Hill || Want to submit a patch?