aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_public_body_controller.rb10
-rw-r--r--app/controllers/application_controller.rb31
-rw-r--r--app/controllers/general_controller.rb88
-rw-r--r--app/controllers/help_controller.rb2
-rw-r--r--app/controllers/public_body_controller.rb6
-rw-r--r--app/controllers/request_controller.rb33
6 files changed, 79 insertions, 91 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index ac12e97b2..c41d05c8d 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -14,7 +14,7 @@ class AdminPublicBodyController < AdminController
def _lookup_query_internal
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@query = params[:query]
if @query == ""
@query = nil
@@ -75,7 +75,7 @@ class AdminPublicBodyController < AdminController
def show
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@public_body = PublicBody.find(params[:id])
render
end
@@ -87,7 +87,7 @@ class AdminPublicBodyController < AdminController
end
def create
- PublicBody.with_locale(I18n.default_locale) do
+ I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
@@ -106,7 +106,7 @@ class AdminPublicBodyController < AdminController
end
def update
- PublicBody.with_locale(I18n.default_locale) do
+ I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
@@ -120,7 +120,7 @@ class AdminPublicBodyController < AdminController
def destroy
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
public_body = PublicBody.find(params[:id])
if public_body.info_requests.size > 0
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a946526b8..9b39d5178 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -27,9 +27,6 @@ class ApplicationController < ActionController::Base
before_filter :set_vary_header
before_filter :set_popup_banner
- # scrub sensitive parameters from the logs
- filter_parameter_logging :password
-
def set_vary_header
response.headers['Vary'] = 'Cookie'
end
@@ -74,9 +71,6 @@ class ApplicationController < ActionController::Base
end
end
- # scrub sensitive parameters from the logs
- filter_parameter_logging :password
-
helper_method :locale_from_params
# Help work out which request causes RAM spike.
@@ -154,19 +148,20 @@ class ApplicationController < ActionController::Base
render :template => "general/exception_caught.rhtml", :status => @status
end
- # For development sites.
- alias original_rescue_action_locally rescue_action_locally
- def rescue_action_locally(exception)
- # Make sure expiry time for session is set (before_filters are
- # otherwise missed by this override)
- session_remember_me
+ # FIXME: This was disabled during the Rails 3 upgrade as this is now handled by Rack
+ # # For development sites.
+ # alias original_rescue_action_locally rescue_action_locally
+ # def rescue_action_locally(exception)
+ # # Make sure expiry time for session is set (before_filters are
+ # # otherwise missed by this override)
+ # session_remember_me
- # Make sure the locale is set correctly too
- set_gettext_locale
+ # # Make sure the locale is set correctly too
+ # set_gettext_locale
- # Display default, detailed error for developers
- original_rescue_action_locally(exception)
- end
+ # # Display default, detailed error for developers
+ # original_rescue_action_locally(exception)
+ # end
def local_request?
false
@@ -258,7 +253,7 @@ class ApplicationController < ActionController::Base
# Check the user is logged in
def authenticated?(reason_params)
unless session[:user_id]
- post_redirect = PostRedirect.new(:uri => request.request_uri, :post_params => params,
+ post_redirect = PostRedirect.new(:uri => request.fullpath, :post_params => params,
:reason_params => reason_params)
post_redirect.save!
# 'modal' controls whether the sign-in form will be displayed in the typical full-blown
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 3ba636e29..faf34aa04 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -19,53 +19,51 @@ class GeneralController < ApplicationController
# New, improved front page!
def frontpage
medium_cache
- behavior_cache :tag => [session[:user_id], request.url] do
- # get some example searches and public bodies to display
- # either from config, or based on a (slow!) query if not set
- body_short_names = Configuration::frontpage_publicbody_examples.split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ")
- @locale = self.locale_from_params()
- locale_condition = 'public_body_translations.locale = ?'
- conditions = [locale_condition, @locale]
- PublicBody.with_locale(@locale) do
- if body_short_names.empty?
- # This is too slow
- @popular_bodies = PublicBody.visible.find(:all,
- :order => "info_requests_count desc",
- :limit => 32,
- :conditions => conditions,
- :joins => :translations
- )
- else
- conditions[0] += " and public_bodies.url_name in (" + body_short_names + ")"
- @popular_bodies = PublicBody.find(:all,
- :conditions => conditions,
- :joins => :translations)
- end
+ # get some example searches and public bodies to display
+ # either from config, or based on a (slow!) query if not set
+ body_short_names = Configuration::frontpage_publicbody_examples.split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ")
+ @locale = self.locale_from_params()
+ locale_condition = 'public_body_translations.locale = ?'
+ conditions = [locale_condition, @locale]
+ I18n.with_locale(@locale) do
+ if body_short_names.empty?
+ # This is too slow
+ @popular_bodies = PublicBody.visible.find(:all,
+ :order => "info_requests_count desc",
+ :limit => 32,
+ :conditions => conditions,
+ :joins => :translations
+ )
+ else
+ conditions[0] += " and public_bodies.url_name in (" + body_short_names + ")"
+ @popular_bodies = PublicBody.find(:all,
+ :conditions => conditions,
+ :joins => :translations)
end
- # Get some successful requests
- begin
- query = 'variety:response (status:successful OR status:partially_successful)'
- sortby = "newest"
- max_count = 5
- xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count)
- @request_events = xapian_object.results.map { |r| r[:model] }
-
- # If there are not yet enough successful requests, fill out the list with
- # other requests
- if @request_events.count < max_count
- @request_events_all_successful = false
- query = 'variety:sent'
- xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count)
- more_events = xapian_object.results.map { |r| r[:model] }
- @request_events += more_events
- # Overall we still want the list sorted with the newest first
- @request_events.sort!{|e1,e2| e2.created_at <=> e1.created_at}
- else
- @request_events_all_successful = true
- end
- rescue
- @request_events = []
+ end
+ # Get some successful requests
+ begin
+ query = 'variety:response (status:successful OR status:partially_successful)'
+ sortby = "newest"
+ max_count = 5
+ xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count)
+ @request_events = xapian_object.results.map { |r| r[:model] }
+
+ # If there are not yet enough successful requests, fill out the list with
+ # other requests
+ if @request_events.count < max_count
+ @request_events_all_successful = false
+ query = 'variety:sent'
+ xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_title_collapse', max_count-@request_events.count)
+ more_events = xapian_object.results.map { |r| r[:model] }
+ @request_events += more_events
+ # Overall we still want the list sorted with the newest first
+ @request_events.sort!{|e1,e2| e2.created_at <=> e1.created_at}
+ else
+ @request_events_all_successful = true
end
+ rescue
+ @request_events = []
end
end
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index cf90f45bb..d13b2655f 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -50,7 +50,7 @@ class HelpController < ApplicationController
end
@contact = ContactValidator.new(params[:contact])
if @contact.valid? && !params[:remove]
- ContactMailer.deliver_message(
+ ContactMailer.deliver_to_admin_message(
params[:contact][:name],
params[:contact][:email],
params[:contact][:subject],
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 8a4a65820..5265706bf 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -16,7 +16,7 @@ class PublicBodyController < ApplicationController
return
end
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
if @public_body.url_name.nil?
@@ -71,7 +71,7 @@ class PublicBodyController < ApplicationController
@public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
- PublicBody.with_locale(self.locale_from_params()) do
+ I18n.with_locale(self.locale_from_params()) do
if params[:submitted_view_email]
if verify_recaptcha
flash.discard(:error)
@@ -129,7 +129,7 @@ class PublicBodyController < ApplicationController
@description = _("in the category ‘{{category_name}}’", :category_name=>category_name)
end
end
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@public_bodies = PublicBody.paginate(
:order => "public_body_translations.name", :page => params[:page], :per_page => 100,
:conditions => conditions,
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 3e8c0a5f6..6106d68da 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -52,7 +52,7 @@ class RequestController < ApplicationController
medium_cache
end
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
# Look up by old style numeric identifiers
if params[:url_title].match(/^[0-9]+$/)
@@ -99,15 +99,13 @@ class RequestController < ApplicationController
# Sidebar stuff
# ... requests that have similar imporant terms
- behavior_cache :tag => ['similar', @info_request.id] do
- begin
- limit = 10
- @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
- :limit => limit, :collapse_by_prefix => 'request_collapse')
- @xapian_similar_more = (@xapian_similar.matches_estimated > limit)
- rescue
- @xapian_similar = nil
- end
+ begin
+ limit = 10
+ @xapian_similar = ::ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events,
+ :limit => limit, :collapse_by_prefix => 'request_collapse')
+ @xapian_similar_more = (@xapian_similar.matches_estimated > limit)
+ rescue
+ @xapian_similar = nil
end
# Track corresponding to this page
@@ -180,13 +178,10 @@ class RequestController < ApplicationController
query = make_query_from_params
@title = _("View and search requests")
sortby = "newest"
- @cache_tag = Digest::MD5.hexdigest(query + @page.to_s + I18n.locale.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
- @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
- end
+ xapian_object = perform_search([InfoRequestEvent], query, sortby, 'request_collapse')
+ @list_results = xapian_object.results.map { |r| r[:model] }
+ @matches_estimated = xapian_object.matches_estimated
+ @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated
@title = @title + " (page " + @page.to_s + ")" if (@page > 1)
@track_thing = TrackThing.create_track_for_search_query(query)
@@ -817,7 +812,7 @@ class RequestController < ApplicationController
# FOI officers can upload a response
def upload_response
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
@reason_params = {
@@ -874,7 +869,7 @@ class RequestController < ApplicationController
def download_entire_request
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
# Test for whole request being hidden or requester-only
if !@info_request.all_can_view?