diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-08-23 17:49:01 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-08-23 17:49:01 +0100 |
commit | 5ea4882f38bcf18016c82c1e6119c4df5237e96e (patch) | |
tree | a393c38b8b4273eee7f4a693c6f4c7a7bd55266f /app/controllers/services_controller.rb | |
parent | db8bb7fa5440855420b8f3ce24611a766e52f89e (diff) | |
parent | a311a1892507aacec5bfb2837dd10f5257dfb42c (diff) |
Merge remote-tracking branch 'origin/release/0.6.4' into wdtk
Conflicts:
app/views/request/show.rhtml
spec/models/info_request_spec.rb
Diffstat (limited to 'app/controllers/services_controller.rb')
-rw-r--r-- | app/controllers/services_controller.rb | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 00c0e61bd..40e0faaf7 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -3,36 +3,43 @@ require 'open-uri' class ServicesController < ApplicationController + def other_country_message text = "" iso_country_code = MySociety::Config.get('ISO_COUNTRY_CODE').downcase 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>' end render :text => text, :content_type => "text/plain" # XXX workaround the HTML validation in test suite end + def hidden_user_explanation info_request = InfoRequest.find(params[:info_request_id]) - render :template => "admin_request/hidden_user_explanation", + render :template => "admin_request/hidden_user_explanation", :content_type => "text/plain", :layout => false, - :locals => {:name_to => info_request.user.name, - :name_from => MySociety::Config.get("CONTACT_NAME", 'Alaveteli'), + :locals => {: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), :site_name => site_name} end + end |