aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-04-04 03:02:02 +0000
committerfrancis <francis>2008-04-04 03:02:02 +0000
commite0b7b3a59b0048829f9d2212a07517872ab62dbd (patch)
tree558b7f5db8d642dc2fc3e63a8880a46957f7c7a6
parent71f328b5bf24ddaf8b6725001f18d5b62213871d (diff)
Option to delete tracks.
-rw-r--r--app/controllers/track_controller.rb21
-rw-r--r--app/views/request/show.rhtml3
-rw-r--r--app/views/user/show.rhtml10
-rw-r--r--config/routes.rb3
-rw-r--r--todo.txt9
5 files changed, 30 insertions, 16 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index eda7c60a2..0ea3376f5 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.3 2008-04-04 01:59:40 francis Exp $
+# $Id: track_controller.rb,v 1.4 2008-04-04 03:02:02 francis Exp $
class TrackController < ApplicationController
@@ -51,5 +51,24 @@ class TrackController < ApplicationController
return "now"
end
+ # Delete a track
+ def delete
+ track_thing = TrackThing.find(params[:track_id].to_i)
+
+ if not authenticated_as_user?(track_thing.tracking_user,
+ :web => "To cancel this alert",
+ :email => "Then you can cancel the alert.",
+ :email_subject => "Cancel a WhatDoTheyKnow alert"
+ )
+ # do nothing - as "authenticated?" has done the redirect to signin page for us
+ return
+ end
+
+ track_thing.destroy
+
+ flash[:notice] = "Your alert has been cancelled."
+ redirect_to user_url(track_thing.tracking_user)
+ end
+
end
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index e3471a75a..ff3330362 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -75,7 +75,8 @@
</ul>
<p>
<% if @existing_track %>
- You are already tracking this request.
+ You are already tracking this request
+ (<%= link_to "alter your subscriptions", user_url(@user) %>).
<% else %>
<%= link_to "Track updates to this request", track_request_url(:url_title => @info_request.url_title) %>
(by email or RSS)
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 1eebaed57..b80ab35f5 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -29,10 +29,12 @@
<ul>
<% for track_thing in @display_user.track_things %>
- <li><%= track_thing.params[:list_description] %>
- <!--
- (<%= link_to "view latest updates", :controller => 'general', :action => 'search', :query => track_thing.track_query %>)
- -->
+ <li>
+ <% form_tag :controller => 'track', :action => 'delete', :track_id => track_thing.id do %>
+ <%= track_thing.params[:list_description] %>
+ <!-- (<%= link_to "view latest updates", :controller => 'general', :action => 'search', :query => track_thing.track_query %>) -->
+ <%= submit_tag "Delete" %>
+ <% end %>
</li>
<% end %>
</ul>
diff --git a/config/routes.rb b/config/routes.rb
index 8b9288ea3..26967bc8b 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.50 2008-04-03 15:42:57 francis Exp $
+# $Id: routes.rb,v 1.51 2008-04-04 03:02:03 francis Exp $
ActionController::Routing::Routes.draw do |map|
@@ -55,6 +55,7 @@ ActionController::Routing::Routes.draw do |map|
map.with_options :controller => 'track' do |track|
track.track_request 'track/request/:url_title', :action => 'track_request'
+ track.delete 'track/delete/:track_id', :action => 'delete'
end
map.with_options :controller => 'help' do |help|
diff --git a/todo.txt b/todo.txt
index e2f73ee64..2583ba703 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,12 +1,3 @@
-Alerts:
-
-Add unsubscribe / manage tracks page.
- Link from email
- Link from user page
- Link from "already tracking" text
-
-Improve "you are now tracking this request!" flash
-
FOI requests to use to test it
==============================