refactored the results page
[selectricity-live] / app / views / quickvote / results.rhtml
1 <% require 'whois/whois' %>
2
3 <div id="title-header">
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 <%= render :partial => 'result_box',
32            :locals => { :method => @election.election_method } %>
33
34 <% for result_type in @election.other_methods %>
35
36 <%= render :partial => 'result_box',
37            :locals => { :method => result_type } %>
38
39 <% end %>
40
41
42 <div class="clear-div"></div>
43
44 <div class="normal-header">
45   <span class="header">Voter Report</span>
46   <span class="subheader"></span>
47 </div>
48
49 <p><%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></p>
50 <table class="voterbox">
51 <tr>
52 <th>IP/Host</th>
53 <th>Origin</th>
54 <th>Vote</th>
55 </tr>
56 <% for voter in @election.voters %>
57   <% next unless voter.voted? %>
58   <tr>
59     <td><% begin %>
60         <% raise ArgumentError.new, "Local Server" if voter.ipaddress == "127.0.0.1" %>
61         <% raise ArgumentError.new, "XML-RPC Voter" if voter.ipaddress == "XMLRPC Request" %>
62         <% w= Whois::Whois.new(IPAddr.new(voter.ipaddress),true)%>
63         <%=h((w.host == nil or w.host.empty?) ? voter.ipaddress : w.host)%>
64       </td>
65       <td>
66         <%w.search_whois%>
67         <%=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 %>
68     
69     <% rescue ArgumentError => err %>
70       <%=h err %>
71     </td>
72     <td><%=h err%>
73     <% rescue NoMethodError %>
74       DNS Unreachable
75     </td>
76     <td> DNS Unreachable
77     <% end %>
78     </td>
79   <td><%= voter.vote.votestring %></td>
80   </tr>
81 <% end %>
82 </table>
83
84 <br />
85
86 <!--
87 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %><br />
88 -->
89

Benjamin Mako Hill || Want to submit a patch?