Merge from head
authorJohn Dong <jdong@mit.edu>
Fri, 31 Aug 2007 13:35:09 +0000 (09:35 -0400)
committerJohn Dong <jdong@mit.edu>
Fri, 31 Aug 2007 13:35:09 +0000 (09:35 -0400)
22 files changed:
app/controllers/account_controller.rb
app/views/layouts/frontpage.rhtml
app/views/quickvote/_methodinfo_approval.rhtml [moved from app/views/quickvote/_result_approval.rhtml with 77% similarity]
app/views/quickvote/_methodinfo_borda.rhtml [moved from app/views/quickvote/_result_borda.rhtml with 84% similarity]
app/views/quickvote/_methodinfo_condorcet.rhtml [moved from app/views/quickvote/_result_condorcet.rhtml with 82% similarity]
app/views/quickvote/_methodinfo_plurality.rhtml [moved from app/views/quickvote/_result_plurality.rhtml with 83% similarity]
app/views/quickvote/_methodinfo_runoff.rhtml [moved from app/views/quickvote/_result_runoff.rhtml with 90% similarity]
app/views/quickvote/_methodinfo_ssd.rhtml [moved from app/views/quickvote/_result_ssd.rhtml with 83% similarity]
app/views/quickvote/_result.rhtml
app/views/quickvote/_result_box.rhtml [new file with mode: 0644]
app/views/quickvote/_results_sidebar.rhtml
app/views/quickvote/results.rhtml
app/views/site/_basic_login.rhtml
app/views/site/index.rhtml
config/environment.rb
db/create.sql
db/schema.rb
public/images/title_front.png
public/images/title_main.png
public/stylesheets/common.css
public/stylesheets/front.css
public/stylesheets/main.css

index 524d743ee0161551cbb97909f26f179e3c93e134..c9388f6f52c542fc7e6081556ccdb5ae661282a8 100644 (file)
@@ -14,6 +14,7 @@ class AccountController < ApplicationController
   #these methods provide basic functionality for the user login system
   #===================================================================
   def login
+    
     return unless request.post?
     self.current_user = User.authenticate(params[:login], params[:password])
     if logged_in?
index 8f14c3ae32c014fce8213e22a4698978b27552ac..6531dc47bd9df4819177645ee3ac750d8f4ecb42 100644 (file)
     <div id="page-wrapper">
 
     <div id="header">
+      <div id="top-bar">
+        <a href="/account/login">login</a>
+          &nbsp;&nbsp;&nbsp;<a href="/account/signup">sign up</a>
+          &nbsp;&nbsp;&nbsp;<a href="/site/about">help/about</a>
+      </div>
          <a href="index.html"><h1>selectricity: voting machinery for the masses</h1></a>
     </div>
   
similarity index 77%
rename from app/views/quickvote/_result_approval.rhtml
rename to app/views/quickvote/_methodinfo_approval.rhtml
index a7e11ce52ad7c87224ed781a017ccb631a030c8a..979c876285af39153b47ca18a961be3f0dcebbe9 100644 (file)
@@ -1,8 +1,5 @@
-<h3>Approval Result</h3>
 <p><font size="-1">(This algorithm assumes that top two choices are "approved.")</font></p>
 
-<%= render :partial => 'result', :object => @election.approval_result %>
-
 <div class="rbmoreinfo">
 <h4>About Approval Voting</h4>
 
@@ -14,5 +11,3 @@ range that voters are allowed to express is extremely constrained:
 accept or not.</p>
 
 </div>
-
-<%= render :partial => 'approval_table' %>
\ No newline at end of file
similarity index 84%
rename from app/views/quickvote/_result_borda.rhtml
rename to app/views/quickvote/_methodinfo_borda.rhtml
index f81cbdba2814bb7dc31209597d2dfa53e928b848..cc3167cf9b1dd1379fe50ee008415d21cf756dd0 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Borda Count Results</h3>
-
-<%= render :partial => 'result', :object => @election.borda_result %>
-
 <div class="rbmoreinfo">
 <h4>About Borda Count</h4>
 
similarity index 82%
rename from app/views/quickvote/_result_condorcet.rhtml
rename to app/views/quickvote/_methodinfo_condorcet.rhtml
index 77ce6585f8bc88b7133d0d7ce150f263f836178f..a02c1d7ecdacfddae2da2ff7b15eed39a3e0d653 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Simple Condorcet Results</h3>
-
-<%= render :partial => 'result', :object => @election.condorcet_result %>
-
 <div class="rbmoreinfo">
 <h4>About Simple Cordorcet Voting</h4>
 
similarity index 83%
rename from app/views/quickvote/_result_plurality.rhtml
rename to app/views/quickvote/_methodinfo_plurality.rhtml
index 86a94691170027c538c96ec7755c1aab8adb843d..9411611c569462f59faca0b3a87309bd1fc55534 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Plurality Results</h3>
-
-<%= render :partial => 'result', :object => @election.plurality_result %>
-
 <div class="rbmoreinfo">
 <h4>About Plurality Voting</h4>
 
@@ -15,4 +11,5 @@ post," "winner-take-all," "majoritarian" or "simple majority"
 voting.</p>
 
 </div>
+
 <%= image_tag(graph_url( :action => 'plurality_pie', :id => @election ) )%>
similarity index 90%
rename from app/views/quickvote/_result_runoff.rhtml
rename to app/views/quickvote/_methodinfo_runoff.rhtml
index f2422909436fde22a203cc04c9d6c8d88f11c8ad..eaba2b1d73b5a99a10d1efa1f7962b67e60096dd 100644 (file)
@@ -1,6 +1,3 @@
-<div class="resultbox">
-<h3>Instant Runoff (IRV) Results</h3>
-
 <div class="rbmoreinfo">
 <h4>About Instant Runoff Voting</h4>
 
@@ -16,5 +13,3 @@ preferences (and so on), until one candidate achieves a majority.</p>
 by several other names.</p>
 
 </div>
-
-</div>
\ No newline at end of file
similarity index 83%
rename from app/views/quickvote/_result_ssd.rhtml
rename to app/views/quickvote/_methodinfo_ssd.rhtml
index e1811840828a9c52e19a629b45b92bc872ca5717..e3ff831bdaf32d41c214c8ddd78f8c5ebc0bb867 100644 (file)
@@ -1,7 +1,3 @@
-<h3>Schulze Method Results</h3>
-
-<%= render :partial => 'result', :object => @election.ssd_result %>
-
 <div class="rbmoreinfo">
 <h4>About the Schulze Method</h4>
 
index b64322455fefcd8c554d5c1f362232c824db9df4..e0ead6de4e3f27b60524554f0b06241578fcd169 100644 (file)
@@ -1,9 +1,10 @@
-<% %>
+<div class="winner">
 <% if result.winner? and result.winners.length == 1%>
-  <p><em>The winner is:
-     <strong><%=h @candidates[result.winner].name.capitalize %></strong></em></p>
+  <p>The winner is:
+     <strong><%=h @candidates[result.winner].name.capitalize %></strong></p>
 <% elsif result.winner? and result.winners.length > 1 %>
-  <p><em>There was a tie. The winners are: <strong><%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%></strong></em></p>
+  <p>There was a tie. The winners are: <strong><%=h( result.winners.collect {|w| @candidates[w].to_s.capitalize}.join(", ") )%></strong></p>
 <% else %>
-  <p><em>There is no winner using this method. </em></strong></p>
+  <p>There is no winner using this method. </strong></p>
 <% end %>
+</div>
diff --git a/app/views/quickvote/_result_box.rhtml b/app/views/quickvote/_result_box.rhtml
new file mode 100644 (file)
index 0000000..41d9d17
--- /dev/null
@@ -0,0 +1,16 @@
+<div id="<%= method %>_result" class="resultbox"<%= ' style="display: none;"' unless @election.election_method == method %>>
+<div class="normal-header">
+  <span class="header"><%= ELECTION_TYPES[method]%> </span>
+  <span class="subheader">
+  <% if @election.election_method == method %>
+    Selected Method
+  <% else %>
+    Alternative Method 
+  <% end %></span>
+</div>
+
+<%= render :partial => 'methodinfo_' + method,
+           :object => @results[@election.election_method] %>
+
+</div>
+
index 704c052cba543a42b253dfc59f230e37265857ef..c60ed3ddfc1cf90a31e10cddf936a2e2d4283fc7 100644 (file)
@@ -1,2 +1,37 @@
+<h2>Winner</h2>
+<%= render :partial => 'result', :object => @results[@election.election_method] %>
+
+<p>This election was run using:
+<strong><%= ELECTION_TYPES[@election.election_method] %></strong></p>
+
+<p>View results with other methods:<br />
+<% type_hash = {}; ELECTION_TYPES.each {|k,v| type_hash[v] = k} %>
+<%= select_tag 'election_type_select', options_for_select(type_hash, @election.election_method) %></p>
+
+<script>
+var election_methods = new Array(<%= ELECTION_TYPES.keys.collect {|k| "'#{k}'"}.join(', ') %>);
+var method_select = $('election_type_select'); 
+
+function show_results_for() {
+  var test = $('test');
+
+  method_select.value;
+  var result_boxes = document.getElementsByClassName('resultbox');
+  for (i = 0; i < result_boxes.length; i++) {
+    result_box = result_boxes[i];
+    if (result_box.id == (method_select.value + "_result")) {
+      Element.show(result_box);
+    } else {
+      Element.hide(result_box);
+    }
+  }
+
+  //alert(method_select.value);
+}
+
+Event.observe(method_select, 'change', show_results_for);
+</script>
+
+<h2>Statistics</h2>
 <%= image_tag( graph_url( :action => 'votes_per_interval', :id => @election ))%>
 
index a51ca1db2e5bd7e6deaa8a0bd82d524817a1d164..f4f6f2d812aa93e98ad46c453d728a7c9900a79d 100644 (file)
      <%= @election.voters.reject {|v| not v.voted? }.length %> (see below for details) 
    </blockquote>
 
-<div class="normal-header">
-  <span class="header">Winner</span>
-  <span class="subheader">Computed with
-  <%= ELECTION_TYPES[@election.election_method] %></span>
-</div>
+<%= render :partial => 'result_box',
+           :locals => { :method => @election.election_method } %>
 
-<div class="mainresultbox">
-<%= render :partial => 'result_' + @election.election_method,
-           :object => @results[@election.election_method] %>
-</div>
+<% for result_type in @election.other_methods %>
 
-<div class="normal-header">
-  <span class="header">Other Voting Methods</span>
-  <span class="subheader"></span>
-</div>
+<%= render :partial => 'result_box',
+           :locals => { :method => result_type } %>
 
-<% for result_type in @election.other_methods %>
-<div class="resultbox">
-<%= render :partial => 'result_' + result_type, 
-           :object => @results[result_type] %>
-</div>
 <% end %>
 
 
 <div class="clear-div"></div>
 
-<h2>Voters <%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></h2>
+<div class="normal-header">
+  <span class="header">Voter Report</span>
+  <span class="subheader"></span>
+</div>
+
+<p><%= link_to "[Stalk Voters]", :controller => "quickvote", :action => "mapvoters", :id => @election.id %></p>
 <table class="voterbox">
 <tr>
 <th>IP/Host</th>
index 9c689fcb55f084236dedd595a2c7f95065a11fe5..12a63dd9110b89c7c442310ea62c38ab884481b0 100644 (file)
@@ -1,11 +1,11 @@
 <% form_tag :controller => 'account', :action => 'login'  do %>
 
   <p><label for="login">Login</label></p>
-  <p><%= text_field "Login", "login", :size => 30 %></p>
+  <p><%= text_field_tag 'login' %></p>
   <p><label for="password">Password</label></p>
-  <p><%= password_field "Password", "password", :size => 30 %></p>
+  <p><%= password_field_tag 'password' %></p>
 
-  <p><%= submit_tag 'Login' %></p>
+  <p><%= submit_tag 'Log in' %></p>
 <% end %>
 
 <p><%= link_to 'Register for an account', :controller => 'account', :action => 'signup' %></p>
index efbb37464de953ed289fd9122246800dd87f35de..e0e34a278475fbdf1f49b97a26f972d0c2f75a57 100644 (file)
@@ -27,8 +27,8 @@
     
     <p>You must have an account to start a new vote or to administer an
     existing vote. You can log in or create a new account below.</p>
-
-    <%= render_partial 'basic_login' %>
+    
+    <%= render :partial => 'basic_login' %>
   <% end %>
 
   </div>
index fcabdd87aa6279b6003532259625536ac62e3fb3..ccd9ad0990874b6b4bb92d6260caa52a891b9982 100644 (file)
@@ -28,7 +28,7 @@ Rails::Initializer.run do |config|
 
   # Use the database for sessions instead of the file system
   # (create the session table with 'rake db:sessions:create')
-  config.action_controller.session_store = :active_record_store
+  config.action_controller.session_store = :active_record_store
 
   # Use SQL instead of Active Record's schema dumper when creating the test database.
   # This is necessary if your schema can't be completely dumped by the schema dumper, 
@@ -66,10 +66,10 @@ require 'randarray'
 require 'gruff-0.2.8/lib/gruff'
 require 'sparklines'
 require 'rubyvote'
-ELECTION_TYPES = {'ssd' => "Schulze Sequential Dropping",
-                  'plurality' => "Plurality/First Past the Post",
-                  'approval' => "Approval (Top Two)",
-                  'condorcet' => "Simple Condorcet",
+ELECTION_TYPES = {'ssd' => "Schulze Method",
+                  'plurality' => "Plurality",
+                  'approval' => "Approval",
+                  'condorcet' => "Condorcet",
                   'borda' => "Borda Count"}
 
 class String
index 7d5f405f5662b4fd30038b5f6d712efa0d1b0976..c28dd36c48e616c427b1ef8dcc3f8737c11d8288 100644 (file)
@@ -101,6 +101,19 @@ create table rankings (
  primary key (id)
 );
 
+# CREATE sessions TABLE
+######################################
+
+drop table if exists sessions;
+create table sessions (
+ id         int(11)      NOT NULL auto_increment,
+ sessid     varchar(255),
+ data       text,
+ updated_at datetime     DEFAULT  NULL,
+ primary    key (id),
+ index      session_index (sessid)
+);
+
 # CREATE users TABLE
 #####################################
 #DROP TABLE IF EXISTS `users`;
index 590425d670859ee07aab24761a30d00f5c780eb2..6c038deadbd2983e1fb2073265ec989248421809 100644 (file)
@@ -74,10 +74,11 @@ ActiveRecord::Schema.define() do
   create_table "voters", :force => true do |t|
     t.column "email",       :string,  :limit => 100
     t.column "password",    :string,  :limit => 100
-    t.column "contacted",   :integer, :limit => 4,   :default => 0, :null => false
-    t.column "election_id", :integer,                               :null => false
+    t.column "contacted",   :integer, :limit => 4,   :default => 0,  :null => false
+    t.column "election_id", :integer,                                :null => false
     t.column "session_id",  :string,  :limit => 32
     t.column "ipaddress",   :string,  :limit => 32
+    t.column "type",        :string,  :limit => 100, :default => "", :null => false
   end
 
   add_index "voters", ["election_id"], :name => "fk_election_voter"
index acf328fff3c5e18456f845235bf81cfbc2c31127..d249a69e157f2992989a4b6efa047de15b58ae53 100644 (file)
Binary files a/public/images/title_front.png and b/public/images/title_front.png differ
index f3dd02d2b159a6ed5f40b291b3377608f73da8a5..1fe60dd97341bd14687ddf91cad9e41ed6bb462f 100644 (file)
Binary files a/public/images/title_main.png and b/public/images/title_main.png differ
index 01cd7c052e53363d8dffd1468d9fbc4511deb55a..a050444f3327d328062db58e2e93e20d9e02290b 100644 (file)
@@ -29,7 +29,7 @@ table, caption, tbody, tfoot, thead, tr, th, td {
 }
 
 body {
-       font-size: 11px;
+       font-size: 0.9em;
        font-family: Trebuchet, Verdana, Arial, Helvetica, sans-serif;
 }
 
@@ -76,7 +76,7 @@ h2, h3 {
 
 #footer {
        font-size: 11px;
-       font-family: Verdana, Arial, Helvetica, sans-serif;
+       font-family: "Trebuchet MS", Trebuchet, Verdana, Arial, sans-serif;
        margin-top: 40px;
        text-align: center;
 }
@@ -104,7 +104,4 @@ h2, h3 {
     background: #FFFBB3; 
     border: 1px black solid;
        text-align: center;
-       font-weight: bold;
-       padding: 5px 5px 5px 15px;
-    width: 250px;
-}
+       font-weight: bold
index 5c2d1cab2a04b7f1af26e67f48146edd33a592c2..4c973b125a097ee5cf45a4fafb867cf5fcf3d853 100644 (file)
@@ -18,7 +18,7 @@ table, caption, tbody, tfoot, thead, tr, th, td {
        padding: 0;
        border: 0;
        font-size: 100%; 
-       font-family: inherit;
+       font-family: "Trebuchet MS", Verdana, Arial, sans-serif;
        vertical-align: baseline;
 }
 
@@ -33,7 +33,7 @@ a {
 }
 
 #body {
-       font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+       font-family: "Trebuchet MS", Verdana, Arial, sans-serif;
        color: white;
        font-size: 12px;
        text-align: left;
@@ -58,6 +58,21 @@ a {
        padding-top: 189px;
        height: 0px;
        margin-top: 10px;
+       margin-left: 231px;
+}
+
+#top-bar {
+       
+       position: relative;
+       float: right;
+       width: 231px;
+       text-align: center;
+}
+
+#top-bar a {
+       color: black;
+       font-size: 11px;
+       text-decoration: none;
 }
 
 
@@ -91,6 +106,7 @@ h3 {
     margin-bottom: 1em;
 }
 
+
 #voters {
        padding-top: 50px;
        height: 559px;
index 3608063a4ae355fe2e331e1ea2a10359fe25edb4..13626a13bd67f4a807535390e38f603e9ef76c8c 100644 (file)
@@ -160,7 +160,7 @@ h5 {
 }
 
 .normal-header {
-    margin: 0 -20px 1em -20px;
+    margin: 1.3em -20px 1.3em -20px;
     height: 32px;
        background-color: #e5e5e5;
 }

Benjamin Mako Hill || Want to submit a patch?