diff options
Diffstat (limited to 'app')
72 files changed, 331 insertions, 264 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb index 52df8dfc1..dca312b8b 100644 --- a/app/controllers/admin_censor_rule_controller.rb +++ b/app/controllers/admin_censor_rule_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_censor_rule_controller.rb,v 1.7 2009-06-30 14:28:25 francis Exp $ class AdminCensorRuleController < AdminController def new diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 08528f8a8..dd966c4af 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_controller.rb,v 1.29 2009-09-17 10:24:35 francis Exp $ require 'fileutils' @@ -48,7 +46,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 +68,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_general_controller.rb b/app/controllers/admin_general_controller.rb index 7e8498d8a..5176eb8db 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_general_controller.rb,v 1.12 2009-10-03 01:28:33 francis Exp $ class AdminGeneralController < AdminController def index diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index 30a43bb81..e64925bde 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_public_body_controller.rb,v 1.23 2009-08-26 00:58:29 francis Exp $ require "public_body_categories" diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 53ff2957b..c97ef7f1e 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_request_controller.rb,v 1.42 2009-10-03 01:28:33 francis Exp $ require 'ostruct' @@ -42,9 +40,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 }) @@ -95,7 +93,7 @@ class AdminRequestController < AdminController :old_allow_new_responses_from => old_allow_new_responses_from, :allow_new_responses_from => @info_request.allow_new_responses_from, :old_handle_rejected_responses => old_handle_rejected_responses, :handle_rejected_responses => @info_request.handle_rejected_responses, :old_tag_string => old_tag_string, :tag_string => @info_request.tag_string, - :old_comments_allowed => old_comments_allowed, :tag_string => @info_request.comments_allowed + :old_comments_allowed => old_comments_allowed, :comments_allowed => @info_request.comments_allowed }) # expire cached files expire_for_request(@info_request) diff --git a/app/controllers/admin_track_controller.rb b/app/controllers/admin_track_controller.rb index 7142dc18e..03217da45 100644 --- a/app/controllers/admin_track_controller.rb +++ b/app/controllers/admin_track_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_track_controller.rb,v 1.5 2009-01-29 12:10:10 francis Exp $ class AdminTrackController < AdminController def list diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb index 4059ac0bb..ed20ddcf4 100644 --- a/app/controllers/admin_user_controller.rb +++ b/app/controllers/admin_user_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: admin_user_controller.rb,v 1.13 2009-07-28 12:53:54 francis Exp $ class AdminUserController < AdminController def index 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..f29015c63 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,8 +6,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: application.rb,v 1.59 2009-09-17 13:01:56 francis Exp $ require 'open-uri' @@ -56,7 +54,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 +87,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 +331,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 +554,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/comment_controller.rb b/app/controllers/comment_controller.rb index 988a8a6f8..ed249d6cc 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: comment_controller.rb,v 1.9 2009-03-09 01:17:04 francis Exp $ class CommentController < ApplicationController before_filter :check_read_only, :only => [ :new ] diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index 839064fcd..150b433ec 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -4,8 +4,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: general_controller.rb,v 1.57 2009-10-03 10:23:43 francis Exp $ begin require 'xmlsimple' @@ -24,7 +22,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] @@ -32,8 +30,7 @@ class GeneralController < ApplicationController if body_short_names.empty? # This is too slow @popular_bodies = PublicBody.find(:all, - :select => "public_bodies.*, (select count(*) from info_requests where info_requests.public_body_id = public_bodies.id) as c", - :order => "c desc", + :order => "info_requests_count desc", :limit => 32, :conditions => conditions, :joins => :translations @@ -56,10 +53,13 @@ class GeneralController < ApplicationController # 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 + else + @request_events_all_successful = true end rescue @request_events = [] @@ -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..cf90f45bb 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: help_controller.rb,v 1.12 2009-07-14 23:30:37 francis Exp $ class HelpController < ApplicationController @@ -20,7 +18,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 7f62aa26d..3101c07e3 100644 --- a/app/controllers/holiday_controller.rb +++ b/app/controllers/holiday_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: holiday_controller.rb,v 1.2 2009-10-26 17:52:39 francis Exp $ class HolidayController < ApplicationController @@ -14,7 +12,7 @@ class HolidayController < ApplicationController def due_date if params[:holiday] @request_date = Date.strptime(params[:holiday]) or raise "Invalid date" - @due_date = Holiday.due_date_from(@request_date, 20) + @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/public_body_controller.rb b/app/controllers/public_body_controller.rb index b8ea82a66..b34e89b8d 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -4,8 +4,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: public_body_controller.rb,v 1.8 2009-09-14 13:27:00 francis Exp $ require 'fastercsv' diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 268ecc73a..396e6593a 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: request_controller.rb,v 1.192 2009-10-19 19:26:40 francis Exp $ require 'alaveteli_file_types' require 'zip/zip' @@ -30,7 +28,7 @@ class RequestController < ApplicationController def select_authority # Check whether we force the user to sign in right at the start, or we allow her # to start filling the request anonymously - if force_registration_on_new_request && !authenticated?( + if Configuration::force_registration_on_new_request && !authenticated?( :web => _("To send your FOI request"), :email => _("Then you'll be allowed to send FOI requests."), :email_subject => _("Confirm your email address") @@ -46,7 +44,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 +367,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 +455,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 +487,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 +873,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/request_game_controller.rb b/app/controllers/request_game_controller.rb index f22652dd1..4b6f02970 100644 --- a/app/controllers/request_game_controller.rb +++ b/app/controllers/request_game_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: request_game_controller.rb,v 1.9 2009-10-19 22:06:54 francis Exp $ class RequestGameController < ApplicationController 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/track_controller.rb b/app/controllers/track_controller.rb index 1a21491b1..8e76b4c9f 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -4,8 +4,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: track_controller.rb,v 1.31 2009-09-02 14:18:26 francis Exp $ class TrackController < ApplicationController diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 0a9e1d781..810b3321e 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: user_controller.rb,v 1.71 2009-09-17 07:51:47 francis Exp $ require 'set' @@ -138,7 +136,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 +190,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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 278df5a3b..090359f1f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,8 +4,7 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: application_helper.rb,v 1.22 2008-07-09 07:24:50 francis Exp $ + require 'languages' module ApplicationHelper diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb index 543b60256..73e12172f 100644 --- a/app/helpers/config_helper.rb +++ b/app/helpers/config_helper.rb @@ -1,9 +1,5 @@ module ConfigHelper def site_name - MySociety::Config.get('SITE_NAME', 'Alaveteli') - end - - def force_registration_on_new_request - MySociety::Config.get('FORCE_REGISTRATION_ON_NEW_REQUEST', false) + Configuration::site_name end end
\ No newline at end of file diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index cae17ebd3..994da0e87 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -4,8 +4,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: link_to_helper.rb,v 1.52 2009-04-08 05:34:51 francis Exp $ module LinkToHelper @@ -221,9 +219,8 @@ module LinkToHelper # Admin pages def admin_url(relative_path) - admin_url_prefix = MySociety::Config.get("ADMIN_BASE_URL", "") - admin_url_prefix = admin_general_index_path+"/" if admin_url_prefix.empty? - return admin_url_prefix + relative_path + admin_url_prefix = Configuration::admin_base_url + (admin_url_prefix.empty? ? admin_general_index_url + '/' : admin_url_prefix) + relative_path end # About page URLs @@ -241,7 +238,7 @@ module LinkToHelper def main_url(relative_path, append = nil) - url_prefix = "http://" + MySociety::Config.get("DOMAIN", '127.0.0.1:3000') + url_prefix = "http://" + Configuration::domain url = url_prefix + relative_path if !append.nil? begin diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index c0a950d47..be2ce47aa 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,7 +1,5 @@ module MailerHelper def contact_from_name_and_email - contact_name = MySociety::Config.get("CONTACT_NAME", 'Alaveteli') - contact_email = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') - return "#{contact_name} <#{contact_email}>" + "#{Configuration::contact_name} <#{Configuration::contact_email}>" end end diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb index 67b81bc9c..5e04c2761 100644 --- a/app/models/about_me_validator.rb +++ b/app/models/about_me_validator.rb @@ -11,8 +11,6 @@ # # Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: contact_validator.rb,v 1.32 2009-09-17 21:10:05 francis Exp $ class AboutMeValidator < ActiveRecord::BaseWithoutTable strip_attributes! diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb index 044006f7c..cdb279c3c 100644 --- a/app/models/application_mailer.rb +++ b/app/models/application_mailer.rb @@ -3,9 +3,8 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: application_mailer.rb,v 1.8 2009-02-09 10:37:12 francis Exp $ +require 'action_mailer/version' class ApplicationMailer < ActionMailer::Base # Include all the functions views get, as emails call similar things. helper :application @@ -16,7 +15,7 @@ class ApplicationMailer < ActionMailer::Base self.raise_delivery_errors = true def blackhole_email - MySociety::Config.get("BLACKHOLE_PREFIX", 'do-not-reply-to-this-address')+"@"+MySociety::Config.get("INCOMING_EMAIL_DOMAIN", "localhost") + Configuration::blackhole_prefix+"@"+Configuration::incoming_email_domain end # URL generating functions are needed by all controllers (for redirects), @@ -26,5 +25,126 @@ class ApplicationMailer < ActionMailer::Base # Site-wide access to configuration settings include ConfigHelper + + # Instantiate a new mailer object. If +method_name+ is not +nil+, the mailer + # will be initialized according to the named method. If not, the mailer will + # remain uninitialized (useful when you only need to invoke the "receive" + # method, for instance). + def initialize(method_name=nil, *parameters) #:nodoc: + create!(method_name, *parameters) if method_name + end + + # For each multipart template (e.g. "the_template_file.text.html.erb") available, + # add the one from the view path with the highest priority as a part to the mail + def render_multipart_templates + added_content_types = {} + self.view_paths.each do |view_path| + Dir.glob("#{view_path}/#{mailer_name}/#{@template}.*").each do |path| + template = view_path["#{mailer_name}/#{File.basename(path)}"] + + # Skip unless template has a multipart format + next unless template && template.multipart? + next if added_content_types[template.content_type] == true + @parts << Part.new( + :content_type => template.content_type, + :disposition => "inline", + :charset => charset, + :body => render_message(template, @body) + ) + added_content_types[template.content_type] = true + end + end + end + + # Look for the current template in each element of view_paths in order, + # return the first + def find_template + self.view_paths.each do |view_path| + if template = view_path["#{mailer_name}/#{@template}"] + return template + end + end + return nil + end + + if ActionMailer::VERSION::MAJOR == 2 + + # This method is a customised version of ActionMailer::Base.create! + # modified to allow templates to be selected correctly for multipart + # mails when themes have added to the view_paths. The problem from our + # point of view with ActionMailer::Base is that it sets template_root to + # the first element of the view_paths array and then uses only that (directly + # and via template_path, which is created from it) in the create! method when + # looking for templates. Our modified version looks for templates in the view_paths + # in order. + # Changed lines marked with *** + + # Initialize the mailer via the given +method_name+. The body will be + # rendered and a new TMail::Mail object created. + def create!(method_name, *parameters) #:nodoc: + initialize_defaults(method_name) + __send__(method_name, *parameters) + + # If an explicit, textual body has not been set, we check assumptions. + unless String === @body + # First, we look to see if there are any likely templates that match, + # which include the content-type in their file name (i.e., + # "the_template_file.text.html.erb", etc.). Only do this if parts + # have not already been specified manually. + if @parts.empty? + # *** render_multipart_templates replaces the following code + # Dir.glob("#{template_path}/#{@template}.*").each do |path| + # template = template_root["#{mailer_name}/#{File.basename(path)}"] + # + # # Skip unless template has a multipart format + # next unless template && template.multipart? + # + # @parts << Part.new( + # :content_type => template.content_type, + # :disposition => "inline", + # :charset => charset, + # :body => render_message(template, @body) + # ) + # end + render_multipart_templates + + unless @parts.empty? + @content_type = "multipart/alternative" if @content_type !~ /^multipart/ + @parts = sort_parts(@parts, @implicit_parts_order) + end + end + + # Then, if there were such templates, we check to see if we ought to + # also render a "normal" template (without the content type). If a + # normal template exists (or if there were no implicit parts) we render + # it. + template_exists = @parts.empty? + + # *** find_template replaces template_root call + # template_exists ||= template_root["#{mailer_name}/#{@template}"] + template_exists ||= find_template + + @body = render_message(@template, @body) if template_exists + + # Finally, if there are other message parts and a textual body exists, + # we shift it onto the front of the parts and set the body to nil (so + # that create_mail doesn't try to render it in addition to the parts). + if !@parts.empty? && String === @body + @parts.unshift ActionMailer::Part.new(:charset => charset, :body => @body) + @body = nil + end + end + + # If this is a multipart e-mail add the mime_version if it is not + # already set. + @mime_version ||= "1.0" if !@parts.empty? + + # build the mail object itself + @mail = create_mail + end + else + raise "ApplicationMailer.create! is obsolete - find another way to ensure that themes can override mail templates for multipart mails" + end + end diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index a74fdcb24..f40ab6fbb 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -21,8 +21,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: censor_rule.rb,v 1.14 2009-09-17 21:10:04 francis Exp $ class CensorRule < ActiveRecord::Base belongs_to :info_request diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index 0395ab6d5..9ef25217d 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -14,8 +14,6 @@ # # Copyright (c) 2010 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: contact_validator.rb,v 1.32 2009-09-17 21:10:05 francis Exp $ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable strip_attributes! diff --git a/app/models/comment.rb b/app/models/comment.rb index 6edfaa24f..5507910e2 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -19,8 +19,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: comment.rb,v 1.18 2009-09-17 21:10:05 francis Exp $ class Comment < ActiveRecord::Base strip_attributes! diff --git a/app/models/contact_mailer.rb b/app/models/contact_mailer.rb index 6e781d48c..16aae2f15 100644 --- a/app/models/contact_mailer.rb +++ b/app/models/contact_mailer.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: contact_mailer.rb,v 1.10 2009-02-09 10:37:12 francis Exp $ class ContactMailer < ApplicationMailer @@ -52,7 +50,7 @@ class ContactMailer < ApplicationMailer :from_user => @from, :recipient_user => recipient_user, } - bcc MySociety::Config::get("CONTACT_EMAIL") + bcc Configuration::contact_email end end diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb index a9748a739..d277161f9 100644 --- a/app/models/contact_validator.rb +++ b/app/models/contact_validator.rb @@ -14,8 +14,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: contact_validator.rb,v 1.32 2009-09-17 21:10:05 francis Exp $ class ContactValidator < ActiveRecord::BaseWithoutTable strip_attributes! diff --git a/app/models/exim_log.rb b/app/models/exim_log.rb index 82000efa1..abe198493 100644 --- a/app/models/exim_log.rb +++ b/app/models/exim_log.rb @@ -17,8 +17,6 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: exim_log.rb,v 1.14 2009-09-17 21:10:05 francis Exp $ class EximLog < ActiveRecord::Base belongs_to :info_request @@ -63,7 +61,7 @@ class EximLog < ActiveRecord::Base order = 0 for line in f order = order + 1 - email_domain = MySociety::Config.get("INCOMING_EMAIL_DOMAIN", "localhost") + email_domain = Configuration::incoming_email_domain emails = line.scan(/request-[^\s]+@#{email_domain}/).sort.uniq for email in emails info_request = InfoRequest.find_by_incoming_email(email) diff --git a/app/models/exim_log_done.rb b/app/models/exim_log_done.rb index 3cedc1379..86574a4cd 100644 --- a/app/models/exim_log_done.rb +++ b/app/models/exim_log_done.rb @@ -15,8 +15,6 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: exim_log_done.rb,v 1.8 2009-09-17 21:10:05 francis Exp $ class EximLogDone < ActiveRecord::Base has_many :exim_logs diff --git a/app/models/holiday.rb b/app/models/holiday.rb index debd88dec..d2437f438 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -20,23 +20,37 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: holiday.rb,v 1.10 2009-10-26 17:52:39 francis Exp $ class Holiday < ActiveRecord::Base - # Calculate the date on which a request made on a given date falls due. + def Holiday.weekend_or_holiday?(date) + # TODO only fetch holidays after the start_date + holidays = self.all.collect { |h| h.day }.to_set + + date.wday == 0 || date.wday == 6 || holidays.include?(date) + end + + def Holiday.due_date_from(start_date, days, type_of_days) + case type_of_days + when "working" + Holiday.due_date_from_working_days(start_date, days) + when "calendar" + Holiday.due_date_from_calendar_days(start_date, days) + else + raise "Unexpected value for type_of_days: #{type_of_days}" + end + end + + # Calculate the date on which a request made on a given date falls due when + # days are given in working days # i.e. it is due by the end of that day. - def Holiday.due_date_from(start_date, working_days) + def Holiday.due_date_from_working_days(start_date, working_days) # convert date/times into dates start_date = start_date.to_date - # TODO only fetch holidays after the start_date - holidays = self.all.collect { |h| h.day }.to_set - - # Count forward (20) working days. We start with today as "day zero". The - # first of the twenty full working days is the next day. We return the - # date of the last of the twenty. + # Count forward the number of working days. We start with today as "day zero". The + # first of the full working days is the next day. We return the + # date of the last of the number of working days. # This response for example of a public authority complains that we had # it wrong. We didn't (even thought I changed the code for a while, @@ -46,15 +60,27 @@ class Holiday < ActiveRecord::Base days_passed = 0 response_required_by = start_date - # Now step forward into each of the 20 days. + # Now step forward into each of the working days. while days_passed < working_days - response_required_by += 1.day - next if response_required_by.wday == 0 || response_required_by.wday == 6 # weekend - next if holidays.include?(response_required_by) - days_passed += 1 + response_required_by += 1 + days_passed += 1 unless weekend_or_holiday?(response_required_by) end - return response_required_by + response_required_by end + # Calculate the date on which a request made on a given date falls due when + # the days are given in calendar days (rather than working days) + # If the due date falls on a weekend or a holiday then the due date is the next + # weekday that isn't a holiday. + def Holiday.due_date_from_calendar_days(start_date, days) + # convert date/times into dates + start_date = start_date.to_date + + response_required_by = start_date + days + while weekend_or_holiday?(response_required_by) + response_required_by += 1 + end + response_required_by + end end diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 13fc316cd..fcb4671c5 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -27,8 +27,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: incoming_message.rb,v 1.228 2009-10-21 11:24:14 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -253,7 +251,7 @@ class IncomingMessage < ActiveRecord::Base text.gsub!(self.info_request.public_body.request_email, _("[{{public_body}} request email]", :public_body => self.info_request.public_body.short_or_long_name)) end text.gsub!(self.info_request.incoming_email, _('[FOI #{{request}} email]', :request => self.info_request.id.to_s) ) - text.gsub!(MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost'), _("[{{site_name}} contact email]", :site_name => MySociety::Config.get('SITE_NAME', 'Alaveteli')) ) + text.gsub!(Configuration::contact_email, _("[{{site_name}} contact email]", :site_name => Configuration::site_name) ) end # Replaces all email addresses in (possibly binary data) with equal length alternative ones. @@ -279,7 +277,7 @@ class IncomingMessage < ActiveRecord::Base if censored_uncompressed_text != uncompressed_text # then use the altered file (recompressed) recompressed_text = nil - if MySociety::Config.get('USE_GHOSTSCRIPT_COMPRESSION') == true + if Configuration::use_ghostscript_compression == true command = ["gs", "-sDEVICE=pdfwrite", "-dCompatibilityLevel=1.4", "-dPDFSETTINGS=/screen", "-dNOPAUSE", "-dQUIET", "-dBATCH", "-sOutputFile=-", "-"] else command = ["pdftk", "-", "output", "-", "compress"] @@ -376,8 +374,7 @@ class IncomingMessage < ActiveRecord::Base text.gsub!(/(Mobile|Mob)([\s\/]*(Fax|Tel))*\s*:?[\s\d]*\d/, "[mobile number]") # Remove WhatDoTheyKnow signup links - domain = MySociety::Config.get('DOMAIN') - text.gsub!(/http:\/\/#{domain}\/c\/[^\s]+/, "[WDTK login link]") + text.gsub!(/http:\/\/#{Configuration::domain}\/c\/[^\s]+/, "[WDTK login link]") # Remove things from censor rules self.info_request.apply_censor_rules_to_text!(text) @@ -647,9 +644,10 @@ class IncomingMessage < ActiveRecord::Base # Text looks like unlabelled nonsense, # strip out anything that isn't UTF-8 begin + source_charset = 'utf-8' if source_charset.nil? text = Iconv.conv('utf-8//IGNORE', source_charset, text) + _("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]", - :site_name => MySociety::Config.get('SITE_NAME', 'Alaveteli')) + :site_name => Configuration::site_name) rescue Iconv::InvalidEncoding, Iconv::IllegalSequence if source_charset != "utf-8" source_charset = "utf-8" diff --git a/app/models/info_request.rb b/app/models/info_request.rb index b62f67ee1..85168e6d4 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -689,21 +689,18 @@ public # last_event_forming_initial_request. There may be more obscure # things, e.g. fees, not properly covered. def date_response_required_by - days_later = MySociety::Config.get('REPLY_LATE_AFTER_DAYS', 20) - return Holiday.due_date_from(self.date_initial_request_last_sent_at, days_later) + Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::reply_late_after_days, Configuration::working_or_calendar_days) end # This is a long stop - even with UK public interest test extensions, 40 # days is a very long time. def date_very_overdue_after last_sent = last_event_forming_initial_request - very_late_days_later = MySociety::Config.get('REPLY_VERY_LATE_AFTER_DAYS', 40) - school_very_late_days_later = MySociety::Config.get('SPECIAL_REPLY_VERY_LATE_AFTER_DAYS', 60) if self.public_body.is_school? # schools have 60 working days maximum (even over a long holiday) - return Holiday.due_date_from(self.date_initial_request_last_sent_at, 60) + Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::special_reply_very_late_after_days, Configuration::working_or_calendar_days) else # public interest test ICO guidance gives 40 working maximum - return Holiday.due_date_from(self.date_initial_request_last_sent_at, 40) + Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::reply_very_late_after_days, Configuration::working_or_calendar_days) end end @@ -903,10 +900,10 @@ public end def InfoRequest.magic_email_for_id(prefix_part, id) - magic_email = MySociety::Config.get("INCOMING_EMAIL_PREFIX", "") + magic_email = Configuration::incoming_email_prefix magic_email += prefix_part + id.to_s magic_email += "-" + InfoRequest.hash_from_id(id) - magic_email += "@" + MySociety::Config.get("INCOMING_EMAIL_DOMAIN", "localhost") + magic_email += "@" + Configuration::incoming_email_domain return magic_email end @@ -917,7 +914,7 @@ public end def InfoRequest.hash_from_id(id) - return Digest::SHA1.hexdigest(id.to_s + MySociety::Config.get("INCOMING_EMAIL_SECRET", 'dummysecret'))[0,8] + return Digest::SHA1.hexdigest(id.to_s + Configuration::incoming_email_secret)[0,8] end # Called by find_by_incoming_email - and used to be called by separate @@ -1141,7 +1138,7 @@ public before_save :purge_in_cache def purge_in_cache - if !MySociety::Config.get('VARNISH_HOST').nil? && !self.id.nil? + if !Configuration::varnish_host.nil? && !self.id.nil? # we only do this for existing info_requests (new ones have a nil id) path = url_for(:controller => 'request', :action => 'show', :url_title => self.url_title, :only_path => true, :locale => :none) req = PurgeRequest.find_by_url(path) diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 54d2f5ef7..5a8e3416f 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -21,8 +21,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: info_request_event.rb,v 1.96 2009-10-19 22:06:55 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request diff --git a/app/models/outgoing_mailer.rb b/app/models/outgoing_mailer.rb index 8562c5b68..a307bb778 100644 --- a/app/models/outgoing_mailer.rb +++ b/app/models/outgoing_mailer.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: outgoing_mailer.rb,v 1.1 2009-10-04 21:53:54 francis Exp $ # Note: The layout for this wraps messages by lines rather than (blank line # separated) paragraphs, as is the convention for all the other mailers. This @@ -24,7 +22,7 @@ class OutgoingMailer < ApplicationMailer @subject = info_request.email_subject_request @headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message) @body = {:info_request => info_request, :outgoing_message => outgoing_message, - :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') } + :contact_email => Configuration::contact_email } end # Later message to public body regarding existing request @@ -36,7 +34,7 @@ class OutgoingMailer < ApplicationMailer @headers["message-id"] = OutgoingMailer.id_for_message(outgoing_message) @body = {:info_request => info_request, :outgoing_message => outgoing_message, :incoming_message_followup => incoming_message_followup, - :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') } + :contact_email => Configuration::contact_email } end # XXX the condition checking valid_to_reply_to? also appears in views/request/_followup.rhtml, @@ -91,7 +89,7 @@ class OutgoingMailer < ApplicationMailer message_id = "ogm-" + outgoing_message.id.to_s t = Time.now message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)] - message_id += "@" + MySociety::Config.get("INCOMING_EMAIL_DOMAIN", "localhost") + message_id += "@" + Configuration::incoming_email_domain return "<" + message_id + ">" end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 0ce1ee11c..0e547d493 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -21,8 +21,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: outgoing_message.rb,v 1.95 2009-10-04 21:53:54 francis Exp $ class OutgoingMessage < ActiveRecord::Base strip_attributes! @@ -87,7 +85,7 @@ class OutgoingMessage < ActiveRecord::Base "'" + self.info_request.title + "'." + "\n\n\n\n [ " + self.get_internal_review_insert_here_note + " ] \n\n\n\n" + "A full history of my FOI request and all correspondence is available on the Internet at this address:\n" + - "http://" + MySociety::Config.get("DOMAIN", '127.0.0.1:3000') + "/request/" + self.info_request.url_title + "http://" + Configuration::domain + "/request/" + self.info_request.url_title else "" end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index f613fc58d..31f08c21a 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -25,8 +25,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: post_redirect.rb,v 1.51 2009-09-17 21:10:05 francis Exp $ require 'openssl' # for random bytes function diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 72bfe954f..6e605651d 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -14,9 +14,6 @@ # # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: profile_photo.rb,v 1.2 2009-09-17 21:10:05 francis Exp $ -# class ProfilePhoto < ActiveRecord::Base WIDTH = 96 diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 2cf1ce8a2..34bcd332c 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -336,7 +336,7 @@ class PublicBody < ActiveRecord::Base pb = PublicBody.new( :name => 'Internal admin authority', :short_name => "", - :request_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost'), + :request_email => Configuration::contact_email, :home_page => "", :notes => "", :publication_scheme => "", @@ -509,6 +509,20 @@ class PublicBody < ActiveRecord::Base return self.request_email_domain end + # Returns nil if configuration variable not set + def override_request_email + e = Configuration::override_all_public_body_request_emails + e if e != "" + end + + def request_email + if override_request_email + override_request_email + else + read_attribute(:request_email) + end + end + # Domain name of the request email def request_email_domain return PublicBody.extract_domain_from_email(self.request_email) diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb index 3bb794684..bae144931 100644 --- a/app/models/raw_email.rb +++ b/app/models/raw_email.rb @@ -11,8 +11,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: raw_email.rb,v 1.12 2009-09-17 21:10:05 francis Exp $ class RawEmail < ActiveRecord::Base # deliberately don't strip_attributes, so keeps raw email properly @@ -28,8 +26,7 @@ class RawEmail < ActiveRecord::Base if ENV["RAILS_ENV"] == "test" return File.join(Rails.root, 'files/raw_email_test') else - return File.join(MySociety::Config.get('RAW_EMAILS_LOCATION', - 'files/raw_emails'), + return File.join(Configuration::raw_emails_location, request_id[0..2], request_id) end end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index ba9285fc6..413e93e25 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: request_mailer.rb,v 1.89 2009-10-04 21:53:54 francis Exp $ require 'alaveteli_file_types' @@ -50,12 +48,12 @@ class RequestMailer < ApplicationMailer headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # we don't care about bounces, likely from spammers 'Auto-Submitted' => 'auto-replied' # http://tools.ietf.org/html/rfc3834 @recipients = email.from_addrs[0].to_s - @subject = "Your response to an FOI request was not delivered" + @subject = _("Your response to an FOI request was not delivered") attachment :content_type => 'message/rfc822', :body => raw_email_data, :filename => "original.eml", :transfer_encoding => '7bit', :content_disposition => 'inline' @body = { :info_request => info_request, - :contact_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') + :contact_email => Configuration::contact_email } end @@ -154,7 +152,7 @@ class RequestMailer < ApplicationMailer 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 'X-Auto-Response-Suppress' => 'OOF' @recipients = info_request.user.name_and_email - @subject = "Someone has updated the status of your request" + @subject = _("Someone has updated the status of your request") url = main_url(request_url(info_request)) @body = {:info_request => info_request, :url => url} end @@ -303,7 +301,7 @@ class RequestMailer < ApplicationMailer # Send email alerts for new responses which haven't been classified. By default, # it goes out 3 days after last update of event, then after 10, then after 24. def self.alert_new_response_reminders - MySociety::Config.get("NEW_RESPONSE_REMINDER_AFTER_DAYS", [3, 10, 24]).each_with_index do |days, i| + Configuration::new_response_reminder_after_days.each_with_index do |days, i| self.alert_new_response_reminders_internal(days, "new_response_reminder_#{i+1}") end end diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index 92da7c376..7dfa87f52 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: track_mailer.rb,v 1.23 2009-10-03 02:50:11 francis Exp $ class TrackMailer < ApplicationMailer def event_digest(user, email_about_things) @@ -27,9 +25,7 @@ class TrackMailer < ApplicationMailer end def contact_from_name_and_email - contact_name = MySociety::Config.get("TRACK_SENDER_NAME", 'Alaveteli') - contact_email = MySociety::Config.get("TRACK_SENDER_EMAIL", 'contact@localhost') - return "#{contact_name} <#{contact_email}>" + "#{Configuration::track_sender_name} <#{Configuration::track_sender_email}>" end # Send email alerts for tracked things. Never more than one email diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index d0fc62e12..d1cef4d4d 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -20,8 +20,7 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: track_thing.rb,v 1.53 2009-09-17 21:10:05 francis Exp $ + require 'set' class TrackThing < ActiveRecord::Base @@ -51,15 +50,15 @@ class TrackThing < ActiveRecord::Base def TrackThing.track_type_description(track_type) if track_type == 'request_updates' - "Individual requests" + _("Individual requests") elsif track_type == 'all_new_requests' || track_type == "all_successful_requests" - "Many requests" + _("Many requests") elsif track_type == 'public_body_updates' - "Public authorities" + _("Public authorities") elsif track_type == 'user_updates' - "People" + _("People") elsif track_type == 'search_query' - "Search queries" + _("Search queries") else raise "internal error " + track_type end @@ -195,7 +194,7 @@ class TrackThing < ActiveRecord::Base if self.track_type == 'request_updates' @params = { # Website - :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow this request"), :verb_on_page_already => _("You are already following this request"), # Email @@ -246,14 +245,14 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'public_body_updates' @params = { # Website - :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow requests to {{public_body_name}}",:public_body_name=>CGI.escapeHTML(self.public_body.name)), :verb_on_page_already => _("You are already following requests to {{public_body_name}}", :public_body_name=>CGI.escapeHTML(self.public_body.name)), # Email :title_in_email => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'", :title_in_rss => self.public_body.law_only_short + " requests to '" + self.public_body.name + "'", # Authentication - :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>MySociety::Config.get('SITE_NAME', 'Alaveteli'), :public_body_name=>CGI.escapeHTML(self.public_body.name)), + :web => _("To follow requests made using {{site_name}} to the public authority '{{public_body_name}}'", :site_name=>Configuration::site_name, :public_body_name=>CGI.escapeHTML(self.public_body.name)), :email => _("Then you will be notified whenever someone requests something or gets a response from '{{public_body_name}}'.", :public_body_name=>CGI.escapeHTML(self.public_body.name)), :email_subject => _("Confirm you want to follow requests to '{{public_body_name}}'", :public_body_name=>self.public_body.name), # RSS sorting @@ -262,7 +261,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'user_updates' @params = { # Website - :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow this person"), :verb_on_page_already => _("You are already following this person"), # Email @@ -278,7 +277,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'search_query' @params = { # Website - :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => "<a href=\"/search/" + CGI.escapeHTML(self.track_query) + "/newest/advanced\">" + self.track_query_description + "</a>", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Follow things matching this search"), :verb_on_page_already => _("You are already following things matching this search"), # Email diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb index 24297f57b..a0a4c0f0c 100644 --- a/app/models/track_things_sent_email.rb +++ b/app/models/track_things_sent_email.rb @@ -17,8 +17,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: track_things_sent_email.rb,v 1.22 2009-09-17 21:10:05 francis Exp $ class TrackThingsSentEmail < ActiveRecord::Base belongs_to :info_request_event diff --git a/app/models/user.rb b/app/models/user.rb index bb1b54d70..59f6c971c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -208,13 +208,12 @@ class User < ActiveRecord::Base # The "internal admin" is a special user for internal use. def User.internal_admin_user - contact_email = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost') - u = User.find_by_email(contact_email) + u = User.find_by_email(Configuration::contact_email) if u.nil? password = PostRedirect.generate_random_token u = User.new( :name => 'Internal admin user', - :email => contact_email, + :email => Configuration::contact_email, :password => password, :password_confirmation => password ) @@ -282,18 +281,16 @@ class User < ActiveRecord::Base return false if self.no_limit # Has the user issued as many as MAX_REQUESTS_PER_USER_PER_DAY requests in the past 24 hours? - daily_limit = MySociety::Config.get("MAX_REQUESTS_PER_USER_PER_DAY") - return false if daily_limit.nil? + return false if Configuration::max_requests_per_user_per_day.nil? recent_requests = InfoRequest.count(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id]) - return (recent_requests >= daily_limit) + return (recent_requests >= Configuration::max_requests_per_user_per_day) end def next_request_permitted_at return nil if self.no_limit - daily_limit = MySociety::Config.get("MAX_REQUESTS_PER_USER_PER_DAY") - n_most_recent_requests = InfoRequest.all(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id], :order => "created_at DESC", :limit => daily_limit) - return nil if n_most_recent_requests.size < daily_limit + n_most_recent_requests = InfoRequest.all(:conditions => ["user_id = ? and created_at > now() - '1 day'::interval", self.id], :order => "created_at DESC", :limit => Configuration::max_requests_per_user_per_day) + return nil if n_most_recent_requests.size < Configuration::max_requests_per_user_per_day nth_most_recent_request = n_most_recent_requests[-1] return nth_most_recent_request.created_at + 1.day diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb index a97fd5d44..cf20bcbf5 100644 --- a/app/models/user_info_request_sent_alert.rb +++ b/app/models/user_info_request_sent_alert.rb @@ -16,8 +16,6 @@ # # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: user_info_request_sent_alert.rb,v 1.34 2009-10-03 02:22:18 francis Exp $ class UserInfoRequestSentAlert < ActiveRecord::Base belongs_to :user diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb index 7adf5b63c..1be4f8aa3 100644 --- a/app/models/user_mailer.rb +++ b/app/models/user_mailer.rb @@ -3,8 +3,6 @@ # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ -# -# $Id: user_mailer.rb,v 1.8 2009-02-09 10:37:12 francis Exp $ class UserMailer < ApplicationMailer def confirm_login(user, reasons, url) diff --git a/app/views/contact_mailer/user_message.rhtml b/app/views/contact_mailer/user_message.rhtml index fe1f47518..b1d6e81ae 100644 --- a/app/views/contact_mailer/user_message.rhtml +++ b/app/views/contact_mailer/user_message.rhtml @@ -1,7 +1,8 @@ --------------------------------------------------------------------- <%= _('{{user_name}} has used {{site_name}} to send you the message below.', :user_name=>@from_user.name, :site_name=>site_name) %> -<%= _('Your details have not been given to anyone, unless you choose to reply to this -message, which will then go directly to the person who wrote the message.')%> +<%= _('Your details, including your email address, have not been given to anyone.') %> +<%= _('If you reply to this message it will go directly to {{user_name}}, who will +learn your email address. Only reply if that is okay.', :user_name => @from_user.name) %> --------------------------------------------------------------------- <%= @message.strip %> diff --git a/app/views/general/_advanced_search_tips.rhtml b/app/views/general/_advanced_search_tips.rhtml index 520cce89b..914abc1af 100644 --- a/app/views/general/_advanced_search_tips.rhtml +++ b/app/views/general/_advanced_search_tips.rhtml @@ -13,7 +13,7 @@ <li><%= _('<strong><code>request:</code></strong> to restrict to a specific request, typing the title as in the URL.')%> <li><%= _('<strong><code>filetype:pdf</code></strong> to find all responses with PDF attachments. Or try these: <code>{{list_of_file_extensions}}</code>', :list_of_file_extensions => IncomingMessage.get_all_file_extensions)%></li> <li><%= _('Type <strong><code>01/01/2008..14/01/2008</code></strong> to only show things that happened in the first two weeks of January.')%></li> - <li><%= _('<strong><code>tag:charity</code></strong> to find all public bodies or requests with a given tag. You can include multiple tags, + <li><%= _('<strong><code>tag:charity</code></strong> to find all public authorities or requests with a given tag. You can include multiple tags, and tag values, e.g. <code>tag:openlylocal AND tag:financial_transaction:335633</code>. Note that by default any of the tags can be present, you have to put <code>AND</code> explicitly if you only want results them all present.')%></li> <li><%= _('Read about <a href="{{advanced_search_url}}">advanced search operators</a>, such as proximity and wildcards.', :advanced_search_url => "http://www.xapian.org/docs/queryparser.html") %></li> diff --git a/app/views/general/_footer.rhtml b/app/views/general/_footer.rhtml index efcd8f96b..ab5ab2c47 100644 --- a/app/views/general/_footer.rhtml +++ b/app/views/general/_footer.rhtml @@ -1,6 +1,6 @@ <div id="footer"> <%= link_to _("Contact {{site_name}}", :site_name => site_name), help_contact_url %> -| <img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="https://twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>"><%= _("Follow us on twitter") %></a> +| <img src="/images/twitter-16.png" alt="twitter icon" class="twitter-icon"> <a href="https://twitter.com/<%= Configuration::twitter_username %>"><%= _("Follow us on twitter") %></a> <%= render :partial => 'general/credits' %> </div> <div class="after-footer"> </div> diff --git a/app/views/general/_frontpage_search_examples.es.rhtml b/app/views/general/_frontpage_search_examples.es.rhtml deleted file mode 100644 index 63c7c3c1e..000000000 --- a/app/views/general/_frontpage_search_examples.es.rhtml +++ /dev/null @@ -1 +0,0 @@ -por ejemplo <a href="/es/search/El%20Geraldine%20Quango">El Geraldine Quango</a>, <a href="/search/fancy%20dog">Fancy Dog</a>. diff --git a/app/views/general/_frontpage_search_examples.rhtml b/app/views/general/_frontpage_search_examples.rhtml deleted file mode 100644 index 359a132e2..000000000 --- a/app/views/general/_frontpage_search_examples.rhtml +++ /dev/null @@ -1 +0,0 @@ -for example <a href="/search/Geraldine%20Quango">Geraldine Quango</a> or <a href="/search/fancy%20dog">Fancy Dog</a>. diff --git a/app/views/general/_stylesheet_includes.rhtml b/app/views/general/_stylesheet_includes.rhtml index 2ffa5dadf..7a03680f8 100644 --- a/app/views/general/_stylesheet_includes.rhtml +++ b/app/views/general/_stylesheet_includes.rhtml @@ -16,6 +16,6 @@ <![endif]--> <!-- the following method for customising CSS is deprecated; see `doc/THEMES.md` for detail --> <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %> - <% if force_registration_on_new_request %> + <% if Configuration::force_registration_on_new_request %> <%= stylesheet_link_tag 'jquery.fancybox-1.3.4', :rel => "stylesheet" %> <% end %> diff --git a/app/views/general/advanced_search.rhtml b/app/views/general/advanced_search.rhtml deleted file mode 100644 index e69de29bb..000000000 --- a/app/views/general/advanced_search.rhtml +++ /dev/null diff --git a/app/views/general/frontpage.rhtml b/app/views/general/frontpage.rhtml index 38133e7ab..e2d74a5e2 100644 --- a/app/views/general/frontpage.rhtml +++ b/app/views/general/frontpage.rhtml @@ -40,7 +40,7 @@ <ul> <% for popular_body in @popular_bodies %> <li><%=public_body_link(popular_body)%> - <%= n_('%d request', '%d requests', popular_body.info_requests.count) % popular_body.info_requests.count %> + <%= n_('%d request', '%d requests', popular_body.info_requests_count) % popular_body.info_requests_count %> </li> <% end%> </ul> @@ -51,20 +51,32 @@ <% end %> <div id="examples_1"> - <h3><%= _("What information has been released?") %></h3> - <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:", + <h3> + <% if @request_events_all_successful %> + <%= _("What information has been released?") %> + <% else %> + <%= _("What information has been requested?") %> + <% end %> + </h3> + <%= _("{{site_name}} users have made {{number_of_requests}} requests, including:", :site_name => site_name, :number_of_requests => InfoRequest.count) %> <ul> <% for event in @request_events %> <li> <%= public_body_link(event.info_request.public_body) %> <%= _('answered a request about') %> - <%=link_to h(event.info_request.title), request_url(event.info_request)%> - <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> + <%=link_to h(event.info_request.title), request_url(event.info_request)%> + <%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(event.described_at)) %> <p class="excerpt" onclick="document.location.href='<%=request_url(event.info_request)%>'"><%= excerpt(event.search_text_main(true), "", 200) %></p> </li> <% end %> </ul> - <p><strong><%=link_to _('More successful requests...'), request_list_successful_url %></strong></p> + <p><strong> + <% if @request_events_all_successful %> + <%=link_to _('More successful requests...'), request_list_successful_url %> + <% else %> + <%=link_to _('More requests...'), request_list_all_url %> + <% end %> + </strong></p> </div> </div> diff --git a/app/views/help/_sidebar.rhtml b/app/views/help/_sidebar.rhtml index 21038e8df..783d35983 100644 --- a/app/views/help/_sidebar.rhtml +++ b/app/views/help/_sidebar.rhtml @@ -8,7 +8,7 @@ <li><%= link_to_unless_current "About the software", "/help/alaveteli" %></li> <li><%= link_to_unless_current "Credits", "/help/credits" %></li> <li><%= link_to_unless_current "Programmers API", "/help/api" %></li> - <li><%= link_to_unless_current "Advanced search", "/search" %></li> + <li><%= link_to_unless_current "Advanced search", "/advancedsearch" %></li> </ul> <h2 id="contact">Contact us</h2> diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.rhtml index dd49f7951..37df68f49 100644 --- a/app/views/help/contact.rhtml +++ b/app/views/help/contact.rhtml @@ -10,27 +10,18 @@ <h2>Contact an authority to get official information</h2> <ul> <li><a href="/new">Go here</a> to make a request, in public, for information - from UK public authorities.</li> + from public authorities.</li> <li> Asking for private information about yourself? - Please read our help page about - <a href="/help/requesting#data_protection">data protection</a>. + Please read our + <a href="/help/requesting#data_protection">help page</a>. </li> </ul> - <h2>Take up an issue with Government</h2> - - <ul> - <li><a href="http://www.writetothem.com">Write to your MP, - local councillor or other representative</a>. - <li><a href="http://www.number10.gov.uk/">Number 10</a> is a good place to start if you would like to take an issue up with central government. </li> - </ul> - - <% end %> - <h2>Contact the WhatDoTheyKnow team</h2> + <h2>Contact the <%= site_name %> team</h2> <% if !flash[:notice] %> <ul> <li> @@ -91,8 +82,7 @@ <p class="form_note"> We can only help you with <strong>technical problems</strong>, or questions - about Freedom of Information. See the top of this page if you would like to - contact the Government. + about Freedom of Information. </P> diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index e4022661f..0dd493fd0 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -42,7 +42,7 @@ <%= render :partial => 'general/before_head_end' %> </head> <body class="<%= 'admin' if is_admin? %> <%= 'front' if params[:action] == 'frontpage' %>"> - <% if force_registration_on_new_request && !@user %> + <% if Configuration::force_registration_on_new_request && !@user %> <%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %> <script type="text/javascript"> $(document).ready(function() { @@ -139,15 +139,13 @@ <input type="text"> </div> <% - ga_code = MySociety::Config.get('GA_CODE', '') - - unless ga_code.empty? %> + unless Configuration::ga_code.empty? %> <script> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script> - var pageTracker = _gat._getTracker("<%=ga_code%>"); + var pageTracker = _gat._getTracker("<%= Configuration::ga_code %>"); pageTracker._trackPageview(); </script> diff --git a/app/views/public_body/_list_sidebar_extra.rhtml b/app/views/public_body/_list_sidebar_extra.rhtml new file mode 100644 index 000000000..6857a7eb5 --- /dev/null +++ b/app/views/public_body/_list_sidebar_extra.rhtml @@ -0,0 +1,6 @@ +<p> + <%= _('<a href="%s">Are we missing a public authority?</a>') % [help_requesting_path + '#missing_body'] %> +</p> +<p> + <%= link_to _('List of all authorities (CSV)'), all_public_bodies_csv_url() %> +</p> diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml index 8cb207bd4..3a64de1f7 100644 --- a/app/views/public_body/list.rhtml +++ b/app/views/public_body/list.rhtml @@ -25,15 +25,10 @@ <% if not first_row %> </ul> <% end %> - <p> - <%= _('<a href="%s">Are we missing a public authority?</a>.') % [help_requesting_path + '#missing_body'] %> - </p> - <p> - <%= link_to _('List of all authorities (CSV)'), all_public_bodies_csv_url() %> - </p> + <%= render :partial => "list_sidebar_extra" %> </div> -<% @title = _("Public authorities - {{description}}", :description => @description) %> +<% @title = @description.empty? ? _("Public authorities") : _("Public authorities - {{description}}", :description => @description) %> <div id="left_column_flip"> <h1><%= _('Public authorities') %></h1> @@ -44,7 +39,7 @@ </div> <% end %> -<h2 class="publicbody_results"><%= _('Found {{count}} public bodies {{description}}', :count=>@public_bodies.total_entries, :description=>@description) %></h2> +<h2 class="publicbody_results"><%= n_('Found %d public authority %s', 'Found %d public authorities %s', @public_bodies.total_entries) % [@public_bodies.total_entries, @description] %></h2> <%= render :partial => 'body_listing', :locals => { :public_bodies => @public_bodies } %> <%= will_paginate(@public_bodies) %><br/> diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml index 63bd5f7fc..b56556d5d 100644 --- a/app/views/public_body/show.rhtml +++ b/app/views/public_body/show.rhtml @@ -64,6 +64,12 @@ <% else %> <%= _('For an unknown reason, it is not possible to make a request to this authority.')%> <% end %> + + <% if @public_body.override_request_email %> + <p> + <%= _("<strong>Note:</strong> Because we're testing, requests are being sent to {{email}} rather than to the actual authority.", :email => @public_body.override_request_email) %> + </p> + <% end %> </div> </div> diff --git a/app/views/request/_sidebar.rhtml b/app/views/request/_sidebar.rhtml index dc0d2eb31..18684943a 100644 --- a/app/views/request/_sidebar.rhtml +++ b/app/views/request/_sidebar.rhtml @@ -31,7 +31,7 @@ <h2><%= _("Act on what you've learnt") %></h2> <div class="act_link"> - <% tweet_link = "https://twitter.com/share?url=#{h(request.url)}&via=#{h(MySociety::Config.get('TWITTER_USERNAME', ''))}&text='#{h(@info_request.title)}'&related=#{_('alaveteli_foi:The software that runs {{site_name}}', :site_name => h(site_name))}" %> + <% tweet_link = "https://twitter.com/share?url=#{h(request.url)}&via=#{h(Configuration::twitter_username)}&text='#{h(@info_request.title)}'&related=#{_('alaveteli_foi:The software that runs {{site_name}}', :site_name => h(site_name))}" %> <%= link_to '<img src="/images/twitter-16.png" alt="twitter icon">', tweet_link %> <%= link_to _("Tweet this request"), tweet_link %> </div> diff --git a/app/views/request/_summary_suggestion.rhtml b/app/views/request/_summary_suggestion.rhtml new file mode 100644 index 000000000..a5da09cda --- /dev/null +++ b/app/views/request/_summary_suggestion.rhtml @@ -0,0 +1,5 @@ +<% if @info_request.law_used == 'eir' %> + <%= _("'Pollution levels over time for the River Tyne'") %> +<% else %> + <%= _("'Crime statistics by ward level for Wales'") %> +<% end %> diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml index 23212fc0b..fe4c2067d 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -86,12 +86,7 @@ </p> <div class="form_item_note"> (<%= _("a one line summary of the information you are requesting, \n\t\t\te.g.") %> - <% if @info_request.law_used == 'eir' %> - <%= _("'Pollution levels over time for the River Tyne'") %> - <% else %> - <%= _("'Crime statistics by ward level for Wales'") %> - <% end %> - ) + <%= render :partial => "summary_suggestion" %>) </div> </div> @@ -121,7 +116,7 @@ will be <strong>displayed publicly</strong> on this website forever (<a href="%s">why?</a>).') % [help_privacy_path+"#public_request"] %> <%= _('If you are thinking of using a pseudonym, - please <a href="%s">read this first</a>.') % [help_privacy_path+"#public_request"] %> + please <a href="%s">read this first</a>.') % [help_privacy_path+"#real_name"] %> </p> <% else %> <p class="form_note"> diff --git a/app/views/request/simple_correspondence.rhtml b/app/views/request/simple_correspondence.rhtml index bcbc795e7..0da9ef172 100644 --- a/app/views/request/simple_correspondence.rhtml +++ b/app/views/request/simple_correspondence.rhtml @@ -1,4 +1,4 @@ -<%= _('This is a plain-text version of the Freedom of Information request "{{request_title}}". The latest, full version is available online at {{full_url}}', :request_title => @info_request.title, :full_url => "http://#{MySociety::Config.get('DOMAIN')}#{show_request_path(:url_title=>@info_request.url_title)}") %>. +<%= _('This is a plain-text version of the Freedom of Information request "{{request_title}}". The latest, full version is available online at {{full_url}}', :request_title => @info_request.title, :full_url => "http://#{Configuration::domain}#{show_request_path(:url_title=>@info_request.url_title)}") %>. <% for info_request_event in @info_request_events %> <% diff --git a/app/views/request/upload_response.rhtml b/app/views/request/upload_response.rhtml index 697ff99aa..bc129426d 100644 --- a/app/views/request/upload_response.rhtml +++ b/app/views/request/upload_response.rhtml @@ -43,7 +43,7 @@ <p> <%= hidden_field_tag 'submitted_upload_response', 1 %> - <%= submit_tag "Upload FOI response" %> + <%= submit_tag _("Upload FOI response") %> <%= _(' (<strong>patience</strong>, especially for large files, it may take a while!)')%> </p> <% end %> diff --git a/app/views/user/_signin.rhtml b/app/views/user/_signin.rhtml index 4fe98ee41..c4d917991 100644 --- a/app/views/user/_signin.rhtml +++ b/app/views/user/_signin.rhtml @@ -9,27 +9,27 @@ <p> <label class="form_label" for="user_signin_email"><%= _('Your e-mail:')%></label> - <%= text_field 'user_signin', 'email', { :size => 20 } %> + <%= text_field 'user_signin', 'email', { :size => 20, :tabindex => 10 } %> </p> <p> <label class="form_label" for="user_signin_password"><%= _('Password:')%></label> - <%= password_field 'user_signin', 'password', { :size => 15 } %> + <%= password_field 'user_signin', 'password', { :size => 15, :tabindex => 20 } %> </p> <p class="form_note"> - <%= link_to _('Forgotten your password?'), signchangepassword_url + "?pretoken=" + h(params[:token]) %> + <%= link_to _('Forgotten your password?'), signchangepassword_url + "?pretoken=" + h(params[:token]), :tabindex => 30 %> </p> <p class="form_checkbox"> - <%= check_box_tag 'remember_me', "1" %> + <%= check_box_tag 'remember_me', "1", false, :tabindex => 40 %> <label for="remember_me"><%= _('Remember me</label> (keeps you signed in longer; do not use on a public computer) ')%></p> <div class="form_button"> <%= hidden_field_tag 'token', params[:token], {:id => 'signin_token' } %> <%= hidden_field_tag :modal, params[:modal], {:id => 'signin_modal' } %> - <%= submit_tag _('Sign in') %> + <%= submit_tag _('Sign in'), :tabindex => 50 %> </div> <% end %> diff --git a/app/views/user/_signup.rhtml b/app/views/user/_signup.rhtml index 9c0132f26..bb93b9617 100644 --- a/app/views/user/_signup.rhtml +++ b/app/views/user/_signup.rhtml @@ -7,7 +7,7 @@ <p> <label class="form_label" for="user_signup_email"><%= _('Your e-mail:')%></label> - <%= text_field 'user_signup', 'email', { :size => 20 } %> + <%= text_field 'user_signup', 'email', { :size => 20, :tabindex => 60 } %> </p> <div class="form_item_note"> <%= _('We will not reveal your email address to anybody unless you or @@ -16,7 +16,7 @@ <p> <label class="form_label" for="user_signup_name"> <%= _('Your name:')%></label> - <%= text_field 'user_signup', 'name', { :size => 20 } %> + <%= text_field 'user_signup', 'name', { :size => 20, :tabindex => 70 } %> </p> <div class="form_item_note"> <%= _('Your <strong>name will appear publicly</strong> @@ -28,12 +28,12 @@ <p> <label class="form_label" for="user_signup_password"> <%= _('Password:')%></label> - <%= password_field 'user_signup', 'password', { :size => 15 } %> + <%= password_field 'user_signup', 'password', { :size => 15, :tabindex => 80 } %> </p> <p> <label class="form_label" for="user_signup_password_confirmation"> <%= _('Password: (again)')%></label> - <%= password_field 'user_signup', 'password_confirmation', { :size => 15 } %> + <%= password_field 'user_signup', 'password_confirmation', { :size => 15, :tabindex => 90 } %> </p> <% if @request_from_foreign_country %> @@ -43,7 +43,7 @@ <div class="form_button"> <%= hidden_field_tag 'token', params[:token], {:id => 'signup_token' } %> <%= hidden_field_tag :modal, params[:modal], {:id => 'signup_modal' } %> - <%= submit_tag _('Sign up') %> + <%= submit_tag _('Sign up'), :tabindex => 100 %> </div> <% end %> diff --git a/app/views/user/rate_limited.rhtml b/app/views/user/rate_limited.rhtml index d5accf114..d52deebab 100644 --- a/app/views/user/rate_limited.rhtml +++ b/app/views/user/rate_limited.rhtml @@ -2,7 +2,7 @@ <h1><%=@title%></h1> -<p><%= _("You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}.", :max_requests_per_user_per_day => MySociety::Config.get("MAX_REQUESTS_PER_USER_PER_DAY"), :can_make_another_request => distance_of_time_in_words(Time.now, @next_request_permitted_at))%></p> +<p><%= _("You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}.", :max_requests_per_user_per_day => Configuration::max_requests_per_user_per_day, :can_make_another_request => distance_of_time_in_words(Time.now, @next_request_permitted_at))%></p> <p><%= _("There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please <a href='{{help_contact_path}}'>get in touch</a>.", :help_contact_path => help_contact_path) %></p> diff --git a/app/views/user/set_profile_about_me.rhtml b/app/views/user/set_profile_about_me.rhtml index 8d8b32758..4fe1047da 100644 --- a/app/views/user/set_profile_about_me.rhtml +++ b/app/views/user/set_profile_about_me.rhtml @@ -26,7 +26,7 @@ <%= _(' Include relevant links, such as to a campaign page, your blog or a twitter account. They will be made clickable. e.g.')%> - <a href="https://twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %>">https://twitter.com/<%= MySociety::Config.get('TWITTER_USERNAME') %></a> + <a href="https://twitter.com/<%= Configuration::twitter_username %>">https://twitter.com/<%= Configuration::twitter_username %></a> </p> </div> |