aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/track_controller.rb27
-rw-r--r--app/views/user/show.rhtml17
-rw-r--r--config/routes.rb4
-rw-r--r--todo.txt2
4 files changed, 30 insertions, 20 deletions
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index f32963342..2a4ed9364 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.6 2008-04-09 02:56:47 francis Exp $
+# $Id: track_controller.rb,v 1.7 2008-04-18 01:57:43 francis Exp $
class TrackController < ApplicationController
@@ -64,7 +64,8 @@ class TrackController < ApplicationController
end
# Delete a track
- def delete
+# def delete
+ def update
track_thing = TrackThing.find(params[:track_id].to_i)
if not authenticated_as_user?(track_thing.tracking_user,
@@ -76,10 +77,24 @@ class TrackController < ApplicationController
return
end
- track_thing.destroy
-
- flash[:notice] = "Your alert has been cancelled."
- redirect_to user_url(track_thing.tracking_user)
+ new_medium = params[:track_thing][:track_medium]
+ if new_medium == 'delete'
+ track_thing.destroy
+ flash[:notice] = "You will no longer be updated about " + track_thing.params[:list_description]
+ redirect_to user_url(track_thing.tracking_user)
+ elsif new_medium == 'email_daily'
+ track_thing.track_medium = new_medium
+ track_thing.created_at = Time.now() # as created_at is used to limit the alerts to start with
+ track_thing.save!
+ flash[:notice] = "You will now be emailed when " + track_thing.params[:list_description] + ", is updated"
+ redirect_to user_url(track_thing.tracking_user)
+ elsif new_medium == 'feed'
+ track_thing.track_medium = new_medium
+ track_thing.save!
+ redirect_to :controller => 'track', :action => 'atom_feed', :track_id => track_thing.id
+ else
+ raise "unknown medium " + new_medium
+ end
end
end
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 402ccf251..ca4b3327a 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -30,17 +30,14 @@
<ul>
<% for track_thing in @display_user.track_things %>
<li>
- <% form_tag :controller => 'track', :action => 'delete', :track_id => track_thing.id do %>
- <%= track_thing.params[:list_description] %>,
- <% if track_thing.track_medium == 'email_daily' %>
- by email daily
- <% elsif track_thing.track_medium == 'feed' %>
- by <%= link_to "RSS feed", :controller => 'track', :action => 'atom_feed', :track_id => track_thing.id %>
- <% else %>
- <% raise "unknown track medium '" + track_thing.track_medium + "'" %>
- <% end %>
+ <% form_tag :controller => 'track', :action => 'update', :track_id => track_thing.id do %>
+ <%= track_thing.params[:list_description] %> by
+ <!-- <% if track_thing.track_medium == 'feed' %>
+ (<%= link_to "RSS feed", :controller => 'track', :action => 'atom_feed', :track_id => track_thing.id %>)
+ <% end %> -->
<!-- (<%= link_to "view latest updates", :controller => 'general', :action => 'search', :query => track_thing.track_query %>) -->
- <%= submit_tag "Delete" %>
+ <%= select 'track_thing', "track_medium", { "Email daily" => "email_daily", "RSS feed" => "feed", "Cancel updates" => "delete"}, { :selected => track_thing.track_medium } %>
+ <%= submit_tag "Update" %>
<% end %>
</li>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index f46e4f8d8..07ba151e5 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.54 2008-04-16 13:23:55 francis Exp $
+# $Id: routes.rb,v 1.55 2008-04-18 01:57:43 francis Exp $
ActionController::Routing::Routes.draw do |map|
@@ -57,7 +57,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'
+ track.update 'track/update/:track_id', :action => 'update'
track.atom_feed 'track/feed/:track_id', :action => 'atom_feed'
end
diff --git a/todo.txt b/todo.txt
index e03f38952..d8cda211b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -28,8 +28,6 @@ BAILII - relationship with law courts, robots.txt ?
Next
====
-Let you change feeds from email to RSS
-
"Some other requests..." should have "more" link now
Things to track: