diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/admin_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/admin_request_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/api_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 17 | ||||
-rw-r--r-- | app/controllers/general_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/help_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/holiday_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 13 | ||||
-rw-r--r-- | app/controllers/services_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 4 |
10 files changed, 28 insertions, 36 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 08528f8a8..b0c936a62 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -48,7 +48,7 @@ class AdminController < ApplicationController end def authenticate - if MySociety::Config.get('SKIP_ADMIN_AUTH', false) + if Configuration::skip_admin_auth session[:using_admin] = 1 return else @@ -70,10 +70,8 @@ class AdminController < ApplicationController end end else - config_username = MySociety::Config.get('ADMIN_USERNAME', '') - config_password = MySociety::Config.get('ADMIN_PASSWORD', '') authenticate_or_request_with_http_basic do |user_name, password| - if user_name == config_username && password == config_password + if user_name == Configuration::admin_username && password == Configuration::admin_password session[:using_admin] = 1 request.env['REMOTE_USER'] = user_name else diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 53ff2957b..b8f2de968 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -42,9 +42,9 @@ class AdminRequestController < AdminController # 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, - :name_from => MySociety::Config.get("CONTACT_NAME", 'Alaveteli'), + :name_from => Configuration::contact_name, :info_request => @info_request, :reason => params[:reason], - :info_request_url => 'http://' + MySociety::Config.get('DOMAIN') + request_url(@info_request), + :info_request_url => 'http://' + Configuration::domain + request_url(@info_request), :site_name => site_name) template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.rhtml")) @request_hidden_user_explanation = ERB.new(template).result(vars.instance_eval { binding }) diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 409a432eb..aa5e85db3 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -248,6 +248,6 @@ class ApiController < ApplicationController private def make_url(*args) - "http://" + MySociety::Config.get("DOMAIN", '127.0.0.1:3000') + "/" + args.join("/") + "http://" + Configuration::domain + "/" + args.join("/") end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ce18e6ef5..4e319ae5c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -56,7 +56,7 @@ class ApplicationController < ActionController::Base end def set_gettext_locale - if MySociety::Config.get('USE_DEFAULT_BROWSER_LANGUAGE', true) + if Configuration::use_default_browser_language 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 @@ -89,7 +89,7 @@ class ApplicationController < ActionController::Base # egrep "CONSUME MEMORY: [0-9]{7} KB" production.log around_filter :record_memory def record_memory - record_memory = MySociety::Config.get('DEBUG_RECORD_MEMORY', false) + record_memory = Configuration::debug_record_memory if record_memory logger.info "Processing request for #{request.url} with Rails process #{Process.pid}" File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) @@ -333,11 +333,10 @@ class ApplicationController < ActionController::Base # def check_read_only - read_only = MySociety::Config.get('READ_ONLY', '') - if !read_only.empty? + if !Configuration::read_only.empty? 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) + :read_only => Configuration::read_only) redirect_to frontpage_url end @@ -557,13 +556,11 @@ class ApplicationController < ActionController::Base end def country_from_ip - gaze = MySociety::Config.get('GAZE_URL', '') - default = MySociety::Config.get('ISO_COUNTRY_CODE', '') country = "" - if !gaze.empty? - country = quietly_try_to_open("#{gaze}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}") + if !Configuration::gaze_url.empty? + country = quietly_try_to_open("#{Configuration::gaze_url}/gaze-rest?f=get_country_from_ip;ip=#{request.remote_ip}") end - country = default if country.empty? + country = Configuration::iso_country_code if country.empty? return country end diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 839064fcd..9e47af22a 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -24,7 +24,7 @@ class GeneralController < ApplicationController 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 = MySociety::Config.get('FRONTPAGE_PUBLICBODY_EXAMPLES', '').split(/\s*;\s*/).map{|s| "'%s'" % s.gsub(/'/, "''") }.join(", ") + 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] @@ -71,7 +71,7 @@ class GeneralController < ApplicationController def blog medium_cache @feed_autodetect = [] - @feed_url = "#{MySociety::Config.get('BLOG_FEED', '')}?lang=#{self.locale_from_params()}" + @feed_url = "#{Configuration::blog_feed}?lang=#{self.locale_from_params()}" @blog_items = [] if not @feed_url.empty? content = quietly_try_to_open(@feed_url) @@ -82,7 +82,7 @@ class GeneralController < ApplicationController @feed_autodetect = [{:url => @feed_url, :title => "#{site_name} blog"}] end end - @twitter_user = MySociety::Config.get('TWITTER_USERNAME', '') + @twitter_user = Configuration::twitter_username end # Just does a redirect from ?query= search to /query diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index c7affd57c..ba04b7e22 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -20,7 +20,7 @@ class HelpController < ApplicationController end def contact - @contact_email = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') + @contact_email = Configuration::contact_email @contact_email = @contact_email.gsub(/@/, "@") # if they clicked remove for link to request/body, remove it diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb index 9430c0756..82fa2852e 100644 --- a/app/controllers/holiday_controller.rb +++ b/app/controllers/holiday_controller.rb @@ -14,9 +14,7 @@ class HolidayController < ApplicationController def due_date if params[:holiday] @request_date = Date.strptime(params[:holiday]) or raise "Invalid date" - days_later = MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20) - working_or_calendar_days = MySociety::Config.get('WORKING_OR_CALENDAR_DAYS', 'working') - @due_date = Holiday.due_date_from(@request_date, days_later, working_or_calendar_days) + @due_date = Holiday.due_date_from(@request_date, Configuration::reply_late_after_days, Configuration::working_or_calendar_days) @skipped = Holiday.all( :conditions => [ 'day >= ? AND day <= ?', @request_date.strftime("%F"), @due_date.strftime("%F") diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 268ecc73a..9ad328a0c 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -46,7 +46,7 @@ class RequestController < ApplicationController end def show - if !MySociety::Config.get('VARNISH_HOST').nil? + if !Configuration::varnish_host.nil? # If varnish is set up to accept PURGEs, then cache for a # long time long_cache @@ -369,7 +369,7 @@ class RequestController < ApplicationController replied by then.</p> <p>If you write about this request (for example in a forum or a blog) please link to this page, and add an annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full, - :late_number_of_days => MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20)) + :late_number_of_days => Configuration::reply_late_after_days) redirect_to show_new_request_path(:url_title => @info_request.url_title) end @@ -457,7 +457,7 @@ class RequestController < ApplicationController flash[:notice] = _("<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response promptly, and normally before the end of <strong>{{date_response_required_by}}</strong>.</p>",:date_response_required_by=>simple_date(@info_request.date_response_required_by)) redirect_to request_url(@info_request) elsif @info_request.calculate_status == 'waiting_response_very_overdue' - flash[:notice] = _("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40), :late_number_of_days => MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20)) + flash[:notice] = _("<p>Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.</p>", :very_late_number_of_days => Configuration::reply_very_late_after_days, :late_number_of_days => Configuration::reply_late_after_days) redirect_to unhappy_url(@info_request) elsif @info_request.calculate_status == 'not_held' flash[:notice] = _("<p>Thank you! Here are some ideas on what to do next:</p> @@ -489,7 +489,7 @@ class RequestController < ApplicationController elsif @info_request.calculate_status == 'gone_postal' redirect_to respond_to_last_url(@info_request) + "?gone_postal=1" elsif @info_request.calculate_status == 'internal_review' - flash[:notice] = _("<p>Thank you! Hopefully your wait isn't too long.</p><p>You should get a response within {{late_number_of_days}} days, or be told if it will take longer (<a href=\"{{review_url}}\">details</a>).</p>",:late_number_of_days => MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20), :review_url => unhappy_url(@info_request) + "#internal_review") + flash[:notice] = _("<p>Thank you! Hopefully your wait isn't too long.</p><p>You should get a response within {{late_number_of_days}} days, or be told if it will take longer (<a href=\"{{review_url}}\">details</a>).</p>",:late_number_of_days => Configuration.reply_late_after_days, :review_url => unhappy_url(@info_request) + "#internal_review") redirect_to request_url(@info_request) elsif @info_request.calculate_status == 'error_message' flash[:notice] = _("<p>Thank you! We'll look into what happened and try and fix it up.</p><p>If the error was a delivery failure, and you can find an up to date FOI email address for the authority, please tell us using the form below.</p>") @@ -875,11 +875,10 @@ class RequestController < ApplicationController if !File.exists?(file_path) FileUtils.mkdir_p(File.dirname(file_path)) Zip::ZipFile.open(file_path, Zip::ZipFile::CREATE) { |zipfile| - convert_command = MySociety::Config.get("HTML_TO_PDF_COMMAND") + convert_command = Configuration::html_to_pdf_command done = false if File.exists?(convert_command) - domain = MySociety::Config.get("DOMAIN") - url = "http://#{domain}#{request_url(info_request)}?print_stylesheet=1" + url = "http://#{Configuration::domain}#{request_url(info_request)}?print_stylesheet=1" tempfile = Tempfile.new('foihtml2pdf') output = AlaveteliExternalCommand.run(convert_command, url, tempfile.path) if !output.nil? diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 40e0faaf7..ead5d73b7 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -6,7 +6,7 @@ class ServicesController < ApplicationController def other_country_message text = "" - iso_country_code = MySociety::Config.get('ISO_COUNTRY_CODE').downcase + iso_country_code = Configuration::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] @@ -36,9 +36,9 @@ class ServicesController < ApplicationController :content_type => "text/plain", :layout => false, :locals => {:name_to => info_request.user_name, - :name_from => MySociety::Config.get("CONTACT_NAME", 'Alaveteli'), + :name_from => Configuration::contact_name, :info_request => info_request, :reason => params[:reason], - :info_request_url => 'http://' + MySociety::Config.get('DOMAIN') + request_url(info_request), + :info_request_url => 'http://' + Configuration::domain + request_url(info_request), :site_name => site_name} end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 0a9e1d781..c48f75204 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -138,7 +138,7 @@ class UserController < ApplicationController # Login form def signin work_out_post_redirect - @request_from_foreign_country = country_from_ip != MySociety::Config.get('ISO_COUNTRY_CODE', 'GB') + @request_from_foreign_country = country_from_ip != Configuration::iso_country_code # make sure we have cookies if session.instance_variable_get(:@dbman) if not session.instance_variable_get(:@dbman).instance_variable_get(:@original) @@ -192,7 +192,7 @@ class UserController < ApplicationController # Create new account form def signup work_out_post_redirect - @request_from_foreign_country = country_from_ip != MySociety::Config.get('ISO_COUNTRY_CODE', 'GB') + @request_from_foreign_country = country_from_ip != Configuration::iso_country_code # Make the user and try to save it @user_signup = User.new(params[:user_signup]) error = false |