Allowed for the results page of quickvotes to be hidden while the quickvote is go
author<jlsharps@mit.edu> <>
Sat, 25 Aug 2007 00:59:18 +0000 (20:59 -0400)
committer<jlsharps@mit.edu> <>
Sat, 25 Aug 2007 00:59:18 +0000 (20:59 -0400)
ing on. Also added a 'notices' option to QuickVotes available only to logged in u
sers. Those two options were added to the elections table, so they should be easy
 to extend to full elections. Also redid some logic on the layout and index.

app/controllers/quickvote_controller.rb
app/views/layouts/main.rhtml
app/views/quickvote/_advanced.rhtml
app/views/quickvote/my_quickvotes.rhtml
app/views/quickvote/not_viewable.rhtml [new file with mode: 0644]
app/views/site/index.rhtml
db/create.sql
db/schema.rb

index c2ed0559659e4995f7ccbb53aecd74aef41b81eb..7ad1722cb59cf69f2021b22021647ef0a26f452f 100644 (file)
@@ -178,6 +178,9 @@ class QuickvoteController < ApplicationController
       redirect_to :controller => 'site'
       return
     end
+    if @election.viewable == 0 && @election.active == 1
+      render :action => 'not_viewable' and return
+    end
     @results = @election.results
     @candidates = {}
     @election.candidates.each {|c| @candidates[c.id] = c}
index 0b9d5cb9d5f2a18494ff4392da386561273525e2..027ef145567213b95a8406ffc5450a8467c44588 100644 (file)
            <div id="links">
              <% if session[:user] %>
                Welcome <strong><%= User.find(session[:user]).login.capitalize %></strong>
+               <%= link_to("Logout", :controller => "account", :action => "logout") %>  |
              <% else %>
                <%= link_to("Login", :controller => "account", :action => "login")
                 %>/<%= link_to("Sign up", :controller => "account", :action => "signup")%>
              <% end %> |
-         
-             <% if session[:user] %>
-               <%= link_to("Logout", :controller => "account", :action => "logout") %>  |
-             <% end %>
              
             <%= link_to("Help/About", :controller => "site", :action => "about") %>
            </div>
index 3037ccc7c6b70e5a0d45adf846b9ac0a2b513d3b..0255fbd6e27599285556adc61c5ce21d06f8dbc9 100644 (file)
@@ -8,4 +8,14 @@
 <span><label for="quickvote_enddate">End Time</span><br />
 <%= quickform.date_select(:enddate, :start_year => Time.now.year) %><br />
 
+</p>Want the results to be visible while the election is active?
+Yes <%= quickform.radio_button(:viewable, 1)%>
+No  <%= quickform.radio_button(:viewable, 0)%></p>
+
+<% if session[:user] %>
+<p>Would you like to be e-mailed when this QuickVote concludes?
+Yes <%= quickform.radio_button(:notices, 1)%>
+No  <%= quickform.radio_button(:notices, 0)%></p>
+<% end -%>
+
 <% end %>
index a512c7f517fb8db8db8e5dea825f26bedee2ac14..a920480be21a2515272ecf398f91190fd19f10bb 100644 (file)
@@ -7,13 +7,18 @@
 
   <% @myqvs.each do |quickvote| %>
   <tr>
-       <td>
-       <%= link_to "#{quickvote.name}",
-          quickaction_url( :ident => quickvote.name, :action => 'results' ) %>
+       <td>    
+         <% if quickvote.active == 1 %>
+           <%= link_to "#{quickvote.name}",
+                    quickaction_url( :ident => quickvote.name, 
+                                     :action => 'results' ) %>
+               <% else %>
+                 <%= quickvote.name %>
+               <% end %>
        </td>
     <td><%= quickvote.startdate.strftime("%x") %></td>
     <td><%= quickvote.enddate.strftime("%x") %></td>
-       <td><%= quickvote.description %>
+       <td><%= quickvote.description %></td>
   </tr>
 <% end %>
 </table>       
diff --git a/app/views/quickvote/not_viewable.rhtml b/app/views/quickvote/not_viewable.rhtml
new file mode 100644 (file)
index 0000000..3c5532e
--- /dev/null
@@ -0,0 +1,3 @@
+<p>Sorry, the creator of this QuickVote has decided this election shouldn't
+       be visible while the QuickVote is running. </p>
+<%= link_to "Selectricity Home", :controller => 'site' %>
\ No newline at end of file
index 0c442189e1f573c463be20a72c1c884e88da303d..9b0b1fec8e8a672a3594a983cf55e6ab086fcef4 100644 (file)
@@ -53,7 +53,7 @@ ongoing election, you can log in to vote using your token here.</p>
 
 <p><%= link_to 'Lost or forgot your token?', :controller => 'voter', :action => 'forgot_password' %></p>
 <% if session[:user] %>
-  <%= render_partial 'user_summary' %> 
+  <%= render :partial => 'user_summary' %> 
 <% else %>
   <h2>Vote Administrators</h2>
   <p>You must have an account to start a new vote or to administer an
index 298b99a63276515661ad7839f782d3a995699539..2033ed18c838d6ff1182f07f96e4ce70d2e64153 100644 (file)
@@ -10,6 +10,8 @@ create table elections (
  startdate datetime, 
  enddate datetime NOT NULL, 
  active tinyint NOT NULL DEFAULT 0,
+ viewable tinyint NOT NULL DEFAULT 1,
+ notices tinyint NOT NULL DEFAULT 0,
  user_id int NULL,
  quickuser varchar(255) NULL, #stores session_id for quickvote creators
  election_method varchar(100) DEFAULT 'ssd',
index 57e39ac71a9e5a32490b72134fe9992cb5668dc1..4ea61b7973e5dc269191f16b03c1c4cdfbcba66a 100644 (file)
@@ -5,9 +5,12 @@
 ActiveRecord::Schema.define() do
 
   create_table "candidates", :force => true do |t|
-    t.column "election_id", :integer,                                :null => false
-    t.column "name",        :string,  :limit => 100, :default => "", :null => false
-    t.column "description", :text
+    t.column "election_id",      :integer,                                :null => false
+    t.column "name",             :string,  :limit => 100, :default => "", :null => false
+    t.column "description",      :text
+    t.column "picture_filename", :string,  :limit => 200
+    t.column "picture_data",     :binary
+    t.column "picture_type",     :string,  :limit => 100
   end
 
   create_table "elections", :force => true do |t|
@@ -17,6 +20,8 @@ ActiveRecord::Schema.define() do
     t.column "startdate",       :datetime
     t.column "enddate",         :datetime,                                   :null => false
     t.column "active",          :integer,  :limit => 4,   :default => 0,     :null => false
+    t.column "viewable",        :integer,  :limit => 4,   :default => 1,     :null => false
+    t.column "notices",         :integer,  :limit => 4,   :default => 0,     :null => false
     t.column "user_id",         :integer
     t.column "quickuser",       :string
     t.column "election_method", :string,   :limit => 100, :default => "ssd"
@@ -25,15 +30,6 @@ ActiveRecord::Schema.define() do
 
   add_index "elections", ["user_id"], :name => "fk_user_election"
 
-  create_table "pictures", :force => true do |t|
-    t.column "filename",     :string,  :limit => 200
-    t.column "data",         :binary
-    t.column "filetype",     :string,  :limit => 100
-    t.column "candidate_id", :integer
-  end
-
-  add_index "pictures", ["candidate_id"], :name => "fk_candidate_picture"
-
   create_table "rankings", :force => true do |t|
     t.column "vote_id",      :integer
     t.column "candidate_id", :integer

Benjamin Mako Hill || Want to submit a patch?