aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/track_controller.rb
diff options
context:
space:
mode:
authorfrancis <francis>2009-03-05 19:09:46 +0000
committerfrancis <francis>2009-03-05 19:09:46 +0000
commit1d0bb50fd3dac805456083e9f8fc0adf93bebf16 (patch)
treeb914f72420e06d5f14472f320416ef08062fa413 /app/controllers/track_controller.rb
parent86e02361a2e4c40626b431e0340218baa2bd9b63 (diff)
Button to delete all tracks of a particular type.
Diffstat (limited to 'app/controllers/track_controller.rb')
-rw-r--r--app/controllers/track_controller.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 229229fff..635f9401a 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -5,7 +5,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: track_controller.rb,v 1.27 2008-09-11 09:36:10 francis Exp $
+# $Id: track_controller.rb,v 1.28 2009-03-05 19:09:47 francis Exp $
class TrackController < ApplicationController
@@ -146,5 +146,31 @@ class TrackController < ApplicationController
end
end
+ # Remove all tracks of a certain type (e.g. requests / users / bodies)
+ def delete_all_type
+ user_id = User.find(params[:user].to_i)
+
+ if not authenticated_as_user?(user_id,
+ :web => "To cancel these alerts",
+ :email => "Then you can cancel the alerts.",
+ :email_subject => "Cancel some WhatDoTheyKnow alerts"
+ )
+ # do nothing - as "authenticated?" has done the redirect to signin page for us
+ return
+ end
+
+ track_type = params[:track_type]
+
+ flash[:notice] = "<p>You will no longer be emailed updates about:</p> <ul>"
+ for track_thing in TrackThing.find(:all, :conditions => [ "track_type = ? and tracking_user_id = ?", track_type, user_id ])
+ flash[:notice] += "<li>" + track_thing.params[:list_description] + " </li>"
+ track_thing.destroy
+ end
+ flash[:notice] += "</ul>"
+
+ redirect_to params[:r]
+ end
+
+
end