Allow custimizable graph sizes, to fit with newly modular results page. Also,
[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 <div class="mainresultbox">
31 <%= render :partial => 'result_' + @election.election_method,
32            :object => @results[@election.election_method] %>
33 </div>
34
35 <h3> Other Voting Methods </h3>
36 <% for result_type in @election.other_methods %>
37 <div class="resultbox">
38 <%= render :partial => 'result_' + result_type, 
39            :object => @results[result_type] %>
40 </div>
41 <% end %>
42
43
44 <div class="clearbox"></div>
45
46 <h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
47 <table class="voterbox">
48 <tr>
49 <th>IP/Host</th>
50 <th>Origin</th>
51 <th>Vote</th>
52 </tr>
53 <% for voter in @election.voters %>
54   <% next unless voter.voted? %>
55   <tr>
56     <td><% begin %>
57         <% raise ArgumentError.new, "Local Server" if voter.ipaddress == "127.0.0.1" %>
58         <% raise ArgumentError.new, "XML-RPC Voter" if voter.ipaddress == "XMLRPC Request" %>
59         <% w= Whois::Whois.new(IPAddr.new(voter.ipaddress),true)%>
60         <%=h((w.host == nil or w.host.empty?) ? voter.ipaddress : w.host)%>
61       </td>
62       <td>
63         <%w.search_whois%>
64         <%=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 %>
65     
66     <% rescue ArgumentError => err %>
67       <%=h err %>
68     </td>
69     <td><%=h err%>
70     <% rescue NoMethodError %>
71       DNS Unreachable
72     </td>
73     <td> DNS Unreachable
74     <% end %>
75     </td>
76   <td><%= voter.vote.votestring %></td>
77   </tr>
78 <% end %>
79 </table>
80
81 <%=image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
82 <br />
83
84 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %><br />
85

Benjamin Mako Hill || Want to submit a patch?