diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/general_controller.rb | 36 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/services_controller.rb | 10 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 3 |
4 files changed, 16 insertions, 43 deletions
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index c715b547d..8ac41b05a 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -86,34 +86,19 @@ class GeneralController < ApplicationController # Just does a redirect from ?query= search to /query def search_redirect - if params[:advanced].nil? - @query, _ = make_query_from_params - else - @query, _ = params[:query] - end - @sortby = params[:sortby] - path = request.path.split("/") - if path.size > 0 && (['newest', 'described', 'relevant'].include?(path[-1])) - @sort_postfix = path.pop - end - if path.size > 0 && (['bodies', 'requests', 'users', 'all'].include?(path[-1])) - @variety_postfix = path.pop - end - @variety_postfix = "bodies" if @variety_postfix.nil? && !params[:bodies].nil? - @variety_postfix = "all" if @variety_postfix.nil? - if @variety_postfix != "users" - @common_query = get_tags_from_params - end - [:latest_status, :request_variety, :request_date_after, :request_date_before, :query, :tags].each do |x| - session[x] = params[x] - end + @query = params.delete(:query) if @query.nil? || @query.empty? @query = nil @page = 1 @advanced = !params[:advanced].nil? render :action => "search" else - redirect_to search_url(@query, @variety_postfix, @sort_postfix, params[:advanced]) + query_parts = @query.split("/") + if !['bodies', 'requests', 'users', 'all'].include?(query_parts[-1]) + redirect_to search_url([@query, "all"], params) + else + redirect_to search_url(@query, params) + end end end @@ -121,13 +106,6 @@ class GeneralController < ApplicationController def search # XXX Why is this so complicated with arrays and stuff? Look at the route # in config/routes.rb for comments. - if !params[:commit].nil? - search_redirect - return - end - [:latest_status, :request_variety, :request_date_after, :request_date_before, :query, :tags].each do |x| - params[x] = session[x] if params[x].nil? - end combined = params[:combined] @sortby = nil @bodies = @requests = @users = true diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 11812b729..a70e8d16c 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -74,8 +74,9 @@ class RequestController < ApplicationController @info_request_events = @info_request.info_request_events @status = @info_request.calculate_status @collapse_quotes = params[:unfold] ? false : true - @update_status = params[:update_status] ? true : false + @update_status = params[:update_status] ? true : false @old_unclassified = @info_request.is_old_unclassified? && !authenticated_user.nil? + @is_owning_user = @info_request.is_owning_user?(authenticated_user) if @update_status return if !@is_owning_user && !authenticated_as_user?(@info_request.user, @@ -108,7 +109,6 @@ class RequestController < ApplicationController # For send followup link at bottom @last_response = @info_request.get_last_response - @is_owning_user = @info_request.is_owning_user?(authenticated_user) respond_to do |format| format.html { @has_json = true; render :template => 'request/show'} format.json { render :json => @info_request.json_for_api(true) } @@ -168,7 +168,8 @@ class RequestController < ApplicationController query = make_query_from_params @title = _("View and search requests") sortby = "newest" - behavior_cache :tag => [@query, @page, I18n.locale] do + @cache_tag = Digest::MD5.hexdigest(query + @page.to_s) + behavior_cache :tag => [@cache_tag] do xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse') @list_results = xapian_object.results.map { |r| r[:model] } @matches_estimated = xapian_object.matches_estimated @@ -696,7 +697,8 @@ class RequestController < ApplicationController @incoming_message.parse_raw_email! @info_request = @incoming_message.info_request if @incoming_message.info_request_id != params[:id].to_i - raise ActiveRecord::RecordNotFound.new(sprintf("Incoming message %d does not belong to request %d", @incoming_message.info_request_id, params[:id])) + message = "Incoming message %d does not belong to request %d" % [@incoming_message.info_request_id, params[:id]] + raise ActiveRecord::RecordNotFound.new(message) end @part_number = params[:part].to_i @filename = params[:file_name].join("/") diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 6fb20336e..225790d71 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -1,12 +1,4 @@ -# controllers/application.rb: -# Parent class of all controllers in FOI site. Filters added to this controller -# apply to all controllers in the application. Likewise, all the methods added -# will be available for all controllers. -# -# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. -# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: application.rb,v 1.59 2009-09-17 13:01:56 francis Exp $ +# controllers/services_controller.rb: require 'open-uri' diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 45b71a3a9..f49fc9165 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -489,7 +489,8 @@ class UserController < ApplicationController raise ActiveRecord::RecordNotFound.new("user not found, url_name=" + params[:url_name]) end if !@display_user.profile_photo - raise "user has no profile photo, url_name=" + params[:url_name] + raise ActiveRecord::RecordNotFound.new("user has no profile photo, url_name=" + params[:url_name]) + end response.content_type = "image/png" |