aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/track_controller.rb27
-rw-r--r--app/views/user/show.rhtml17
2 files changed, 28 insertions, 16 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 %>