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

Benjamin Mako Hill || Want to submit a patch?