aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb10
-rw-r--r--app/controllers/track_controller.rb16
-rw-r--r--app/models/track_thing.rb8
-rw-r--r--app/views/request/show.rhtml10
-rw-r--r--app/views/track/track_set.rhtml4
-rw-r--r--todo.txt9
6 files changed, 40 insertions, 17 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
diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb
index 84f29fa80..c71dd6f4c 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.5 2008-04-04 01:44:41 francis Exp $
+# $Id: track_thing.rb,v 1.6 2008-04-04 01:59:40 francis Exp $
class TrackThing < ActiveRecord::Base
belongs_to :user, :foreign_key => 'tracking_user_id'
@@ -75,6 +75,12 @@ class TrackThing < ActiveRecord::Base
return @params
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 ] )
+ end
+
+
end
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index eecf0bcdf..7c6a020a8 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -66,10 +66,14 @@
</div>
<div id="request_sidebar">
- <h2>Actions</h2>
+ <h2>Follow this request</h2>
<p>
- <%= link_to "Track updates to this request", track_request_url(:url_title => @info_request.url_title) %>
- (by email or RSS)
+ <% if @existing_track %>
+ You are already tracking this request.
+ <% else %>
+ <%= link_to "Track updates to this request", track_request_url(:url_title => @info_request.url_title) %>
+ (by email or RSS)
+ <% end %>
</p>
<% if @info_requests_same_user_same_body.size > 0 %>
diff --git a/app/views/track/track_set.rhtml b/app/views/track/track_set.rhtml
index 7f89e98db..47e4f59a1 100644
--- a/app/views/track/track_set.rhtml
+++ b/app/views/track/track_set.rhtml
@@ -21,8 +21,8 @@
</div>
<p class="form_note">
- <strong>Privacy note:</strong> It will appear publically on your user page that
- you are tracking this request (<a href="/help/about/#tracking">details</a>).
+ <strong>Lack of privacy note:</strong> It will appear publically on your user page that
+ you are tracking this request (<a href="/help/about/#tracking">why?</a>).
</p>
<div class="form_button">
diff --git a/todo.txt b/todo.txt
index 4cd374aff..12644db40 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,16 +1,13 @@
Alerts:
Add unsubscribe / manage tracks page.
+ Link from email
+ Link from user page
+ Link from "already tracking" text
Show on request who is tracking it
-Add you are already tracking this request error
-And show that you already tracking if you are logged in and on the request page
-
Improve "you are now tracking this request!" flash
-Add unique indices, to stop duplicate tracks
-And to stop duplicate sent email things
-
FOI requests to use to test it
==============================