From 284808d259b3ba8ba1e6c106d949fffeb110a5a7 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 24 Aug 2011 11:50:10 +0100 Subject: First stab at filtering on the "View requests" page --- app/controllers/request_controller.rb | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index c1a13273a..731348fbf 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -129,25 +129,12 @@ class RequestController < ApplicationController def list medium_cache @view = params[:view] - - if @view.nil? - redirect_to request_list_url(:view => 'successful') - return - end - - if @view == 'recent' - @title = _("Recently sent Freedom of Information requests") - query = "variety:sent"; - sortby = "newest" - @track_thing = TrackThing.create_track_for_all_new_requests - elsif @view == 'successful' - @title = _("Recently successful responses") - query = 'variety:response (status:successful OR status:partially_successful)' - sortby = "described" - @track_thing = TrackThing.create_track_for_all_successful_requests - else - raise "unknown request list view " + @view.to_s + if !@view.nil? + params[:request_status] = @view end + params[:request_status] = "recent" if params[:query].nil? && params[:request_status].nil? + query, sortby = alter_query_from_params(params[:query]) + @title = "Some title" @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect behavior_cache :tag => [@view, @page] do @@ -158,7 +145,8 @@ class RequestController < ApplicationController @title = @title + " (page " + @page.to_s + ")" if (@page > 1) - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + # XXX need to reinstate the following; @track_thing had previously been set to "TrackThing.create_track_for_all_new_requests" and "TrackThing.create_track_for_all_successful_requests" + # @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] # Don't let robots go more than 20 pages in if @page > 20 -- cgit v1.2.3 From 45fc8c3e18dc5e43e98fc1fae5b519f1440086ea Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Wed, 24 Aug 2011 16:48:55 +0100 Subject: more work in progress on search forms --- app/controllers/request_controller.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 731348fbf..bb91cc854 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -129,12 +129,9 @@ class RequestController < ApplicationController def list medium_cache @view = params[:view] - if !@view.nil? - params[:request_status] = @view - end params[:request_status] = "recent" if params[:query].nil? && params[:request_status].nil? - query, sortby = alter_query_from_params(params[:query]) - @title = "Some title" + query, sortby = alter_query_from_params + @title = "View and search requests" @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect behavior_cache :tag => [@view, @page] do -- cgit v1.2.3 From 5f0c0d59ded4301efa085c4103b84a42a9fa61f6 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Fri, 26 Aug 2011 09:48:01 +0100 Subject: Further work in progress on better search functionality --- app/controllers/request_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index bb91cc854..3c283baae 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -129,10 +129,10 @@ class RequestController < ApplicationController def list medium_cache @view = params[:view] - params[:request_status] = "recent" if params[:query].nil? && params[:request_status].nil? - query, sortby = alter_query_from_params + params[:latest_status] = @view + query = make_query_from_params @title = "View and search requests" - + sortby = "newest" @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect behavior_cache :tag => [@view, @page] do xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') -- cgit v1.2.3 From b41edc7ae069e6071f7ff7223c1e60cca5e75e8c Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 29 Aug 2011 13:13:59 +0100 Subject: Add tests & fixes for new search/filtering functionality --- app/controllers/request_controller.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 3c283baae..79b8e4816 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -134,6 +134,7 @@ class RequestController < ApplicationController @title = "View and search requests" sortby = "newest" @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect + behavior_cache :tag => [@view, @page] do xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') @list_results = xapian_object.results.map { |r| r[:model] } -- cgit v1.2.3