aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/request_controller.rb11
-rw-r--r--app/controllers/track_controller.rb4
-rw-r--r--app/models/track_thing.rb9
-rw-r--r--app/views/request/list.rhtml12
4 files changed, 21 insertions, 15 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 8a128ea30..7bf2deba0 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.80 2008-05-12 01:37:50 francis Exp $
+# $Id: request_controller.rb,v 1.81 2008-05-12 01:53:41 francis Exp $
class RequestController < ApplicationController
@@ -42,11 +42,7 @@ class RequestController < ApplicationController
# 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
+ @existing_track = TrackThing.find_by_existing_track(@user, @track_thing.track_query)
end
def list
@@ -56,6 +52,9 @@ class RequestController < ApplicationController
@title = "Recently sent Freedom of Information requests"
query = "variety:sent";
sortby = "newest"
+ # Already tracking?
+ @track_thing = TrackThing.create_track_for_all_new_requests()
+ @existing_track = TrackThing.find_by_existing_track(@user, @track_thing.track_query)
elsif @view == 'successful'
@title = "Recent successful responses"
query = 'variety:response (status:successful OR status:partially_successful)'
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index f1f9c1fd3..416b98e59 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.10 2008-05-12 01:37:50 francis Exp $
+# $Id: track_controller.rb,v 1.11 2008-05-12 01:53:41 francis Exp $
class TrackController < ApplicationController
@@ -41,7 +41,7 @@ class TrackController < ApplicationController
# 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)
+ @existing_track = TrackThing.find_by_existing_track(@user, @track_thing.track_query)
if @existing_track
return "already"
end
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index a66fc1b34..bf329b5dc 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -21,7 +21,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: track_thing.rb,v 1.12 2008-05-12 01:38:18 francis Exp $
+# $Id: track_thing.rb,v 1.13 2008-05-12 01:53:41 francis Exp $
class TrackThing < ActiveRecord::Base
belongs_to :tracking_user, :class_name => 'User'
@@ -101,8 +101,11 @@ class TrackThing < ActiveRecord::Base
end
# When constructing a new track, use this to avoid duplicates / double posting
- def TrackThing.find_by_existing_track(tracking_user_id, track_query)
- return TrackThing.find(:first, :conditions => [ 'tracking_user_id = ? and track_query = ?', tracking_user_id, track_query ] )
+ def TrackThing.find_by_existing_track(tracking_user, track_query)
+ if tracking_user.nil?
+ return nil
+ end
+ return TrackThing.find(:first, :conditions => [ 'tracking_user_id = ? and track_query = ?', tracking_user.id, track_query ] )
end
diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml
index 285a60b58..6688dedb1 100644
--- a/app/views/request/list.rhtml
+++ b/app/views/request/list.rhtml
@@ -1,5 +1,7 @@
-<% if @view.nil? %>
-<p><%= link_to "Track all new requests", track_new_requests_url() %>
+<% if @existing_track %>
+<p>You are already being told about any new requests (<%= link_to "alter your subscriptions", user_url(@user) %>).</p>
+<% elsif @view.nil? %>
+<p><%= link_to "Be told about any new requests", track_new_requests_url() %>
(by email or RSS feed <img src="/images/feed-14.png" alt="" class="rss">)
</p>
<% end %>
@@ -20,8 +22,10 @@
<%= will_paginate WillPaginate::Collection.new(@page, @per_page, @search_hits) %>
-<% if @view.nil? %>
-<p><%= link_to "Track all new requests", track_new_requests_url() %>
+<% if @existing_track %>
+<p>You are already being told about any new requests. (<%= link_to "alter your subscriptions", user_url(@user) %>).</p>
+<% elsif @view.nil? %>
+<p><%= link_to "Be told about any new requests", track_new_requests_url() %>
(by email or RSS feed <img src="/images/feed-14.png" alt="" class="rss">)
</p>
<% end %>