elections marked as viewable will now dispaly a link to their results page while...
author<jlsharps@mit.edu> <>
Fri, 9 May 2008 23:12:17 +0000 (19:12 -0400)
committer<jlsharps@mit.edu> <>
Fri, 9 May 2008 23:12:17 +0000 (19:12 -0400)
app/controllers/election_controller.rb
app/views/election/show.rhtml

index bfef0215377bc7547616dd343c81ecf8226aee83..571b93628e7e916f2dd4e2228e91c02729c5344d 100644 (file)
@@ -173,7 +173,7 @@ class ElectionController < ApplicationController
   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}
@@ -186,6 +186,7 @@ class ElectionController < ApplicationController
     
     @candidates_by_id = {}
     @election.candidates.each {|cand| @candidates_by_id[cand.id] = cand}
+    
   end
   
   def detailed_results
@@ -194,7 +195,8 @@ class ElectionController < ApplicationController
 
     @voter_list = []
     @vote_list = []
-    @election.voters. each do |voter|
+    
+    @election.voters.each do |voter|
       if voter.vote and voter.vote.confirmed?
         @voter_list << voter.email
              @vote_list << voter.vote
index 5a46af94a3008c55dbe29c05d81ca82578fd8543..6060fb162d08a6f6b14c609ab93d6b291c2060f1 100644 (file)
@@ -3,12 +3,24 @@
   <span class="subheader"></span>
 </div>
 
-<% if @election.active? %>
+<% if @election.done? %>
+<div id="status">Election is finished. <%= link_to "View results",
+  :action => 'detailed_results', :id => @election.id %>.</div>
+
+<% elsif (@election.active? && @election.viewable?) %>
+  <div id="status">The creator of this election has decided that the results
+       should be viewable while the election is in progress.
+       <%if @election.voters.empty? %>
+       However, no one has voted yet.
+       <% else %>
+       <%= link_to "View results", :action => 'detailed_results', 
+               :id => @election.id %>.
+    <% end %>
+  </div>
+<% elsif @election.active? %>
   <div id="status">Vote is in currently in progress. Return to
         this page for results on <%= @election.enddate %>.</div>
-<% elsif @election.done? %>
-  <div id="status">Election is finished. <%= link_to "View results",
-  :action => 'results', :id => @election.id %>.</div>
+  
 <% else %>
   <p style="text-align: right;">
     <%= link_to "Edit General Information",
@@ -41,7 +53,7 @@
 
 </ul>
 
-<% unless @election.authenticated -%>
+<% 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 %>

Benjamin Mako Hill || Want to submit a patch?