diff options
-rw-r--r-- | app/controllers/body_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/track_controller.rb | 20 | ||||
-rw-r--r-- | app/helpers/link_to_helper.rb | 4 | ||||
-rw-r--r-- | app/models/track_thing.rb | 32 | ||||
-rw-r--r-- | app/views/body/show.rhtml | 6 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | todo.txt | 5 |
7 files changed, 64 insertions, 10 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb index 3441a8db5..866cfa8aa 100644 --- a/app/controllers/body_controller.rb +++ b/app/controllers/body_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: body_controller.rb,v 1.11 2008-03-28 15:09:47 francis Exp $ +# $Id: body_controller.rb,v 1.12 2008-05-12 10:21:34 francis Exp $ class BodyController < ApplicationController # XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL @@ -32,6 +32,8 @@ class BodyController < ApplicationController redirect_to show_public_body_url(:url_name => @public_bodies[0].url_name) end @public_body = @public_bodies[0] + + @track_thing = TrackThing.create_track_for_public_body(@public_body) end def list diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 7b6244bc6..970b2a52a 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.13 2008-05-12 09:18:45 francis Exp $ +# $Id: track_controller.rb,v 1.14 2008-05-12 10:21:34 francis Exp $ class TrackController < ApplicationController @@ -24,7 +24,7 @@ class TrackController < ApplicationController end end - # Track all new requests + # Track all new/successful requests def track_list @view = params[:view] @@ -53,6 +53,22 @@ class TrackController < ApplicationController end end + # Track all updates to a particular public body + def track_public_body + @public_body = PublicBody.find_by_url_name(params[:url_name]) + @track_thing = TrackThing.create_track_for_public_body(@public_body) + ret = self.track_set + if ret + if @track_thing.track_medium == 'feed' + redirect_to :controller => 'track', :action => 'atom_feed', :track_id => @track_thing.id + else + flash[:notice] = "You are " + ret + " tracking this public body!" + redirect_to public_body_url(@public_body) + end + end + end + + # Generic request tracker - set @track_thing before calling def track_set if @user diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index e3e88d8ee..8a36121e8 100644 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -5,7 +5,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: link_to_helper.rb,v 1.28 2008-05-12 09:18:45 francis Exp $ +# $Id: link_to_helper.rb,v 1.29 2008-05-12 10:21:35 francis Exp $ module LinkToHelper @@ -89,6 +89,8 @@ module LinkToHelper track_list_url(:view => nil) elsif track_thing.track_type == 'all_successful_requests' track_list_url(:view => 'successful') + elsif track_thing.track_type == 'public_body_updates' + track_public_body_url(:url_name => track_thing.public_body.url_name) else raise "unknown tracking type " + track_thing.track_type end diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 2039912d7..d074cea03 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.15 2008-05-12 09:18:45 francis Exp $ +# $Id: track_thing.rb,v 1.16 2008-05-12 10:21:35 francis Exp $ class TrackThing < ActiveRecord::Base belongs_to :tracking_user, :class_name => 'User' @@ -38,6 +38,7 @@ class TrackThing < ActiveRecord::Base 'request_updates', 'all_new_requests', 'all_successful_requests', + 'public_body_updates', ] validates_inclusion_of :track_medium, :in => [ @@ -67,6 +68,14 @@ class TrackThing < ActiveRecord::Base return track_thing end + def TrackThing.create_track_for_public_body(public_body) + track_thing = TrackThing.new + track_thing.track_type = 'public_body_updates' + track_thing.public_body = public_body + track_thing.track_query = "variety:sent requested_from:" + public_body.url_name + return track_thing + end + # Return hash of text parameters describing the request etc. include LinkToHelper def params @@ -120,9 +129,26 @@ class TrackThing < ActiveRecord::Base :email => "Then you will be emailed whenever an FOI request succeeds", :email_subject => "Confirm you want to be emailed when an FOI request succeeds", # Other - :feed_sortby => 'described', # for RSS, as successfulest would give a date for responses possibly days before description + :feed_sortby => 'described', # for RSS, as newest would give a date for responses possibly days before description + } + elsif self.track_type == 'public_body_updates' + @params = { + # Website + :set_title => "How would you like to be told about new requests to the public authority '" + CGI.escapeHTML(self.public_body.name) + "'?", + :list_description => "'<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>', a public authority", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :verb_on_page => "Be told about new requests to this public authority", + :verb_on_page_already => "being told about new requests to this public authority", + # Email + :title_in_email => "New FOI requests to '" + self.public_body.name + "'", + :title_in_rss => "New FOI requests to '" + self.public_body.name + "'", + # Authentication + :web => "To be told about new requests to the public authority '" + CGI.escapeHTML(self.public_body.name) + "'", + :email => "Then you will be emailed whenever someone requests something from '" + CGI.escapeHTML(self.public_body.name) + "'.", + :email_subject => "Confirm you want to be told about new requests to '" + CGI.escapeHTML(self.public_body.name) + "'", + # Other + :feed_sortby => 'described', # for RSS, as newest would give a date for responses possibly days before description } - else + else raise "unknown tracking type " + self.track_type end end diff --git a/app/views/body/show.rhtml b/app/views/body/show.rhtml index 66b8a8555..e1fa095b6 100644 --- a/app/views/body/show.rhtml +++ b/app/views/body/show.rhtml @@ -1,4 +1,10 @@ <% @title = "Information freed from '" + h(@public_body.name) + "'" %> + +<div id="request_sidebar"> + <h2>People tracking this authority</h2> + <%= render :partial => 'track/tracking_people_and_link', :locals => { :track_thing => @track_thing } %> +</div> + <h1><%=h(@public_body.name)%></h1> <p class="subtitle"> diff --git a/config/routes.rb b/config/routes.rb index d3c60f684..66548275c 100644 --- a/config/routes.rb +++ b/config/routes.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: routes.rb,v 1.59 2008-05-12 09:18:46 francis Exp $ +# $Id: routes.rb,v 1.60 2008-05-12 10:21:35 francis Exp $ ActionController::Routing::Routes.draw do |map| @@ -62,6 +62,7 @@ ActionController::Routing::Routes.draw do |map| map.with_options :controller => 'track' do |track| track.track_request 'track/request/:url_title', :action => 'track_request' track.track_list '/track/list/:view', :action => 'track_list', :view => nil + track.track_public_body "/track/body/:url_name", :action => 'track_public_body' track.update '/track/update/:track_id', :action => 'update' track.atom_feed '/track/feed/:track_id', :action => 'atom_feed' @@ -36,9 +36,10 @@ Next Things to track - don't ever return users / public bodies for now! - anything requesty with keyword - - requests for a particular public body - requests by a particular user +Link to /list/successful from /list + Later ===== @@ -48,7 +49,7 @@ s = InfoRequest.find(:all).select { |i| (not i.awaiting_description) and i.get_l Museum aliases Highlight text search finds in word docs -Edits to outgoing/incoming/title won't be reindexed in Xapian +Edits to outgoing/incoming/title won't be reindexed in Xapian (maybe just reindex all once a week) Make the "needs admin attention" have a text box asking why |