Use WHOIS to search up meaningful organizational data about voters. NOTE: Probably...
[selectricity-live] / app / views / quickvote / results.rhtml
index 1fad7ea36a907186d565ff633e7877b0fe1613b6..1df2856e4416b8d2ff81e905d673be82bf8420f1 100644 (file)
@@ -1,4 +1,4 @@
-<% %>
+<%require 'whois/whois' %>
 <h1>Results</h1>
 
 <% if @election.shortdesc %>
@@ -145,7 +145,6 @@ by several other names.</p>
 <div class="clearbox"></div>
 
 <h2>Voters</h2>
-
 <table class="voterbox">
 <tr>
 <th>IP Address</th>
@@ -156,14 +155,22 @@ by several other names.</p>
   <% next unless voter.voted? %>
   <tr>
   <td><%= voter.ipaddress %></td>
-  <td><%= `host #{voter.ipaddress}`.sub(/^.*pointer (.*)\.$/, '\1') %></td>
+  <td><% begin %>
+      <% raise ArgumentError.new if voter.ipaddress == "127.0.0.1" %>
+      <%= Whois::Whois.new(IPAddr.new(voter.ipaddress).to_s).search_whois.grep(/^OrgName/)[0].sub(/^OrgName\:/,'').strip %>
+    
+    <% rescue ArgumentError => err %>
+      <%= voter.ipaddress %>
+    <% end %>
+    </td>
   <td><%= voter.vote.votestring %></td>
   </tr>
 <% end %>
 </table>
 
+<%= render :partial => 'pref_table' %>
+
 <%= image_tag( graph_url( :action => 'votes_per_day', :id => @election ) ) %><br />
 <%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%><br />
 <%= image_tag( graph_url( :action => 'borda_bar', :id => @election ) ) %><br />
 <%= image_tag( graph_url( :action => 'choices_positions', :id => @election ) ) %>
-

Benjamin Mako Hill || Want to submit a patch?