Made the results page 'modular,' and all the necessary adaptations.
[selectricity] / app / views / quickvote / results.rhtml
1 <% %>
2 <%require 'whois/whois' %>
3 <h1>Results</h1>
4
5 <% if @election.shortdesc %>
6   <p><strong>Description:</strong></p>
7   <blockquote><em><%=h @election.shortdesc %></em>
8     <% if @election.longdesc -%>
9       <br />
10       <%= h(@election.longdesc) -%>
11     <% end -%>
12   </blockquote>
13 <% end %>
14
15 <p><strong>Candidates/choices:</strong></p>
16
17 <ol>
18   <% for candidate in @election.candidates.sort %>
19     <li><%=h candidate.name.capitalize %></li>
20   <% end %>
21 </ol>
22
23 <p><strong>Number of voters:</strong></p>
24    <blockquote>
25      <%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details) 
26    </blockquote>
27
28 <h2>Winners</h2>
29
30 <%= render :partial => 'result_' + @election.election_method,
31            :object => @results[@election.election_method] %>
32
33
34 <h3> Other Voting Methods </h3>
35 <% for result_type in @election.other_methods %>
36 <%= render :partial => 'result_' + result_type, 
37            :object => @results[result_type] %>
38 <% end %>
39
40
41 <div class="clearbox"></div>
42
43 <h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
44 <table class="voterbox">
45 <tr>
46 <th>IP/Host</th>
47 <th>Origin</th>
48 <th>Vote</th>
49 </tr>
50 <% for voter in @election.voters %>
51   <% next unless voter.voted? %>
52   <tr>
53     <td><% begin %>
54         <% raise ArgumentError.new, "Local Server" if voter.ipaddress == "127.0.0.1" %>
55         <% raise ArgumentError.new, "XML-RPC Voter" if voter.ipaddress == "XMLRPC Request" %>
56         <% w= Whois::Whois.new(IPAddr.new(voter.ipaddress).to_s,true)%>
57         <%=h((w.host == nil or w.host.empty?) ? voter.ipaddress : w.host)%>
58       </td>
59       <td>
60         <%w.search_whois%>
61         <%=h (w.all.grep(/^(OrgName|org-name)/)[0] or "").sub(/^(OrgName|org-name)\:/,'').strip -%> - <%=  (w.all.grep(/^(NetName|netname)/)[0] or "").sub(/^(NetName|netname)\:/,'').strip %>
62     
63     <% rescue ArgumentError => err %>
64       <%=h err %>
65     </td>
66     <td><%=h err%>
67     <% end %>
68     </td>
69   <td><%= voter.vote.votestring %></td>
70   </tr>
71 <% end %>
72 </table>
73
74 <%= render :partial => 'pref_tables' %>
75
76 <%=image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
77 <br />
78 <%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %><br />
79 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %><br />
80 <%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>

Benjamin Mako Hill || Want to submit a patch?