added first stab at a kiosk mode
author<mako@atdot.cc> <>
Sun, 7 Jun 2009 12:30:52 +0000 (08:30 -0400)
committer<mako@atdot.cc> <>
Sun, 7 Jun 2009 12:30:52 +0000 (08:30 -0400)
app/controllers/voter_controller.rb
app/models/election.rb
app/views/election/_overview_form.rhtml
app/views/election/show.rhtml
app/views/layouts/_footer.rhtml
app/views/voter/_vote_sidebar.rhtml
app/views/voter/full_vote.rhtml
app/views/voter/kiosk_ready.rhtml [new file with mode: 0644]
db/migrate/20090607094837_kiosk_mode.rb [new file with mode: 0644]
db/schema.rb

index c0634695e971db632506d491ebd5192865086973..a912824ebd25f6baf1539b320077e86004613ff3 100644 (file)
@@ -19,8 +19,10 @@ class VoterController < ApplicationController
         @voter = OpenVoter.find(:all,
           :conditions => ["session_id = ? and election_id = ?",
           session.session_id, @election.id])[0]
-      
-        @voter = OpenVoter.new unless @voter
+     
+        unless @voter and not @voter.election.kiosk
+          @voter = OpenVoter.new
+        end
 
         @voter.election = @election
         @voter.session_id = session.session_id
@@ -121,6 +123,8 @@ class VoterController < ApplicationController
       if @voter.election.embeddable? and params[:embed] == "true" \
         and @voter.election.early_results?
         redirect_to :action => :results, :id => @password, :embed => 'true'
+      elsif @voter.election.kiosk and params[:kiosk] = "true"
+        redirect_to :action => "kiosk_ready", :id => @password, :kiosk => true
       else
         render :action => 'thanks'
       end
@@ -176,7 +180,13 @@ class VoterController < ApplicationController
       redirect_to :action => 'index'
     end
   end
-  
+  def kiosk_ready
+    if not authenticate
+      redirect_to :action => 'index', :kiosk => true
+    end
+  end
+
   private
   def authenticate
     password = params[:id]
index a3cf8e47c1b3db7ee0e74908eb71f0fcd5798c46..a3e939424ac11099ba5c1f6e70dd5b0989b2b405 100644 (file)
@@ -89,6 +89,10 @@ class Election < ActiveRecord::Base
   def authenticated?
     authenticated
   end
+
+  def kiosk?
+    kiosk
+  end
   
   def shortdesc
     shortdesc = description.split(/\n/)[0]
index be90de6593f3944d0c87accd0dff4e792f6dec2a..1f540c62462e056605af8684753ef6c44380fe38 100644 (file)
 <% type_hash = {}; ELECTION_TYPES.each {|k,v| type_hash[v] = k} %>
 <%= select_tag 'election[election_method]', options_for_select(type_hash, @election.election_method) %></p>
 
-<p><label for="election_election_method">Enable Embeddable Elections?</label>
-<%= check_box :election, :embeddable %></p>
+<p><label for="election_verifiable">Enable voter verifiable
+elections?</label>
+<%= check_box :election, :verifiable%></p>
 
-<p><label for="election_election_method">Should results be visible before end of election?</label>
+<p><label for="election_early_results">Should results be visible before end of election?</label>
 <%= check_box :election, :early_results%></p>
 
+<p><label for="election_embeddable">Enable embeddable elections?</label>
+<%= check_box :election, :embeddable %></p>
+
+<p><label for="election_kiosk">Enable kiosk mode?</label>
+<em><strong>Warning:</strong> This will let users vote multiple times
+from the same computer!</em>
+<%= check_box :election, :kiosk%></p>
+
 <!--[eoform:election]-->
 
index 5de6081b298b5d8c89fa0539c4360498d158ec19..ff116f47570a1a8f1cb1bab7e12b393a1b2744e8 100644 (file)
 <li>Elections <strong>will be</strong> embeddable.</li>
 <% end %>
 
+<% if @election.kiosk %>
+<li>Selectricity's kiosk mode <strong>will be</strong> available.</li>
+<% end %>
+
+<% if @election.verifiable%>
+<li>Voters <strong>will be</strong> given tokens to verify their votes.</li>
+<% else %>
+<li>Elections <strong>will not be</strong> voter verifiable.</li>
+<% end %>
+
 </ul>
 
 <% if @election.active? and not @election.authenticated? %>
-<p><strong>Link</strong></p>
-<%= (link_to ("Go Vote!", 
-            :controller => 'voter', :action => 'index', :election_id => @election.id)).to_s %>
+<p><strong>Link to election:</strong></p>
+<ul>
+<li><%= (link_to ("Vote in election", 
+          :controller => 'voter', :action => 'index', :election_id => @election.id)).to_s %>
+     (<%= votepassword_url(:urlpassword => "open." + @election.id.to_s) %>)</li>
+
+<% if @election.kiosk %>
+<li><%= (link_to ("Kiosk mode",
+          :controller => 'voter', :action => 'index', :election_id => @election.id, :kiosk => true)).to_s %>
+     (<%= votepassword_url(:urlpassword => "open." + @election.id.to_s, :kiosk => true) %>)</li>
+  <% end %>
+</ul>
 <% end -%>
 
 <div class="normal-header">
index f481c852a6b5f830f8dd7560cd8441e45717ae1f..d9747b8c774fba6807bd61c38dd6a679ba9bab0a 100644 (file)
@@ -1,5 +1,7 @@
   <div id="footer">
-       <a href="http://blog.selectricity.org/">Copyleft 2006, 2007</a> 
-       <a href="http://www.media.mit.edu">MIT Media Lab</a>, <%= link_to("Selectricity Team", :controller => 'about', :action => 'team') %>&nbsp;&nbsp;::&nbsp;&nbsp; 
+       <a href="http://blog.selectricity.org/">Copyleft 2006-2009</a> 
+    <a href="http://civic.mit.edu">MIT Center for Future Civic Media</a>, 
+       <a href="http://www.media.mit.edu">MIT Media Lab</a>,
+    <%= link_to("Selectricity Team", :controller => 'about', :action => 'team') %>&nbsp;&nbsp;::&nbsp;&nbsp; 
     <a href="http://blog.selectricity.org/">Selectricity News Blog</a>
   </div>
index 2f250e077e536b65c6f7dbdc25ee1554f6cee276..58b1e56c9c34bdab70ceea90cb2d1bee6bd23b03 100644 (file)
@@ -6,5 +6,9 @@ order.</p>
 <%= render :partial => 'common/sortable_vote' %>
 
 <div style="margin-left: 30pt;">
-<%= button_to "Submit Vote", :action => 'review', :id => @password %>
+<% if @voter.election.kiosk and params[:kiosk] == "true" %>
+  <%= button_to "Submit Vote", :action => 'review', :id => @password, :kiosk => true %>
+<% else %>
+  <%= button_to "Submit Vote", :action => 'review', :id => @password %>
+<% end %>
 </div>
index 5e8a8d1695669256b4a963212fd0eb6e0c1332dc..80ea98676d01b72bb50066677ea6548a85f3fe89 100644 (file)
@@ -6,10 +6,12 @@
 <p><strong>Description:</strong></p>
 <p><%= @voter.election.description %></p>
 
+<% if @voter.election.authenticated? %>
 <div class="normal-header">
   <span class="header">Current Voter</span>
   <span class="subheader"></span>
 </div>
+<% end %>
 
 <p><strong><%= @voter.email %></strong></p>
 
diff --git a/app/views/voter/kiosk_ready.rhtml b/app/views/voter/kiosk_ready.rhtml
new file mode 100644 (file)
index 0000000..7773dd8
--- /dev/null
@@ -0,0 +1,9 @@
+<div id="title-header">
+  <span class="header"><%= @voter.election.name %></span>
+  <span class="subheader"></span>
+</div>
+
+<p>Selectricity is running in kiosk mode and is ready for the next
+voter. Press the button below to generate a new ballot.</p>
+
+<p align="center"><%= button_to "Vote!", :action => "index", :urlpassword => @password, :kiosk => true %></p>
diff --git a/db/migrate/20090607094837_kiosk_mode.rb b/db/migrate/20090607094837_kiosk_mode.rb
new file mode 100644 (file)
index 0000000..57ea98d
--- /dev/null
@@ -0,0 +1,18 @@
+class KioskMode < ActiveRecord::Migration
+  def self.up
+    add_column :elections, :kiosk, :boolean,
+                :null => false, :default => false
+    add_column :elections, :verifiable, :boolean,
+               :null => false, :default => true
+
+    Election.find(:all).select {|e| e.class == QuickVote }.each do |e|
+      e.verifiable = false
+      e.save
+    end
+  end
+
+  def self.down
+    remove_column :elections, :kiosk
+    remove_column :elections, :verifiable
+  end
+end
index c30d3f6432ce8537f02313607ea7d17c56683169..0d99d2e959895f1b34b81551bdd0c25e5fb8926d 100644 (file)
@@ -9,7 +9,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 3)
+ActiveRecord::Schema.define(:version => 3) do
 
   create_table "candidates", :force => true do |t|
     t.integer "election_id",                :null => false
@@ -18,34 +18,38 @@ ActiveRecord::Schema.define(:version => 3)
   end
 
   create_table "elections", :force => true do |t|
-    t.string   "name",            :limit => 100,                    :null => false
-    t.text     "description",                                       :null => false
-    t.integer  "anonymous",       :limit => 1,   :default => 1,     :null => false
+    t.string   "name",                :limit => 100,                    :null => false
+    t.text     "description",                                           :null => false
+    t.integer  "anonymous",           :limit => 1,   :default => 1,     :null => false
     t.datetime "startdate"
-    t.datetime "enddate",                                           :null => false
-    t.integer  "active",          :limit => 1,   :default => 0,     :null => false
-    t.integer  "viewable",        :limit => 1,   :default => 1,     :null => false
-    t.integer  "notices",         :limit => 1,   :default => 0,     :null => false
+    t.datetime "enddate",                                               :null => false
+    t.integer  "active",              :limit => 1,   :default => 0,     :null => false
+    t.integer  "viewable",            :limit => 1,   :default => 1,     :null => false
+    t.integer  "notices",             :limit => 1,   :default => 0,     :null => false
     t.integer  "user_id"
     t.string   "quickuser"
-    t.string   "election_method", :limit => 100, :default => "ssd"
-    t.string   "type",            :limit => 100,                    :null => false
-    t.boolean  "embeddable",                     :default => false, :null => false
-    t.boolean  "authenticated",                  :default => true,  :null => false
-    t.boolean  "early_results",                  :default => false, :null => false
+    t.string   "election_method",     :limit => 100, :default => "ssd"
+    t.string   "type",                :limit => 100,                    :null => false
+    t.boolean  "embeddable",                         :default => false, :null => false
+    t.boolean  "authenticated",                      :default => true,  :null => false
+    t.boolean  "early_results",                      :default => false, :null => false
+    t.string   "embed_custom_string"
   end
 
   add_index "elections", ["user_id"], :name => "fk_user_election"
 
   create_table "pictures", :force => true do |t|
-    t.string  "filename",     :limit => 200
-    t.binary  "data"
-    t.string  "filetype",     :limit => 100
-    t.integer "candidate_id"
+    t.string   "filename"
+    t.string   "content_type"
+    t.integer  "size"
+    t.integer  "width"
+    t.integer  "height"
+    t.integer  "parent_id"
+    t.string   "thumbnail"
+    t.datetime "created_at"
+    t.integer  "candidate_id"
   end
 
-  add_index "pictures", ["candidate_id"], :name => "fk_candidate_picture"
-
   create_table "rankings", :force => true do |t|
     t.integer "vote_id"
     t.integer "candidate_id"

Benjamin Mako Hill || Want to submit a patch?