diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/request_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/track_controller.rb | 16 |
2 files changed, 21 insertions, 5 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 334edbbff..693352c91 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.70 2008-04-03 16:09:25 francis Exp $ +# $Id: request_controller.rb,v 1.71 2008-04-04 01:59:40 francis Exp $ class RequestController < ApplicationController @@ -30,6 +30,14 @@ class RequestController < ApplicationController @last_info_request_event_id = last_event.nil? ? nil : last_event.id @new_responses_count = @events_needing_description.select {|i| i.event_type == 'response'}.size + # Already tracking? + @track_thing = TrackThing.create_track_for_request(@info_request) + if @user + @existing_track = TrackThing.find_by_existing_track(@user.id, @track_thing.track_query) + else + @existing_track = nil + end + # Sidebar stuff @info_requests_same_user_same_body = InfoRequest.find(:all, :order => "created_at desc", :conditions => ["prominence = 'normal' and user_id = ? and public_body_id = ? and id <> ?", @info_request.user_id, @info_request.public_body_id, @info_request.id], diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 37283d0d9..eda7c60a2 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.2 2008-04-03 15:29:50 francis Exp $ +# $Id: track_controller.rb,v 1.3 2008-04-04 01:59:40 francis Exp $ class TrackController < ApplicationController @@ -13,14 +13,22 @@ class TrackController < ApplicationController def track_request @info_request = InfoRequest.find_by_url_title(params[:url_title]) @track_thing = TrackThing.create_track_for_request(@info_request) - if self.track_set - flash[:notice] = "You are now tracking this request!" + ret = self.track_set + if ret + flash[:notice] = "You are " + ret + " tracking this request!" redirect_to request_url(@info_request) end end # Generic request tracker - set @track_thing before calling def track_set + if @user + @existing_track = TrackThing.find_by_existing_track(@user.id, @track_thing.track_query) + if @existing_track + return "already" + end + end + @track_thing.track_medium = 'email_daily' @title = @track_thing.params[:title] @@ -40,7 +48,7 @@ class TrackController < ApplicationController @track_thing.tracking_user_id = @user.id @track_thing.save! - return true + return "now" end end |