aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/application_mailer.rb2
-rw-r--r--app/models/contact_mailer.rb2
-rw-r--r--app/models/exim_log.rb2
-rw-r--r--app/models/incoming_message.rb9
-rw-r--r--app/models/info_request.rb19
-rw-r--r--app/models/outgoing_mailer.rb6
-rw-r--r--app/models/outgoing_message.rb2
-rw-r--r--app/models/public_body.rb2
-rw-r--r--app/models/raw_email.rb3
-rw-r--r--app/models/request_mailer.rb4
-rw-r--r--app/models/track_mailer.rb4
-rw-r--r--app/models/track_thing.rb2
-rw-r--r--app/models/user.rb15
13 files changed, 30 insertions, 42 deletions
diff --git a/app/models/application_mailer.rb b/app/models/application_mailer.rb
index 044006f7c..3a11733a8 100644
--- a/app/models/application_mailer.rb
+++ b/app/models/application_mailer.rb
@@ -16,7 +16,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),
diff --git a/app/models/contact_mailer.rb b/app/models/contact_mailer.rb
index 6e781d48c..adeac8eac 100644
--- a/app/models/contact_mailer.rb
+++ b/app/models/contact_mailer.rb
@@ -52,7 +52,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/exim_log.rb b/app/models/exim_log.rb
index 82000efa1..e1861150f 100644
--- a/app/models/exim_log.rb
+++ b/app/models/exim_log.rb
@@ -63,7 +63,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/incoming_message.rb b/app/models/incoming_message.rb
index 13fc316cd..f3844a153 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -253,7 +253,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 +279,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 +376,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)
@@ -649,7 +648,7 @@ class IncomingMessage < ActiveRecord::Base
begin
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 141440c6d..85168e6d4 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -689,23 +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)
- working_or_calendar_days = MySociety::Config.get('WORKING_OR_CALENDAR_DAYS', 'working')
- return Holiday.due_date_from(self.date_initial_request_last_sent_at, days_later, working_or_calendar_days)
+ 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)
- working_or_calendar_days = MySociety::Config.get('WORKING_OR_CALENDAR_DAYS', 'working')
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, school_very_late_days_later, working_or_calendar_days)
+ 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, very_late_days_later, working_or_calendar_days)
+ Holiday.due_date_from(self.date_initial_request_last_sent_at, Configuration::reply_very_late_after_days, Configuration::working_or_calendar_days)
end
end
@@ -905,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
@@ -919,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
@@ -1143,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/outgoing_mailer.rb b/app/models/outgoing_mailer.rb
index 8562c5b68..2e5e9c6ae 100644
--- a/app/models/outgoing_mailer.rb
+++ b/app/models/outgoing_mailer.rb
@@ -24,7 +24,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 +36,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 +91,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..cb2f1efdc 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -87,7 +87,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/public_body.rb b/app/models/public_body.rb
index 2cf1ce8a2..e9a90bce3 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 => "",
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb
index 3bb794684..c7b8eb017 100644
--- a/app/models/raw_email.rb
+++ b/app/models/raw_email.rb
@@ -28,8 +28,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..4316a9be9 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -55,7 +55,7 @@ class RequestMailer < ApplicationMailer
: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
@@ -303,7 +303,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..6e2dd5109 100644
--- a/app/models/track_mailer.rb
+++ b/app/models/track_mailer.rb
@@ -27,9 +27,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..9a553b382 100644
--- a/app/models/track_thing.rb
+++ b/app/models/track_thing.rb
@@ -253,7 +253,7 @@ class TrackThing < ActiveRecord::Base
: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
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