diff options
author | francis <francis> | 2009-03-05 19:09:46 +0000 |
---|---|---|
committer | francis <francis> | 2009-03-05 19:09:46 +0000 |
commit | 1d0bb50fd3dac805456083e9f8fc0adf93bebf16 (patch) | |
tree | b914f72420e06d5f14472f320416ef08062fa413 | |
parent | 86e02361a2e4c40626b431e0340218baa2bd9b63 (diff) |
Button to delete all tracks of a particular type.
-rw-r--r-- | app/controllers/track_controller.rb | 28 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 4 | ||||
-rw-r--r-- | app/views/user/show.rhtml | 26 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | todo.txt | 6 |
5 files changed, 58 insertions, 9 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 diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml index 3055c85d1..1d0df2fe5 100644 --- a/app/views/user/show.rhtml +++ b/app/views/user/show.rhtml @@ -56,12 +56,29 @@ <% if @is_you and not @track_things.empty? %> <h2> Your <%=pluralize(@track_things.size, "email subscription") %> + <% if @track_things_grouped.size == 1 %> + <% form_tag :controller => 'track', :action => 'delete_all_type' do %> + <h3> + <%=TrackThing.track_type_description(@track_things[0].track_type)%> + <%= hidden_field_tag 'track_type', @track_things[0].track_type %> + <%= hidden_field_tag 'user', @display_user.id %> + <%= hidden_field_tag 'r', request.request_uri %> + <%= submit_tag "unsubscribe all" %> + </h3> + <% end %> + <% end %> </h2> - <% for track_type_description, track_things in @track_things_grouped %> + <% for track_type, track_things in @track_things_grouped %> <% if @track_things_grouped.size > 1 %> - <h3> - <%=track_type_description%> - </h3> + <% form_tag :controller => 'track', :action => 'delete_all_type' do %> + <h3> + <%=TrackThing.track_type_description(track_type)%> + <%= hidden_field_tag 'track_type', track_type %> + <%= hidden_field_tag 'user', @display_user.id %> + <%= hidden_field_tag 'r', request.request_uri %> + <%= submit_tag "unsubscribe all" %> + </h3> + <% end %> <% end %> <ul> @@ -75,7 +92,6 @@ <%= submit_tag "unsubscribe" %> </div> <% end %> - <!-- (<%= link_to "view latest updates", :controller => 'general', :action => 'search', :query => track_thing.track_query %>) --> </li> <% end %> </ul> diff --git a/config/routes.rb b/config/routes.rb index 5dec2afc4..763bc8b27 100644 --- a/config/routes.rb +++ b/config/routes.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: routes.rb,v 1.81 2009-01-29 12:28:45 francis Exp $ +# $Id: routes.rb,v 1.82 2009-03-05 19:09:47 francis Exp $ ActionController::Routing::Routes.draw do |map| @@ -79,6 +79,7 @@ ActionController::Routing::Routes.draw do |map| track.track_search "/:feed/search/*query_array", :action => 'track_search_query' , :feed => /(track|feed)/ track.update '/track/update/:track_id', :action => 'update' + track.delete_all_type '/track/delete_all_type', :action => 'delete_all_type' track.atom_feed '/track/feed/:track_id', :action => 'atom_feed' end @@ -69,6 +69,12 @@ Add option for "misdelivered to the wrong request" Later ===== +When it prompts error_message people to send annotation, maybe just show them +the email address of the error to check then and there? + +Graph on admin page is a bit knackered as doesn't cover all the statuses - I think +this means "waiting_response" is unnecessarily stretched out + Should really make replies munge subject of last response, rather than start afresh with subject - authorities use FOI code in subject as here: http://www.whatdotheyknow.com/request/causes_of_the_financial_crisis#incoming-12779 |