diff options
-rw-r--r-- | app/controllers/request_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/track_controller.rb | 16 | ||||
-rw-r--r-- | app/models/track_thing.rb | 27 | ||||
-rw-r--r-- | app/views/request/list.rhtml | 12 | ||||
-rw-r--r-- | app/views/track/track_set.rhtml | 2 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | todo.txt | 13 |
7 files changed, 69 insertions, 14 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 1879482a3..8a128ea30 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.79 2008-05-12 00:56:21 francis Exp $ +# $Id: request_controller.rb,v 1.80 2008-05-12 01:37:50 francis Exp $ class RequestController < ApplicationController @@ -50,18 +50,18 @@ class RequestController < ApplicationController end def list - view = params[:view] + @view = params[:view] - if view.nil? + if @view.nil? @title = "Recently sent Freedom of Information requests" query = "variety:sent"; sortby = "newest" - elsif view == 'successful' + elsif @view == 'successful' @title = "Recent successful responses" query = 'variety:response (status:successful OR status:partially_successful)' sortby = "newest" else - raise "unknown request list view " + view.to_s + raise "unknown request list view " + @view.to_s end perform_search(query, sortby, 'request_collapse') end diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 43264be67..f1f9c1fd3 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.9 2008-04-30 00:46:00 francis Exp $ +# $Id: track_controller.rb,v 1.10 2008-05-12 01:37:50 francis Exp $ class TrackController < ApplicationController @@ -24,6 +24,20 @@ class TrackController < ApplicationController end end + # Track all new requests + def track_new_requests + @track_thing = TrackThing.create_track_for_all_new_requests + 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 + " being told about any new requests!" + redirect_to request_list_url(:view => nil) + end + end + end + # Generic request tracker - set @track_thing before calling def track_set if @user diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 8b45d6a3a..86a301aee 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.10 2008-04-21 16:44:06 francis Exp $ +# $Id: track_thing.rb,v 1.11 2008-05-12 01:37:50 francis Exp $ class TrackThing < ActiveRecord::Base belongs_to :tracking_user, :class_name => 'User' @@ -36,6 +36,7 @@ class TrackThing < ActiveRecord::Base validates_inclusion_of :track_type, :in => [ 'request_updates', + 'all_new_requests', ] validates_inclusion_of :track_medium, :in => [ @@ -51,6 +52,13 @@ class TrackThing < ActiveRecord::Base return track_thing end + def TrackThing.create_track_for_all_new_requests() + track_thing = TrackThing.new + track_thing.track_type = 'all_new_requests' + track_thing.track_query = "variety:sent" + return track_thing + end + # Return hash of text parameters describing the request etc. include LinkToHelper def params @@ -70,7 +78,22 @@ class TrackThing < ActiveRecord::Base # Other :feed_sortby => 'described', # for RSS, as newest would give a date for responses possibly days before description } - else + elsif self.track_type == 'all_new_requests' + @params = { + # Website + :set_title => "How would you like to be told about any new requests?", + :list_description => "any <a href=\"/list\">new requests</a>", + # Email + :title_in_email => "New Freedom of Information requests", + :title_in_rss => "New Freedom of Information requests", + # Authentication + :web => "To be told about any new requets", + :email => "Then you will be emailed whenever anyone makes a new FOI request", + :email_subject => "Confirm you want to be emailed about new requests", + # Other + :feed_sortby => 'described', # for RSS, as newest would give a date for responses possibly days before description + } + else raise "unknown tracking type " + self.track_type end end diff --git a/app/views/request/list.rhtml b/app/views/request/list.rhtml index 3b024b764..285a60b58 100644 --- a/app/views/request/list.rhtml +++ b/app/views/request/list.rhtml @@ -1,3 +1,9 @@ +<% if @view.nil? %> +<p><%= link_to "Track all new requests", track_new_requests_url() %> +(by email or RSS feed <img src="/images/feed-14.png" alt="" class="rss">) +</p> +<% end %> + <h1><%=@title%></h1> <% if @search_results.empty? %> @@ -14,3 +20,9 @@ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @search_hits) %> +<% if @view.nil? %> +<p><%= link_to "Track all new requests", track_new_requests_url() %> +(by email or RSS feed <img src="/images/feed-14.png" alt="" class="rss">) +</p> +<% end %> + diff --git a/app/views/track/track_set.rhtml b/app/views/track/track_set.rhtml index 9fc299841..452938c12 100644 --- a/app/views/track/track_set.rhtml +++ b/app/views/track/track_set.rhtml @@ -20,7 +20,7 @@ <p class="form_note"> <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>). + you are tracking this (<a href="/help/about/#tracking">why?</a>). </p> <div class="form_button"> diff --git a/config/routes.rb b/config/routes.rb index 083accc9e..0b26ce530 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.57 2008-04-30 00:57:20 francis Exp $ +# $Id: routes.rb,v 1.58 2008-05-12 01:37:50 francis Exp $ ActionController::Routing::Routes.draw do |map| @@ -61,6 +61,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_new_requests 'track/new_requests', :action => 'track_new_requests' track.update 'track/update/:track_id', :action => 'update' track.atom_feed 'track/feed/:track_id', :action => 'atom_feed' end @@ -1,3 +1,6 @@ + +create_track_for_request + FOI requests to use to test it ============================== @@ -33,15 +36,17 @@ Next Things to track - don't ever return users / public bodies for now! - new requests - - new requests with keyword + - anything requesty with keyword - successful responses - -Editing status in admin interface isn't putting it in info request events - Do search for cases where current value doens't corespond to last event value + - requests for a particular public body + - requests by a particular user Later ===== +Check this again after a while, for dodgy states of events: +s = InfoRequest.find(:all).select { |i| (not i.awaiting_description) and i.get_last_response_event_id and InfoRequestEvent.find(i.get_last_response_event_id).calculated_state != i.described_state }; s.size + Museum aliases Highlight text search finds in word docs |