diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/track_controller.rb | 28 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 4 |
2 files changed, 29 insertions, 3 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 diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 5196096ef..a443d3e7d 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_controller.rb,v 1.61 2009-03-03 22:37:58 francis Exp $ +# $Id: user_controller.rb,v 1.62 2009-03-05 19:09:47 francis Exp $ class UserController < ApplicationController # Show page about a user @@ -46,7 +46,7 @@ class UserController < ApplicationController # All tracks for the user if @is_you @track_things = TrackThing.find(:all, :conditions => ["tracking_user_id = ? and track_medium = ?", @display_user.id, 'email_daily'], :order => 'created_at desc') - @track_things_grouped = @track_things.group_by(&:track_type_description) + @track_things_grouped = @track_things.group_by(&:track_type) end # Requests you need to describe |