aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb1
-rw-r--r--app/controllers/track_controller.rb26
-rw-r--r--app/helpers/link_to_helper.rb2
-rw-r--r--config/routes.rb7
-rw-r--r--todo.txt1
5 files changed, 34 insertions, 3 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 167667725..e69059f6c 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -91,6 +91,7 @@ class RequestController < ApplicationController
# handle_rejected_responses
:info_request_events => @info_request_events.map { |e| {
+ # XXX this code is partly duplicated with the track controller
:id => e.id,
:event_type => e.event_type,
# params_yaml has possibly sensitive data in it, don't include it
diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb
index 863477c0a..ff17eb25f 100644
--- a/app/controllers/track_controller.rb
+++ b/app/controllers/track_controller.rb
@@ -25,7 +25,7 @@ class TrackController < ApplicationController
def track_list
@view = params[:view]
- if @view.nil?
+ if @view == 'recent' || @view.nil? # the blank one for backwards compatibility
@track_thing = TrackThing.create_track_for_all_new_requests
elsif @view == 'successful'
@track_thing = TrackThing.create_track_for_all_successful_requests
@@ -118,7 +118,29 @@ class TrackController < ApplicationController
@xapian_object = perform_search([InfoRequestEvent], @track_thing.track_query, @track_thing.params[:feed_sortby], nil, 25, 1)
respond_to do |format|
format.atom { render :template => 'track/atom_feed' }
- end
+ format.json {
+ render :json =>
+ @xapian_object.results.map { |r| {
+ # XXX this code is partly duplicated with the request controller
+ :id => r[:model].id,
+ :event_type => r[:model].event_type,
+ :info_request => r[:model].info_request.url_title,
+ :public_body => r[:model].info_request.public_body.url_name,
+ :user => r[:model].info_request.user.url_name,
+ # params_yaml has possibly sensitive data in it, don't include it
+ :created_at => r[:model].created_at,
+ :described_state => r[:model].described_state,
+ :calculated_state => r[:model].calculated_state,
+ :last_described_at => r[:model].last_described_at,
+ :incoming_message_id => r[:model].incoming_message_id,
+ :outgoing_message_id => r[:model].outgoing_message_id,
+ :comment_id => r[:model].comment_id,
+ # XXX would be nice to add links here, but alas the
+ # code to make them is in views only. See views/request/details.rhtml
+ }
+ }
+ }
+ end
end
# Change or delete a track
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 2ba4649ba..93151ecfe 100644
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -121,7 +121,7 @@ module LinkToHelper
if track_thing.track_type == 'request_updates'
track_request_url(:url_title => track_thing.info_request.url_title, :feed => feed)
elsif track_thing.track_type == 'all_new_requests'
- track_list_url(:view => nil, :feed => feed)
+ track_list_url(:view => 'recent', :feed => feed)
elsif track_thing.track_type == 'all_successful_requests'
track_list_url(:view => 'successful', :feed => feed)
elsif track_thing.track_type == 'public_body_updates'
diff --git a/config/routes.rb b/config/routes.rb
index 162d5c4ab..e265699aa 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -93,6 +93,13 @@ ActionController::Routing::Routes.draw do |map|
end
map.with_options :controller => 'track' do |track|
+ track.track_request '/:feed/request/:url_title.:format', :action => 'track_request', :feed => /(track|feed)/
+ track.track_list '/:feed/list/:view.:format', :action => 'track_list', :view => nil, :feed => /(track|feed)/
+ track.track_public_body "/:feed/body/:url_name.:format", :action => 'track_public_body', :feed => /(track|feed)/
+ track.track_user "/:feed/user/:url_name.:format", :action => 'track_user', :feed => /(track|feed)/
+ # XXX must be better way of getting dots and slashes in search queries to work than this *query_array
+ track.track_search "/:feed/search/*query_array.:format", :action => 'track_search_query' , :feed => /(track|feed)/
+
# /track/ is for setting up an email alert for the item
# /feed/ is a direct RSS feed of the item
track.track_request '/:feed/request/:url_title', :action => 'track_request', :feed => /(track|feed)/
diff --git a/todo.txt b/todo.txt
index 2c4d76269..e056048df 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,3 +1,4 @@
+Convert user just to a full user json thing each time?
Tag search