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 From a26fbf9b9653114869f0929103f94ceb1c405232 Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Mon, 29 Aug 2011 15:37:48 +0100 Subject: re-enable tracking on "view requests" page (and make note that we now need to make the descriptions we present users more friendly) --- app/controllers/request_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 79b8e4816..1db038c92 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -134,7 +134,6 @@ 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] } @@ -142,9 +141,8 @@ class RequestController < ApplicationController end @title = @title + " (page " + @page.to_s + ")" if (@page > 1) - - # 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 } ] + @track_thing = TrackThing.create_track_for_search_query(query) + @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 0420098e50996a033552335e94e35ade781357af Mon Sep 17 00:00:00 2001 From: Seb Bacon Date: Tue, 30 Aug 2011 13:32:13 +0100 Subject: Additional changes omitted from commit 9d8388c03d0faeaca29d233a340c58bd65f28a97 (distinguish 404s and 500s), fixes #161. --- app/controllers/request_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 79b8e4816..a76418e4e 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -37,7 +37,7 @@ class RequestController < ApplicationController # Look up by new style text names @info_request = InfoRequest.find_by_url_title(params[:url_title]) if @info_request.nil? - raise "Request not found" + raise ActiveRecord::RecordNotFound.new("Request not found") end set_last_request(@info_request) @@ -189,7 +189,7 @@ class RequestController < ApplicationController params[:info_request][:public_body_id] = params[:url_name] else public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise "None found" if public_body.nil? # XXX proper 404 + raise ActiveRecord::RecordNotFound.new("None found") if public_body.nil? # XXX proper 404 params[:info_request][:public_body_id] = public_body.id end elsif params[:public_body_id] @@ -672,10 +672,10 @@ class RequestController < ApplicationController raise "internal error, pre-auth filter should have caught this" if !@info_request.user_can_view?(authenticated_user) @attachment = IncomingMessage.get_attachment_by_url_part_number(@incoming_message.get_attachments_for_display, @part_number) - raise "attachment not found part number " + @part_number.to_s + " incoming_message " + @incoming_message.id.to_s if @attachment.nil? + raise ActiveRecord::RecordNotFound.new("attachment not found part number " + @part_number.to_s + " incoming_message " + @incoming_message.id.to_s) if @attachment.nil? # check filename in URL matches that in database (use a censor rule if you want to change a filename) - raise "please use same filename as original file has, display: '" + @attachment.display_filename + "' old_display: '" + @attachment.old_display_filename + "' original: '" + @original_filename + "'" if @attachment.display_filename != @original_filename && @attachment.old_display_filename != @original_filename + raise ActiveRecord::RecordNotFound.new("please use same filename as original file has, display: '" + @attachment.display_filename + "' old_display: '" + @attachment.old_display_filename + "' original: '" + @original_filename + "'") if @attachment.display_filename != @original_filename && @attachment.old_display_filename != @original_filename @attachment_url = get_attachment_url(:id => @incoming_message.info_request_id, :incoming_message_id => @incoming_message.id, :part => @part_number, -- cgit v1.2.3