diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-08-22 14:11:02 +0100 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-08-22 14:19:05 +0100 |
commit | 5c3881bfacdb34a605ddfbadf1531d0e341d7beb (patch) | |
tree | 088e752d1a6d2fb38d1409dbfb1cb332af92594c /app/controllers/application_controller.rb | |
parent | 15a174375e638b91c138d771d4851613110f9cdc (diff) | |
parent | a29b3aaf0ae77af49d38813b62dddcb6889c1ebe (diff) |
merge from master and make tests pass
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5f18be2e5..0df3e22da 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -42,18 +42,18 @@ class ApplicationController < ActionController::Base end def set_gettext_locale - requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] + if MySociety::Config.get('USE_DEFAULT_BROWSER_LANGUAGE', true) + requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || I18n.default_locale + else + requested_locale = params[:locale] || session[:locale] || cookies[:locale] || I18n.default_locale + end session[:locale] = FastGettext.set_locale(requested_locale) end # scrub sensitive parameters from the logs filter_parameter_logging :password - helper_method :site_name, :locale_from_params - def site_name - site_name = MySociety::Config.get('SITE_NAME', 'Alaveteli') - return site_name - end + helper_method :locale_from_params # Help work out which request causes RAM spike. # http://www.codeweblog.com/rails-to-monitor-the-process-of-memory-leaks-skills/ @@ -221,7 +221,11 @@ class ApplicationController < ActionController::Base if session[:user_id].nil? return nil else - return User.find(session[:user_id]) + begin + return User.find(session[:user_id]) + rescue ActiveRecord::RecordNotFound + return nil + end end end @@ -272,7 +276,9 @@ class ApplicationController < ActionController::Base def check_read_only read_only = MySociety::Config.get('READ_ONLY', '') if !read_only.empty? - flash[:notice] = "<p>WhatDoTheyKnow is currently in maintenance. You can only view existing requests. You cannot make new ones, add followups or annotations, or otherwise change the database.</p> <p>" + read_only + "</p>" + flash[:notice] = _("<p>{{site_name}} is currently in maintenance. You can only view existing requests. You cannot make new ones, add followups or annotations, or otherwise change the database.</p> <p>{{read_only}}</p>", + :site_name => site_name, + :read_only => read_only) redirect_to frontpage_url end @@ -347,6 +353,9 @@ class ApplicationController < ActionController::Base # views (for links) and mailers (for use in emails), so include them into # all of all. include LinkToHelper + + # Site-wide access to configuration settings + include ConfigHelper end |