From: Date: Thu, 23 Aug 2007 22:27:55 +0000 (-0400) Subject: Added a method, views, and corresponding route so that a user can track the X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/6fdb49ee0dfc76980bcefb18968d1e1c55c8149c?ds=inline Added a method, views, and corresponding route so that a user can track the quickvotes he has created by his session_id. Have yet to modify the cookies to stick around permanently. --- diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index e675638..c2ed055 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -10,11 +10,13 @@ class QuickvoteController < ApplicationController ############################################################# def create - if params[:quickvote] + if params[:quickvote] @quickvote = QuickVote.new(params[:quickvote]) # store the candidate grabbed through ajax and stored in flash @quickvote.candidate_names = flash[:candidate_names] @quickvote.description=@quickvote.description + #record who created the quickvote so that person can monitor it easily + @quickvote.quickuser = session.session_id # try to save, if it fails, show the page again (the flash should # still be intact if @quickvote.save @@ -181,6 +183,10 @@ class QuickvoteController < ApplicationController @election.candidates.each {|c| @candidates[c.id] = c} end + def my_quickvotes + @myqvs = QuickVote.find(:all, :conditions => ["quickuser = ?", + session.session_id]) + end end diff --git a/app/views/quickvote/my_quickvotes.rhtml b/app/views/quickvote/my_quickvotes.rhtml new file mode 100644 index 0000000..546cb24 --- /dev/null +++ b/app/views/quickvote/my_quickvotes.rhtml @@ -0,0 +1,19 @@ + + + <% ["Name", "Start Date", "End Date", "Description"].each do |column| %> + + <% end -%> + + + <% @myqvs.each do |quickvote| %> + + + + + +<% end %> +
<%= column %>
+ <%= link_to "#{quickvote.name}", + quickaction_url( :ident => quickvote.name, :action => 'results' ) %> + <%= quickvote.startdate.strftime("%x") %><%= quickvote.enddate.strftime("%x") %><%= quickvote.description %> +
\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 96beafd..735f5d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,7 +15,7 @@ ActionController::Routing::Routes.draw do |map| map.connect 'quickvote/:action/:id', :controller => 'quickvote', - :requirements => { :action => /(create|add_candidate|sort_candidates)/ } + :requirements => { :action => /(create|add_candidate|sort_candidates|my_quickvotes)/ } map.quickaction 'quickvote/:ident/:action', :controller => 'quickvote', diff --git a/db/create.sql b/db/create.sql index 7b3fef5..a5a2e0a 100644 --- a/db/create.sql +++ b/db/create.sql @@ -3,7 +3,7 @@ drop table if exists elections; create table elections ( - id int NOT NULL auto_increment, + id int NOT NULL auto_increment, name varchar(100) NOT NULL, description TEXT NOT NULL, anonymous tinyint NOT NULL DEFAULT 1, @@ -11,6 +11,7 @@ create table elections ( enddate datetime NOT NULL, active 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', `type` varchar(100) NOT NULL, primary key (id),