aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin_censor_rule_controller.rb2
-rw-r--r--app/controllers/admin_public_body_controller.rb9
-rw-r--r--app/controllers/admin_request_controller.rb2
-rw-r--r--app/controllers/api_controller.rb5
-rw-r--r--app/controllers/application_controller.rb11
-rw-r--r--app/controllers/services_controller.rb20
6 files changed, 31 insertions, 18 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb
index 52df8dfc1..ec86cdf8e 100644
--- a/app/controllers/admin_censor_rule_controller.rb
+++ b/app/controllers/admin_censor_rule_controller.rb
@@ -31,6 +31,8 @@ class AdminCensorRuleController < AdminController
redirect_to admin_url('request/show/' + @censor_rule.info_request.id.to_s)
elsif !@censor_rule.user.nil?
redirect_to admin_url('user/show/' + @censor_rule.user.id.to_s)
+ elsif @censor_rule.regexp?
+ redirect_to admin_url('')
else
raise "internal error"
end
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index 285523e11..dd47c1a4f 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -139,13 +139,8 @@ class AdminPublicBodyController < AdminController
end
def import_csv
- if params['commit'] == 'Dry run'
- dry_run_only = true
- elsif params['commit'] == 'Upload'
- dry_run_only = false
- else
- raise "internal error, unknown button label"
- end
+ dry_run_only = (params['commit'] == 'Upload' ? false : true)
+
if params[:csv_file]
csv_contents = params[:csv_file].read
else
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index dba4955dc..0b58a95e5 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -28,7 +28,7 @@ class AdminRequestController < AdminController
@info_request = InfoRequest.find(params[:id])
# XXX is this *really* the only way to render a template to a
# variable, rather than to the response?
- vars = OpenStruct.new(:name_to => @info_request.user.name,
+ vars = OpenStruct.new(:name_to => @info_request.user_name,
:name_from => MySociety::Config.get("CONTACT_NAME", 'Alaveteli'),
:info_request => @info_request, :reason => params[:reason],
:info_request_url => 'http://' + MySociety::Config.get('DOMAIN') + request_url(@info_request),
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index 4db07b4c9..718c31e6f 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -151,8 +151,9 @@ class ApiController < ApplicationController
mail = RequestMailer.create_external_response(request, body, sent_at, attachment_hashes)
request.receive(mail, mail.encoded, true)
end
-
- head :no_content
+ render :json => {
+ 'url' => make_url("request", request.url_title),
+ }
end
def body_request_events
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index eb6c9c7f7..7b5eb5590 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -27,6 +27,7 @@ class ApplicationController < ActionController::Base
before_filter :check_in_post_redirect
before_filter :session_remember_me
before_filter :set_vary_header
+ before_filter :set_popup_banner
# scrub sensitive parameters from the logs
filter_parameter_logging :password
@@ -133,6 +134,10 @@ class ApplicationController < ActionController::Base
# 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
+
case exception
when ActiveRecord::RecordNotFound, ActionController::UnknownAction, ActionController::RoutingError
@status = 404
@@ -156,6 +161,9 @@ class ApplicationController < ActionController::Base
# otherwise missed by this override)
session_remember_me
+ # Make sure the locale is set correctly too
+ set_gettext_locale
+
# Display default, detailed error for developers
original_rescue_action_locally(exception)
end
@@ -556,6 +564,9 @@ class ApplicationController < ActionController::Base
return country
end
+ def set_popup_banner
+ @popup_banner = render_to_string(:partial => "general/popup_banner").strip
+ end
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb
index 00c0e61bd..8fa860fb2 100644
--- a/app/controllers/services_controller.rb
+++ b/app/controllers/services_controller.rb
@@ -9,15 +9,19 @@ class ServicesController < ApplicationController
if country_from_ip.downcase != iso_country_code
found_country = WorldFOIWebsites.by_code(country_from_ip)
found_country_name = !found_country.nil? && found_country[:country_name]
- old_locale = FastGettext.locale
- FastGettext.locale = FastGettext.best_locale_in(request.env['HTTP_ACCEPT_LANGUAGE'])
- if found_country_name
- text = _("Hello! You can make Freedom of Information requests within {{country_name}} at {{link_to_website}}", :country_name => found_country_name, :link_to_website => "<a href=\"#{found_country[:url]}\">#{found_country[:name]}</a>")
- else
- current_country = WorldFOIWebsites.by_code(iso_country_code)[:country_name]
- text = _("Hello! We have an <a href=\"/help/alaveteli?country_name=#{CGI.escape(current_country)}\">important message</a> for visitors outside {{country_name}}", :country_name => current_country)
+
+ old_fgt_locale = FastGettext.locale
+ begin
+ FastGettext.locale = FastGettext.best_locale_in(request.env['HTTP_ACCEPT_LANGUAGE'])
+ if found_country_name
+ text = _("Hello! You can make Freedom of Information requests within {{country_name}} at {{link_to_website}}", :country_name => found_country_name, :link_to_website => "<a href=\"#{found_country[:url]}\">#{found_country[:name]}</a>")
+ else
+ current_country = WorldFOIWebsites.by_code(iso_country_code)[:country_name]
+ text = _("Hello! We have an <a href=\"/help/alaveteli?country_name=#{CGI.escape(current_country)}\">important message</a> for visitors outside {{country_name}}", :country_name => current_country)
+ end
+ ensure
+ FastGettext.locale = old_fgt_locale
end
- FastGettext.locale = old_locale
end
if !text.empty?
text += ' <span class="close-button">X</span>'