diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/comment_controller.rb | 20 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index fe2b31daf..94abfe142 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: comment_controller.rb,v 1.3 2008-08-26 22:54:45 francis Exp $ +# $Id: comment_controller.rb,v 1.4 2008-08-29 11:57:57 francis Exp $ class CommentController < ApplicationController @@ -43,7 +43,23 @@ class CommentController < ApplicationController # This automatically saves dependent objects in the same transaction @info_request.save! flash[:notice] = "Thank you for making an annotation!" - redirect_to comment_url(@comment) + + # Also subscribe to track for this request, so they get updates + if params[:subscribe_to_request] + @track_thing = TrackThing.create_track_for_request(@info_request) + @existing_track = TrackThing.find_by_existing_track(@user, @track_thing) + if not @existing_track + @track_thing.track_medium = 'email_daily' + @track_thing.tracking_user_id = @user.id + @track_thing.save! + flash[:notice] += " You will also be emailed updates about the request." + else + flash[:notice] += " You are already being emailed updates about the request." + end + end + + # we don't use comment_url here, as then you don't see the flash at top of page + redirect_to request_url(@info_request) else # do nothing - as "authenticated?" has done the redirect to signin page for us end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 41c48dee3..e1df1287a 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_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: request_controller.rb,v 1.96 2008-08-27 00:39:03 francis Exp $ +# $Id: request_controller.rb,v 1.97 2008-08-29 11:57:57 francis Exp $ class RequestController < ApplicationController @@ -39,6 +39,9 @@ class RequestController < ApplicationController # Track corresponding to this page @track_thing = TrackThing.create_track_for_request(@info_request) @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ] + + # Default to subscribing to requests + params[:subscribe_to_request] = true end # Requests similar to this one |