From 3e545735b4784af19edec9bfcc8e25ff17cb7f12 Mon Sep 17 00:00:00 2001 From: Date: Fri, 24 Aug 2007 20:59:18 -0400 Subject: [PATCH] Allowed for the results page of quickvotes to be hidden while the quickvote is go 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 | 3 +++ app/views/layouts/main.rhtml | 5 +---- app/views/quickvote/_advanced.rhtml | 10 ++++++++++ app/views/quickvote/my_quickvotes.rhtml | 13 +++++++++---- app/views/quickvote/not_viewable.rhtml | 3 +++ app/views/site/index.rhtml | 2 +- db/create.sql | 2 ++ db/schema.rb | 20 ++++++++------------ 8 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 app/views/quickvote/not_viewable.rhtml diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index c2ed055..7ad1722 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -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} diff --git a/app/views/layouts/main.rhtml b/app/views/layouts/main.rhtml index 0b9d5cb..027ef14 100644 --- a/app/views/layouts/main.rhtml +++ b/app/views/layouts/main.rhtml @@ -19,14 +19,11 @@ diff --git a/app/views/quickvote/_advanced.rhtml b/app/views/quickvote/_advanced.rhtml index 3037ccc..0255fbd 100644 --- a/app/views/quickvote/_advanced.rhtml +++ b/app/views/quickvote/_advanced.rhtml @@ -8,4 +8,14 @@
<%= quickform.date_select(:enddate, :start_year => Time.now.year) %>
+

Want the results to be visible while the election is active? +Yes <%= quickform.radio_button(:viewable, 1)%> +No <%= quickform.radio_button(:viewable, 0)%>

+ +<% if session[:user] %> +

Would you like to be e-mailed when this QuickVote concludes? +Yes <%= quickform.radio_button(:notices, 1)%> +No <%= quickform.radio_button(:notices, 0)%>

+<% end -%> + <% end %> diff --git a/app/views/quickvote/my_quickvotes.rhtml b/app/views/quickvote/my_quickvotes.rhtml index a512c7f..a920480 100644 --- a/app/views/quickvote/my_quickvotes.rhtml +++ b/app/views/quickvote/my_quickvotes.rhtml @@ -7,13 +7,18 @@ <% @myqvs.each do |quickvote| %> - - <%= link_to "#{quickvote.name}", - quickaction_url( :ident => quickvote.name, :action => 'results' ) %> + + <% if quickvote.active == 1 %> + <%= link_to "#{quickvote.name}", + quickaction_url( :ident => quickvote.name, + :action => 'results' ) %> + <% else %> + <%= quickvote.name %> + <% end %> <%= quickvote.startdate.strftime("%x") %> <%= quickvote.enddate.strftime("%x") %> - <%= quickvote.description %> + <%= quickvote.description %> <% end %> diff --git a/app/views/quickvote/not_viewable.rhtml b/app/views/quickvote/not_viewable.rhtml new file mode 100644 index 0000000..3c5532e --- /dev/null +++ b/app/views/quickvote/not_viewable.rhtml @@ -0,0 +1,3 @@ +

Sorry, the creator of this QuickVote has decided this election shouldn't + be visible while the QuickVote is running.

+<%= link_to "Selectricity Home", :controller => 'site' %> \ No newline at end of file diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index 0c44218..9b0b1fe 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -53,7 +53,7 @@ ongoing election, you can log in to vote using your token here.

<%= link_to 'Lost or forgot your token?', :controller => 'voter', :action => 'forgot_password' %>

<% if session[:user] %> - <%= render_partial 'user_summary' %> + <%= render :partial => 'user_summary' %> <% else %>

Vote Administrators

You must have an account to start a new vote or to administer an diff --git a/db/create.sql b/db/create.sql index 298b99a..2033ed1 100644 --- a/db/create.sql +++ b/db/create.sql @@ -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', diff --git a/db/schema.rb b/db/schema.rb index 57e39ac..4ea61b7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 -- 2.30.2