From: Date: Sun, 7 Jun 2009 12:30:52 +0000 (-0400) Subject: added first stab at a kiosk mode X-Git-Url: https://projects.mako.cc/source/selectricity-live/commitdiff_plain/57a193789d1f48a856816c357483cfd7c621cd9d?ds=inline;hp=da8a3c5c6efcad4e4a5424a09c0479f7ee52a9ec added first stab at a kiosk mode --- diff --git a/app/controllers/voter_controller.rb b/app/controllers/voter_controller.rb index c063469..a912824 100644 --- a/app/controllers/voter_controller.rb +++ b/app/controllers/voter_controller.rb @@ -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] diff --git a/app/models/election.rb b/app/models/election.rb index a3cf8e4..a3e9394 100644 --- a/app/models/election.rb +++ b/app/models/election.rb @@ -89,6 +89,10 @@ class Election < ActiveRecord::Base def authenticated? authenticated end + + def kiosk? + kiosk + end def shortdesc shortdesc = description.split(/\n/)[0] diff --git a/app/views/election/_overview_form.rhtml b/app/views/election/_overview_form.rhtml index be90de6..1f540c6 100644 --- a/app/views/election/_overview_form.rhtml +++ b/app/views/election/_overview_form.rhtml @@ -23,11 +23,20 @@ <% type_hash = {}; ELECTION_TYPES.each {|k,v| type_hash[v] = k} %> <%= select_tag 'election[election_method]', options_for_select(type_hash, @election.election_method) %>

-

-<%= check_box :election, :embeddable %>

+

+<%= check_box :election, :verifiable%>

-

+

<%= check_box :election, :early_results%>

+

+<%= check_box :election, :embeddable %>

+ +

+Warning: This will let users vote multiple times +from the same computer! +<%= check_box :election, :kiosk%>

+ diff --git a/app/views/election/show.rhtml b/app/views/election/show.rhtml index 5de6081..ff116f4 100644 --- a/app/views/election/show.rhtml +++ b/app/views/election/show.rhtml @@ -51,12 +51,31 @@
  • Elections will be embeddable.
  • <% end %> +<% if @election.kiosk %> +
  • Selectricity's kiosk mode will be available.
  • +<% end %> + +<% if @election.verifiable%> +
  • Voters will be given tokens to verify their votes.
  • +<% else %> +
  • Elections will not be voter verifiable.
  • +<% end %> + <% if @election.active? and not @election.authenticated? %> -

    Link

    -<%= (link_to ("Go Vote!", - :controller => 'voter', :action => 'index', :election_id => @election.id)).to_s %> +

    Link to election:

    + <% end -%>
    diff --git a/app/views/layouts/_footer.rhtml b/app/views/layouts/_footer.rhtml index f481c85..d9747b8 100644 --- a/app/views/layouts/_footer.rhtml +++ b/app/views/layouts/_footer.rhtml @@ -1,5 +1,7 @@ diff --git a/app/views/voter/_vote_sidebar.rhtml b/app/views/voter/_vote_sidebar.rhtml index 2f250e0..58b1e56 100644 --- a/app/views/voter/_vote_sidebar.rhtml +++ b/app/views/voter/_vote_sidebar.rhtml @@ -6,5 +6,9 @@ order.

    <%= render :partial => 'common/sortable_vote' %>
    -<%= 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 %>
    diff --git a/app/views/voter/full_vote.rhtml b/app/views/voter/full_vote.rhtml index 5e8a8d1..80ea986 100644 --- a/app/views/voter/full_vote.rhtml +++ b/app/views/voter/full_vote.rhtml @@ -6,10 +6,12 @@

    Description:

    <%= @voter.election.description %>

    +<% if @voter.election.authenticated? %>
    Current Voter
    +<% end %>

    <%= @voter.email %>

    diff --git a/app/views/voter/kiosk_ready.rhtml b/app/views/voter/kiosk_ready.rhtml new file mode 100644 index 0000000..7773dd8 --- /dev/null +++ b/app/views/voter/kiosk_ready.rhtml @@ -0,0 +1,9 @@ +
    + <%= @voter.election.name %> + +
    + +

    Selectricity is running in kiosk mode and is ready for the next +voter. Press the button below to generate a new ballot.

    + +

    <%= button_to "Vote!", :action => "index", :urlpassword => @password, :kiosk => true %>

    diff --git a/db/migrate/20090607094837_kiosk_mode.rb b/db/migrate/20090607094837_kiosk_mode.rb new file mode 100644 index 0000000..57ea98d --- /dev/null +++ b/db/migrate/20090607094837_kiosk_mode.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index c30d3f6..0d99d2e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"