fixed a large number of bugs in the software (see wiki) over a days work
authorBenjamin Mako Hill <mako@atdot.cc>
Wed, 17 Jun 2009 05:22:34 +0000 (01:22 -0400)
committerBenjamin Mako Hill <mako@atdot.cc>
Wed, 17 Jun 2009 05:22:34 +0000 (01:22 -0400)
21 files changed:
app/controllers/election_controller.rb
app/controllers/quickvote_controller.rb
app/controllers/voter_controller.rb
app/models/election.rb
app/models/quick_vote.rb
app/views/account/summary.rhtml
app/views/common/_pref_tables.rhtml
app/views/common/details.rhtml [moved from app/views/voter/details.rhtml with 50% similarity]
app/views/common/pref_tables_wrapper.rhtml [moved from app/views/common/pref_tables.rhtml with 100% similarity]
app/views/common/results.rhtml [moved from app/views/voter/results.rhtml with 87% similarity]
app/views/election/_candidate_line_edit.rhtml
app/views/election/_full_results_sidebar.rhtml [new file with mode: 0644]
app/views/election/_voter_list.rhtml
app/views/election/detailed_results.rhtml [deleted file]
app/views/election/edit_candidates.rhtml
app/views/election/edit_general_information.rhtml
app/views/election/edit_voters.rhtml
app/views/election/show.rhtml
app/views/voter/_full_results_sidebar.rhtml [moved from app/views/voter/_results_sidebar.rhtml with 99% similarity]
app/views/voter/review.rhtml
app/views/voter/thanks.rhtml

index ad74a1b211de62a91b37a41e46e5756ab6fe8709..58c5c47f1737ae300eaa31fc77152957903080fb 100644 (file)
@@ -10,8 +10,17 @@ class ElectionController < ApplicationController
   require_dependency "voter"
   require_dependency "vote"
   require_dependency "candidate"
   require_dependency "voter"
   require_dependency "vote"
   require_dependency "candidate"
+
+  helper :sparklines
   layout 'main'
 
   layout 'main'
 
+
+  before_filter :verify_owner,
+    :except => [:new, :general_information, :create_election]
+  before_filter :verify_not_active,
+    :except => [:new, :general_information, :create_election,
+                :show, :results, :details, :pref_tables]
+
   ## methods for displaying, creating,
   ## and manipulating election overview data
   ####################################################################
   ## methods for displaying, creating,
   ## and manipulating election overview data
   ####################################################################
@@ -51,18 +60,9 @@ class ElectionController < ApplicationController
     end
   end
   
     end
   end
   
-  def create_theme_hash
-    target = Hash.new
-    params.each do |k,v|
-      target[k] = v if k=="top_bar" or k=="default_image" or k=="bg1" \
-                    or k=="bg2" or k=="bottom_bar"
-    end
-    return target
-  end
-  
-  # TODO add filter to verify that the person working on or looking at
-  # something is the owner
   def edit_general_information
   def edit_general_information
+    @sidebar_content = render_to_string :partial => 'progress',
+                                        :locals => { :page => 'overview' }
     @election = Election.find(params[:id])
   end
   
     @election = Election.find(params[:id])
   end
   
@@ -83,7 +83,7 @@ class ElectionController < ApplicationController
       flash[:notice] = 'Election was successfully updated.'
       redirect_to :action => 'show', :id => @election
     else
       flash[:notice] = 'Election was successfully updated.'
       redirect_to :action => 'show', :id => @election
     else
-      render :action => 'edit'
+      render :action => 'edit_general_information'
     end
   end
   
     end
   end
   
@@ -173,7 +173,7 @@ class ElectionController < ApplicationController
   def edit_candidates
     @sidebar_content = render_to_string :partial => 'progress',
                                         :locals => { :page => 'candidates' }
   def edit_candidates
     @sidebar_content = render_to_string :partial => 'progress',
                                         :locals => { :page => 'candidates' }
-    @election = Election.find( params[:id] )
+    @election = Election.find(params[:id] )
   end
 
   def add_candidate
   end
 
   def add_candidate
@@ -196,12 +196,12 @@ class ElectionController < ApplicationController
   end
   
   def delete_candidate
   end
   
   def delete_candidate
-    candidate = Candidate.find( params[:id] )
+    candidate = Candidate.find(params[:candidate] )
     candidate.destroy
   end
 
   def candidate_picture
     candidate.destroy
   end
 
   def candidate_picture
-    candidate = Candidate.find( params[:id] )
+    candidate = Candidate.find(params[:candidate])
     send_data( candidate.picture.data,
                :filename => candidate.picture.filename,
               :type => candidate.picture.filetype,
     send_data( candidate.picture.data,
                :filename => candidate.picture.filename,
               :type => candidate.picture.filetype,
@@ -219,7 +219,8 @@ class ElectionController < ApplicationController
     @sidebar_content = render_to_string :partial => 'progress',
                                         :locals => { :page => 'voters' }
 
     @sidebar_content = render_to_string :partial => 'progress',
                                         :locals => { :page => 'voters' }
 
-    @election = Election.find( params[:id] )
+    @election = Election.find(params[:id])
+
     if params.has_key?( :raw_voter_list )
       process_incoming_voters( params[:raw_voter_list] )
     end
     if params.has_key?( :raw_voter_list )
       process_incoming_voters( params[:raw_voter_list] )
     end
@@ -228,7 +229,7 @@ class ElectionController < ApplicationController
   end
   
   def delete_voter
   end
   
   def delete_voter
-    voter = FullVoter.find( params[:id] )
+    voter = FullVoter.find(params[:voter])
     voter.destroy
   end
 
     voter.destroy
   end
 
@@ -245,40 +246,27 @@ class ElectionController < ApplicationController
   ## methods for computing and printing results
   ####################################################################
   def results
   ## methods for computing and printing results
   ####################################################################
   def results
-    @election = Election.find( params[:id] )
-    votes = []
-    
-    @election.voters.each do |voter|
-      if voter.vote and voter.vote.confirmed?
-        votes << voter.vote.rankings.sort.collect {|vote| vote.candidate_id}
-      end
+    @election = Election.find(params[:id])
+
+    if @election.early_results? \
+       or @election.enddate < Time.now
+      
+      # render results
+      @sidebar_content = render_to_string(:partial => 'full_results_sidebar')
+      render :template => 'common/results'
+    else
+      redirect_to :action => 'index'
     end
     end
-    
-    @voteobj = CloneproofSSDVote.new(votes)
-    @resultobj = @voteobj.result
-    @winners = @resultobj.winners
-    
-    @candidates_by_id = {}
-    @election.candidates.each {|cand| @candidates_by_id[cand.id] = cand}
-    
   end
   
   end
   
-  def detailed_results
-   
-    self.results
-
-    @voter_list = []
-    @vote_list = []
-    
-    @election.voters.each do |voter|
-      if voter.vote and voter.vote.confirmed?
-        @voter_list << voter.email
-             @vote_list << voter.vote
-      end
-    end
+  def pref_tables
+    @election = Election.find(params[:id])
+    render :template => 'common/pref_tables_wrapper', :layout => 'basic'
+  end
 
 
-    @vote_list.sort!
-    @vote_list.sort! { |a,b| a.token <=> b.token }
+  def details
+    @election = Election.find(params[:id])
+    render :template => 'common/details'
   end
 
   ## private methods
   end
 
   ## private methods
@@ -314,5 +302,30 @@ class ElectionController < ApplicationController
         voter.save
       end
     end
         voter.save
       end
     end
+  
+    def create_theme_hash
+      target = Hash.new
+      params.each do |k,v|
+        target[k] = v if k=="top_bar" or k=="default_image" or k=="bg1" \
+                      or k=="bg2" or k=="bottom_bar"
+      end
+      return target
+    end
+
+    # verify that the person trying to edit the election is the owner
+    def verify_owner
+      election = Election.find(params[:id])
+      unless election.user == session[:user]
+        redirect_to :controller => 'front', :action => 'index' 
+      end
+    end
+
+    # verify that the election is not active
+    def verify_not_active
+      election = Election.find(params[:id])
+      unless election.active == 0
+        redirect_to :controller => 'front', :action => 'index' 
+      end
+    end
 
 end
 
 end
index 5bf89c775b18026810fa74b89bcea3fe5184ec0b..066fd6ba463635c12af56ea07b9e5e449d998294 100644 (file)
@@ -44,6 +44,7 @@ class QuickvoteController < ApplicationController
 
       #Give registered users additional QuickVote functionality 
       @quickvote.user_id = session[:user][:id] if session[:user]
 
       #Give registered users additional QuickVote functionality 
       @quickvote.user_id = session[:user][:id] if session[:user]
+      @quickvote.create_candidates
 
       # try to save, if it fails, show the page again (the flash should
       # still be intact
 
       # try to save, if it fails, show the page again (the flash should
       # still be intact
index 9ba619c918a3f1e1a0858f8ba962984929b17c1d..1634ccd1a86d4854f96f6b5922154d26139accfe 100644 (file)
@@ -12,6 +12,9 @@ class VoterController < ApplicationController
   require_dependency "vote"
   require_dependency "election"
 
   require_dependency "vote"
   require_dependency "election"
 
+  before_filter :authenticate, :except => [:index, :login, :reminder,
+                                           :kiosk_ready]
+
   def index
     if params[:election_id]
       @election = Election.find(params[:election_id])
   def index
     if params[:election_id]
       @election = Election.find(params[:election_id])
@@ -80,54 +83,23 @@ class VoterController < ApplicationController
     end
   end
   
     end
   end
   
-  def pref_tables
-    if authenticate
-      @election = @voter.election
-      @results = @election.results
-      @candidates = {}
-      @election.candidates.each {|c| @candidates[c.id] = c}
-      @names = @election.names_by_id
-      render :template => 'common/pref_tables', :layout => 'basic'
-    else
-      redirect_to :action => 'index'
-    end
-  end
-
-  def details
-    if authenticate
-      @election = @voter.election
-      @votes = @election.votes.select {|v| v.confirmed? }.shuffle
-      @voters = @votes.collect {|v| v.voter}.shuffle
-      render :action => 'details'
-    else
-      redirect_to :action => 'index'
-    end
-  end
-
   def review
   def review
-    if authenticate
-      @voter.vote.time = Time.now
-      @voter.vote.save
-      @voter.reload
-    else
-      redirect_to :action => 'index'
-    end
+    @voter.vote.time = Time.now
+    @voter.vote.save
+    @voter.reload
   end
 
   def confirm
   end
 
   def confirm
-    if authenticate
-      @voter.vote.confirm!
-
-      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
+    @voter.vote.confirm!
+
+    if @voter.election.embeddable? and params[:embed] == "true" \
+      and @voter.election.early_results?
+      redirect_to :action => :results, :id => @password, :embed => 'true'
+    elsif not(@voter.election.verifiable) \
+      and @voter.election.kiosk and params[:kiosk] == "true"
+      redirect_to :action => "kiosk_ready", :id => @password, :kiosk => true
     else
     else
-      redirect_to :action => 'index'
+      render :action => 'thanks'
     end
   end
   
     end
   end
   
@@ -143,19 +115,12 @@ class VoterController < ApplicationController
   end
   
   def results
   end
   
   def results
-    if authenticate and
-      (@voter.election.early_results? \
-       or @voter.election.enddate < Time.now)
+    if @voter.election.early_results? \
+       or @voter.election.enddate < Time.now
       
       @election = @voter.election
       
       @election = @voter.election
-      # compute and display results
-
-      @results = @election.results
-      @candidates = {}
-      @election.candidates.each {|c| @candidates[c.id] = c}
-      @names = @election.names_by_id
-        
-      @sidebar_content = render_to_string(:partial => 'results_sidebar')
+      @sidebar_content = render_to_string(:partial => 'full_results_sidebar')
+
       #look for custom theme, and assign to instance variabels for widget use
       if @election.embed_custom_string
         @top_bar = SkinPicture.find(:first,
       #look for custom theme, and assign to instance variabels for widget use
       if @election.embed_custom_string
         @top_bar = SkinPicture.find(:first,
@@ -172,13 +137,23 @@ class VoterController < ApplicationController
       if @election.embeddable? and params[:embed] == "true"
         render :template => 'embed/results', :layout => 'embed'
       else
       if @election.embeddable? and params[:embed] == "true"
         render :template => 'embed/results', :layout => 'embed'
       else
-        render :action => 'results'
+        render :template => 'common/results'
       end
     else
       redirect_to :action => 'index'
     end
   end
  
       end
     else
       redirect_to :action => 'index'
     end
   end
  
+  def pref_tables
+    @election = @voter.election
+    render :template => 'common/pref_tables_wrapper', :layout => 'basic'
+  end
+
+  def details
+    @election = @voter.election
+    render :template => 'common/details'
+  end
+
   def kiosk_ready
     reset_session
 
   def kiosk_ready
     reset_session
 
@@ -193,21 +168,25 @@ class VoterController < ApplicationController
     if password == "open"
       election = Election.find(params[:format])
 
     if password == "open"
       election = Election.find(params[:format])
 
-      # check to see if the person has voted before
-      unless election.authenticated?
+      # if it's not actually open, lets redirect
+      if election.authenticated
+        redirect_to :action => 'index'
+      
+      # otherwise, lets see if they've before
+      else
         @voter = OpenVoter.find(:all,
           :conditions => ["session_id = ? and election_id = ?",
                           session.session_id, election.id])[0]
         @voter = OpenVoter.find(:all,
           :conditions => ["session_id = ? and election_id = ?",
                           session.session_id, election.id])[0]
-        @password = "open." + election.id.to_s
-      end
 
 
-      # if it's ready for kiosk_mode, then we create and authenticate
-      unless @voter and params[:action] == 'kiosk_ready' \
-        and election.kiosk
-       
-        # this is maybe not quite as a dry as it should be
-        @voter = OpenVoter.new unless @voter
+        # when (a) there is no voter or (b) when there is a voter but
+        # it's kiosk mode on the right page, rewrite witha  blank voter
+        if not(@voter) \
+          or (params[:action] == 'kiosk_ready' and election.kiosk)
+          @voter = OpenVoter.new unless @voter
+        end
 
 
+        # now that we have a voter (one way or another), set things
+        # right
         @voter.election = election
         @voter.session_id = session.session_id
         @password = "open." + election.id.to_s
         @voter.election = election
         @voter.session_id = session.session_id
         @password = "open." + election.id.to_s
@@ -216,9 +195,13 @@ class VoterController < ApplicationController
     else
       @voter = FullVoter.find(:all,
         :conditions => [ "password = ?", password ] )[0]
     else
       @voter = FullVoter.find(:all,
         :conditions => [ "password = ?", password ] )[0]
-      @password = @voter.password
+
+      if @voter
+        @password = @voter.password
+      else
+        redirect_to :Action => 'index'
+      end
     end
     end
-    @voter
   end
 end
 
   end
 end
 
index a3e939424ac11099ba5c1f6e70dd5b0989b2b405..4ce571a468c4aa91a39fd6696e7a76161e706afd 100644 (file)
@@ -11,9 +11,12 @@ class Election < ActiveRecord::Base
   has_many :votes
   belongs_to :user
   validates_presence_of :name, :description
   has_many :votes
   belongs_to :user
   validates_presence_of :name, :description
-  
+
+  # enforce constraints associated with dependencies (i.e., a kiosk
+  # election can't also be unauthenticated)
+  before_save :enforce_constraints
+
   #validate that method is one of the listed election types
   #validate that method is one of the listed election types
-  
   attr_reader :plurality_result
   attr_reader :approval_result
   attr_reader :condorcet_result
   attr_reader :plurality_result
   attr_reader :approval_result
   attr_reader :condorcet_result
@@ -21,7 +24,7 @@ class Election < ActiveRecord::Base
   attr_reader :borda_result
   
   require 'date'
   attr_reader :borda_result
   
   require 'date'
-  
   def initialize(params={})
     super
     self.enddate = read_attribute( :enddate ) || \
   def initialize(params={})
     super
     self.enddate = read_attribute( :enddate ) || \
@@ -71,7 +74,7 @@ class Election < ActiveRecord::Base
 
   def activate!
     self.active = 1
 
   def activate!
     self.active = 1
-    self.save!
+    self.save
   end
   
   def quickvote?
   end
   
   def quickvote?
@@ -164,6 +167,30 @@ class Election < ActiveRecord::Base
     
     names
   end
     
     names
   end
+
+  def candidate_hash
+    hash = {}
+    self.candidates.each {|c| hash[c.id] = c}
+    return hash
+  end
+
+  # TODO now that this code is in here, we should go ahead and remove
+  # date checking from other places in the code
+  def after_find
+    if self.active < 2 and self.enddate < Time.now 
+      self.active = 2
+      self.save
+    end
+  end
+
+  private
+  def enforce_constraints
+    # kiosks can't be authenticated
+    self.authenticated = false if kiosk?
+    return true
+  end
+
 end
 
 
 end
 
 
index de78813153025698796b8ce274f711072cf984e5..f9e1b83d8a02b81cf81c4c28fdc6323df7b48126 100644 (file)
@@ -1,6 +1,5 @@
 class QuickVote < Election
   before_validation :build_candidate_names
 class QuickVote < Election
   before_validation :build_candidate_names
-  after_validation :create_candidates
   validates_uniqueness_of :name
 
   attr_accessor :candidate_names
   validates_uniqueness_of :name
 
   attr_accessor :candidate_names
@@ -60,8 +59,8 @@ class QuickVote < Election
 
   def build_candidate_names
     @candidate_names ||= []
 
   def build_candidate_names
     @candidate_names ||= []
-    if @candidate_names.empty? and not candidates.empty?
-        @candidate_names = candidates.collect {|c| c.name}
+    if @candidate_names.empty? and not self.candidates.empty?
+        @candidate_names = self.candidates.collect {|c| c.name}
     end
   end
 
     end
   end
 
index b53122ed5094a898d026132ff464132128163f3d..0ea9f241dcb729614205a6445581998fc1b3335a 100644 (file)
@@ -21,12 +21,8 @@ Member since: <%=h @user.created_at.strftime("%x") %>
     <% @user.elections.select {|e| e.instance_of?(Election)}.each do |election| %>
     <tr>
          <td style="text-align: left;">
     <% @user.elections.select {|e| e.instance_of?(Election)}.each do |election| %>
     <tr>
          <td style="text-align: left;">
-           <% if election.active == 1 -%>
            <%= link_to "#{election.name}", :controller => 'election', 
                            :action => 'show', :id => election %>
            <%= link_to "#{election.name}", :controller => 'election', 
                            :action => 'show', :id => election %>
-               <% else -%>
-                 <%=h election.name %>
-               <% end -%>
          </td>
          <td style="text-align: left;"><%=h election.description %></td>
          <td style="text-align: left;">
          </td>
          <td style="text-align: left;"><%=h election.description %></td>
          <td style="text-align: left;">
index 3a53144068b601556d16b79f12d516fed90535ea..3edc05a1811c4da80c04aa764ac301e12bd65c62 100644 (file)
@@ -1,7 +1,13 @@
+<!-- first, process the results -->
+<% @election.results! %>
+
+<!-- create the necessary variables -->
 <% candidates = @election.ssd_result.ranked_candidates.flatten -%>
 <% voters = @election.voters.size %>
 <% matrix = @election.ssd_result.matrix %>
 <% victories = @election.ssd_result.victories_and_ties %>
 <% candidates = @election.ssd_result.ranked_candidates.flatten -%>
 <% voters = @election.voters.size %>
 <% matrix = @election.ssd_result.matrix %>
 <% victories = @election.ssd_result.victories_and_ties %>
+<% @names = @election.names_by_id %>
+
 <p>Each number in the table below shows how many times the candidate on
 the left beat the matching candidate on the top. The winner is on the
 top of the left column.</p>
 <p>Each number in the table below shows how many times the candidate on
 the left beat the matching candidate on the top. The winner is on the
 top of the left column.</p>
similarity index 50%
rename from app/views/voter/details.rhtml
rename to app/views/common/details.rhtml
index cf73f4189c7ae52865b0e163585bb46baa1aeac6..ae09c2975b7821ee5fdc292482fd51a455d70abe 100644 (file)
@@ -1,3 +1,6 @@
+<% @votes = @election.votes.select {|v| v.confirmed? }.shuffle %>
+<% @voters = @votes.collect {|v| v.voter}.shuffle %>
+
 <div id="title-header">
   <span class="header">Details</span>
   <span class="subheader"><%= @election.name %></span>
 <div id="title-header">
   <span class="header">Details</span>
   <span class="subheader"><%= @election.name %></span>
@@ -11,27 +14,35 @@ election:</p>
 
 <ol>
 <%- @voters.each do |voter| -%>
 
 <ol>
 <%- @voters.each do |voter| -%>
-<li><%= voter.email %></li>
+<li><% if voter.email %>
+       <%= voter.email %>
+    <% elsif @election.kiosk? %>
+       Kiosk Voter
+    <% else %>
+       Unknown voter
+    <% end %></li>
 <%- end -%>
 </ol>
 
 <p>The following table lists the votes cast in random order.</p>
 
 <%- end -%>
 </ol>
 
 <p>The following table lists the votes cast in random order.</p>
 
-<p>The column marked <em>Verification Token</em> lists tokens that were
-given to voters at the time of voting. Voters can check to see that the
-vote that corresponds to their token was recorded correctly. The column
-marked <em>Vote</em> lists the candidates in order of the voter's
-preference. To read these votes, refer to the key below.</p>
+<p><% if @election.verifiable %>The column marked <em>Verification
+Token</em> lists tokens that were given to voters at the time of voting.
+Voters can check to see that the vote that corresponds to their token
+was recorded correctly.<% end %> The column marked <em>Vote</em> lists
+the candidates in order of the voter's preference. To read these votes,
+refer to the key below.</p>
 
 <table class="preftable">
 <tr>
 <th></th>
 
 <table class="preftable">
 <tr>
 <th></th>
-<th>Verification Token</th>
+<% if @election.verifiable %><th>Verification Token</th><% end %>
 <th>Vote</th>
 <%- @votes.each_with_index do |vote, i| -%>
 <tr>
 <td><%= i + 1 %></td>
 <th>Vote</th>
 <%- @votes.each_with_index do |vote, i| -%>
 <tr>
 <td><%= i + 1 %></td>
-<td><%= vote.token %></td><td><%= vote.votestring%></td>
+<% if @election.verifiable %><td><%= vote.token %></td><% end %>
+<td><%= vote.votestring%></td>
 </tr>
 <%- end -%>
 </table>
 </tr>
 <%- end -%>
 </table>
similarity index 87%
rename from app/views/voter/results.rhtml
rename to app/views/common/results.rhtml
index bb95c88438905e016342b3b4c21ccfa073eb6f2d..6f3a18d10ac8c6c7b764a953ce3836b18f3a3764 100644 (file)
@@ -1,3 +1,8 @@
+<!-- create the default variables -->
+<% @results = @election.results %>
+<% @names = @election.names_by_id %>
+<% @candidates = @election.candidate_hash %>
+
 <% require 'whois/whois' %>
 
 <div id="title-header">
 <% require 'whois/whois' %>
 
 <div id="title-header">
index bcb7cd92809eb2731549dd1cd584746bb9c4c0ec..0260a6a7176091ad10dbd2b540da10ea019b40d8 100644 (file)
@@ -6,7 +6,7 @@
   <%= link_to_remote "Delete",
                        :complete => "Element.remove('cand#{@current_candidate.id}')",
                        :url => { :action => :delete_candidate,
   <%= link_to_remote "Delete",
                        :complete => "Element.remove('cand#{@current_candidate.id}')",
                        :url => { :action => :delete_candidate,
-                      :id => @current_candidate.id } %>
+                      :id => @election.id, :candidate => @current_candidate.id } %>
    </div>
    <div class="clear-div"></div>
    <%= render :partial => 'candidate_box_info' %>
    </div>
    <div class="clear-div"></div>
    <%= render :partial => 'candidate_box_info' %>
diff --git a/app/views/election/_full_results_sidebar.rhtml b/app/views/election/_full_results_sidebar.rhtml
new file mode 100644 (file)
index 0000000..bb3bbc9
--- /dev/null
@@ -0,0 +1,6 @@
+<!-- common data to all sidebars -->
+<%= render :partial => 'common/results_sidebar' %>
+
+<h2>Details</h2>
+
+<p><%= link_to "Auditing Information", { :action => 'details', :id => @election.id }, :popup => [] %></p>
index 4493b0a3950f5c862576f4172c7463004a9d15fa..34aa2074d385a6f5f0d6730e5c6420473cfc84af 100644 (file)
@@ -13,7 +13,8 @@
         <% if @edit %>
         <%= link_to_remote "Delete",
                     :complete => "Element.remove('voter#{voter.id}')",
         <% if @edit %>
         <%= link_to_remote "Delete",
                     :complete => "Element.remove('voter#{voter.id}')",
-                    :url => { :action => :delete_voter, :id => voter.id } %>
+                    :url => { :action => :delete_voter, :id => @election.id,
+                              :voter => voter.id } %>
         <% end %>
     </li>
   </div>  
         <% end %>
     </li>
   </div>  
diff --git a/app/views/election/detailed_results.rhtml b/app/views/election/detailed_results.rhtml
deleted file mode 100644 (file)
index 1f22377..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-<h2>Result</h2>
-
-<%= render :partial => 'winner' %>
-
-<h2>Result Details</h2>
-
-<%= render :partial => 'winner_details' %>
-
-<h2>Election Rolls for Voter Verification</h2>
-
-<p>The voting rolls -- displayed here in alphabetical order -- for the
-last election are are follows.</p>
-
-<p>Information is displayed here to help voters verifying that their own
-vote was recorded correctly and that the election was not tampered
-with.</p>
-
-<h3>Voters</h3>
-<table border="1">
-<th>Voters (A-Z)</th>
-<% for email in @voter_list %>
-<tr>
-<td><%= email %></td>
-</tr>
-<% end %>
-</table>
-
-<h3>Votes by Token</h3>
-
-<p>The votes, listed in alphabetical order by token.</p>
-
-<table border="1">
-<tr>
-  <th rowspan="2">Token (0-9, A-Z)</th>
-  <th colspan="<%= @election.candidates.length %>">Rank of Candidates</th>
-</tr>
-<tr>
-
-<% for candidate in @election.candidates.sort.reverse %>
-  <th><%= candidate %></th>
-<% end %>
-
-</tr>
-<% for vote in @vote_list %>
-  <tr>
-  <td><%= vote.token %></td>
-  <% for ranking in vote.rankings %>
-    <td><%= ranking %></td>
-  <% end %>
-  </tr>
-<% end %>
-</table>
index 7e1f315c9506f86268f94046fedee7c361689ee1..cd0bd5ab7c99b5b05174677ddde9d0d36b26aff9 100644 (file)
@@ -5,6 +5,8 @@
 
 <div class="clear-div"></div>
 
 
 <div class="clear-div"></div>
 
+<% if @election.active == 0 %>
+
 <div class="normal-header">
   <span class="header">Enter New Candidate</span>
   <span class="subheader"></span>
 <div class="normal-header">
   <span class="header">Enter New Candidate</span>
   <span class="subheader"></span>
 to proceed to the next step.</p>
 
 <%= button_to "Proceed to Next Step", :action => 'new_voters', :id => @election %>
 to proceed to the next step.</p>
 
 <%= button_to "Proceed to Next Step", :action => 'new_voters', :id => @election %>
+
+<% else %>
+
+<p>You can not edit the list of candidates once the election has begun.
+please return to the <%= link_to "election overview page", :action =>
+'show', :id => @election.id %>.</p>
+
+<% end %>
index 17ec3247f003e1a9a000b9f7abcfc84ca84cf2fd..1d8ec907e1c6230e77e5b8a426fcb12c32c1368f 100644 (file)
@@ -6,7 +6,7 @@
 <% form_tag( {:action => 'update_general_information', :id => @election},
                        :multipart => true ) do %>
   <%= render :partial => 'overview_form' %>
 <% form_tag( {:action => 'update_general_information', :id => @election},
                        :multipart => true ) do %>
   <%= render :partial => 'overview_form' %>
-  <%= render :partial => 'theme_upload' %>
+  <!--  <%= render :partial => 'theme_upload' %> -->
   <%= submit_tag 'Done' %>
 <% end %>
 
   <%= submit_tag 'Done' %>
 <% end %>
 
index 77093fe5262db3783c7589a014291708b199e5ef..770c5ecdabed0819ea47a1a4479d757345941147 100644 (file)
@@ -3,8 +3,13 @@
   <span class="subheader"></span>
 </div>
 
   <span class="subheader"></span>
 </div>
 
-<p id="unauth_notice" <%= 'style="display: none;"' if @election.authenticated %>>Anyone will be able to
-vote in this election.</p>
+<% if @election.active == 0 %>
+
+<p id="unauth_notice" <%= 'style="display: none;"' if @election.authenticated %>>
+<% if @election.kiosk? %>
+  <em>Because you have enabled kiosk mode, there will be no registration of voters.</em>
+<% end %>
+Anyone will be able to vote in this election.</p>
 
 <div id="voter_info_box" <%= 'style="display: none;"' unless @election.authenticated %>>
 <%= render :partial => 'voter_list' %>
 
 <div id="voter_info_box" <%= 'style="display: none;"' unless @election.authenticated %>>
 <%= render :partial => 'voter_list' %>
@@ -14,7 +19,9 @@ vote in this election.</p>
 <% end %>
 </div>
 
 <% end %>
 </div>
 
-<%= check_box :election, :authenticated %> Only allow registered voters 
+<% unless @election.kiosk? %>
+  <%= check_box :election, :authenticated %> Only allow registered voters 
+<% end %>
 
 <%= observe_field "election_authenticated",
       :url => { :action => 'toggle_authenticated', :id => @election.id },
 
 <%= observe_field "election_authenticated",
       :url => { :action => 'toggle_authenticated', :id => @election.id },
@@ -32,4 +39,13 @@ vote in this election.</p>
 <p>When you are done entering voters, please click the button below
 to proceed to the next step.</p>
 
 <p>When you are done entering voters, please click the button below
 to proceed to the next step.</p>
 
-<%= button_to 'Proceed to Next Step!', :action => 'show', :id => @election.id %>
+<%= button_to 'Proceed to Next Step', :action => 'show', :id => @election.id %>
+
+<% else %>
+
+<p>You can not edit the list of voters once the election has begun.
+please return to the <%= link_to "election overview page", :action =>
+'show', :id => @election.id %>.</p>
+
+<% end %>
+
index 2f628958434ab99c798dc75a8a0de69590c74ab5..39621bfbf329b1457a2752b7aa0dd7348be41177 100644 (file)
@@ -8,13 +8,13 @@
        :election_id => @election.id %>.</div>
 
 <% elsif (@election.active? && @election.early_results? ) %>
        :election_id => @election.id %>.</div>
 
 <% elsif (@election.active? && @election.early_results? ) %>
-  <div id="status">The creator of this election has decided that the results
+  <div id="status">You have decided that the results
        should be viewable while the election is in progress.
        should be viewable while the election is in progress.
-       <%if @election.voters.empty? %>
+       <%if @election.voters.select {|v| v.vote.confirmed?}.empty? %>
        However, no one has voted yet.
        <% else %>
        However, no one has voted yet.
        <% else %>
-       <%= link_to "View results", :controller => 'voter', :action => 'results', 
-               :id => "open" %>.
+       <%= link_to "View results", :controller => 'election', :action => 'results', 
+               :id => @election.id %>.
     <% end %>
   </div>
 <% elsif @election.active? %>
     <% end %>
   </div>
 <% elsif @election.active? %>
similarity index 99%
rename from app/views/voter/_results_sidebar.rhtml
rename to app/views/voter/_full_results_sidebar.rhtml
index 81cc9079e8b24e91a037ae3458deb0dbab1389f6..b85390f933c85f1ce7309e4e175929b85028349e 100644 (file)
@@ -4,4 +4,3 @@
 <h2>Details</h2>
 
 <p><%= link_to "Auditing Information", { :action => 'details', :id => @password }, :popup => [] %></p>
 <h2>Details</h2>
 
 <p><%= link_to "Auditing Information", { :action => 'details', :id => @password }, :popup => [] %></p>
-
index b831aef225471db68e2181fd2c1b8a670bc202a5..a72ecda7b2a18d70f5d57bf1c47c015bae428d74 100644 (file)
@@ -24,15 +24,28 @@ preferred to least preferred:</p>
 <p>Please select from one of the following pages.</p>
 
 <div style="text-align: center;">
 <p>Please select from one of the following pages.</p>
 
 <div style="text-align: center;">
-  <p><%= button_to 'Confirm This Vote', :action => 'confirm', :id => @password %></p>
-
-  <p>If you choose, you will be able to go back<br />and change it up until
-  the end of the voting period.</p>
+  <p><% if @voter.election.kiosk? and params[:kiosk] == 'true' %>
+        <%= button_to 'Confirm This Vote', :action => 'confirm', :id => @password,
+                      :kiosk => true %>
+      <% else %>
+        <%= button_to 'Confirm This Vote', :action => 'confirm', :id => @password %>
+      <% end %>
+  </p>
+
+  <% unless @voter.election.kiosk? %>
+    <p>If you choose, you will be able to go back<br />and change it up until
+    the end of the voting period.</p>
+  <% end %>
   
   
-  <p><%= button_to 'Discard This Vote', votepassword_url(
-                   :action => 'index', :urlpassword => @password) %></p>
-
-  <p>You will be returned to the voting page to vote<br /> again, if you choose.</p>
-
+  <p><% if @voter.election.kiosk? and params[:kiosk] == 'true' %>
+        <%= button_to 'Discard This Vote', 
+            votepassword_url(:action => 'index', :urlpassword => @password,
+                             :kiosk => true) %>
+      <% else %>
+        <%= button_to 'Discard This Vote', 
+            votepassword_url(:action => 'index', :urlpassword => @password) %>
+      <% end %>
+    </p>
+    
 </tr>
 </div>
 </tr>
 </div>
index 7562c61681faef0b4d03f3f0c36062dad0495d8d..c68e22bc0046ee7ec95abe5c291d12a6f6bd310b 100644 (file)
 end of the election, you will be able to use this token to verify that
 your vote was used in the election and that your vote was recorded
 correctly.</p>
 end of the election, you will be able to use this token to verify that
 your vote was used in the election and that your vote was recorded
 correctly.</p>
+
+<% if @voter.election.kiosk? and params[:kiosk] == 'true' %>
+
+<p>Please click the done button below when finished to reset the system
+for the next voter.</p>
+
+<%= button_to "Done", :action => "kiosk_ready", :id => @password, :kiosk => true  %>
+
+<% end %>

Benjamin Mako Hill || Want to submit a patch?