Added a method, views, and corresponding route so that a user can track the
author<jlsharps@mit.edu> <>
Thu, 23 Aug 2007 22:27:55 +0000 (18:27 -0400)
committer<jlsharps@mit.edu> <>
Thu, 23 Aug 2007 22:27:55 +0000 (18:27 -0400)
quickvotes he has created by his session_id. Have yet to modify the cookies to
stick around permanently.

app/controllers/quickvote_controller.rb
app/views/quickvote/my_quickvotes.rhtml [new file with mode: 0644]
config/routes.rb
db/create.sql

index e675638f2af35b619c967560fb32eae5fc3613fd..c2ed0559659e4995f7ccbb53aecd74aef41b81eb 100644 (file)
@@ -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 (file)
index 0000000..546cb24
--- /dev/null
@@ -0,0 +1,19 @@
+<table class="voterbox">
+  <tr>
+  <% ["Name", "Start Date", "End Date", "Description"].each do |column| %>
+       <th><%= column %></th>
+  <% end -%>
+  </tr>
+
+  <% @myqvs.each do |quickvote| %>
+  <tr>
+       <td>
+       <%= link_to "#{quickvote.name}",
+          quickaction_url( :ident => quickvote.name, :action => 'results' ) %>
+       </td>
+    <td><%= quickvote.startdate.strftime("%x") %></td>
+    <td><%= quickvote.enddate.strftime("%x") %></td>
+       <td><%= quickvote.description %>
+  </tr>
+<% end %>
+</table>       
\ No newline at end of file
index 96beafd4dde7af51ba160cde5e02fff5794c7dd0..735f5d7c92f2448bf9ba945c624652a0e0b6e67c 100644 (file)
@@ -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',
index 7b3fef5600b061a043c5c3972abe066aa75df79f..a5a2e0a0fb54b1458ae5e1abb8a8394fb0b454d1 100644 (file)
@@ -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),

Benjamin Mako Hill || Want to submit a patch?