Merge head
[selectricity-live] / app / views / quickvote / results.rhtml
1 <% require 'whois/whois' %>
2
3 <div id="page-title">
4   <span class="header">Quickvote</span>
5   <span class="subheader">Results</span>
6 </div>
7
8 <div class="main-content">
9
10 <% if @election.shortdesc %>
11   <p><strong>Vote Description:</strong></p>
12   <blockquote><em><%=h @election.shortdesc %></em>
13     <% if @election.longdesc -%>
14       <br />
15       <%= h(@election.longdesc) -%>
16     <% end -%>
17   </blockquote>
18 <% end %>
19
20 <p><strong>Candidates/choices:</strong></p>
21
22 <ol>
23   <% for candidate in @election.candidates.sort %>
24     <li><%=h candidate.name.capitalize %></li>
25   <% end %>
26 </ol>
27
28 <p><strong>Number of voters:</strong></p>
29    <blockquote>
30      <%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details) 
31    </blockquote>
32
33 <div class="plain-header">
34   <span class="header">Winner</span>
35   <span class="subheader"></span>
36 </div>
37
38 <div class="mainresultbox">
39 <%= render :partial => 'result_' + @election.election_method,
40            :object => @results[@election.election_method] %>
41 </div>
42
43 <div class="plain-header">
44   <span class="header">Other Voting Methods</span>
45   <span class="subheader"></span>
46 </div>
47
48 <% for result_type in @election.other_methods %>
49 <div class="resultbox">
50 <%= render :partial => 'result_' + result_type, 
51            :object => @results[result_type] %>
52 </div>
53 <% end %>
54
55
56 <div class="clear-div"></div>
57
58 <h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
59 <table class="voterbox">
60 <tr>
61 <th>IP/Host</th>
62 <th>Origin</th>
63 <th>Vote</th>
64 </tr>
65 <% for voter in @election.voters %>
66   <% next unless voter.voted? %>
67   <tr>
68     <td><% begin %>
69         <% raise ArgumentError.new, "Local Server" if voter.ipaddress == "127.0.0.1" %>
70         <% raise ArgumentError.new, "XML-RPC Voter" if voter.ipaddress == "XMLRPC Request" %>
71         <% w= Whois::Whois.new(IPAddr.new(voter.ipaddress),true)%>
72         <%=h((w.host == nil or w.host.empty?) ? voter.ipaddress : w.host)%>
73       </td>
74       <td>
75         <%w.search_whois%>
76         <%=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 %>
77     
78     <% rescue ArgumentError => err %>
79       <%=h err %>
80     </td>
81     <td><%=h err%>
82     <% rescue NoMethodError %>
83       DNS Unreachable
84     </td>
85     <td> DNS Unreachable
86     <% end %>
87     </td>
88   <td><%= voter.vote.votestring %></td>
89   </tr>
90 <% end %>
91 </table>
92
93 <%=image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
94 <br />
95
96 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %><br />
97
98 </div>

Benjamin Mako Hill || Want to submit a patch?