aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/incoming_message.rb4
-rw-r--r--app/models/info_request.rb8
-rw-r--r--app/models/profile_photo.rb12
-rw-r--r--app/models/public_body.rb34
4 files changed, 37 insertions, 21 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index bcf0b6ec9..59e61952e 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -385,6 +385,10 @@ class IncomingMessage < ActiveRecord::Base
multiline_original_message = '(' + '''>>>.* \d\d/\d\d/\d\d\d\d\s+\d\d:\d\d(?::\d\d)?\s*>>>''' + ')'
text.gsub!(/^(#{multiline_original_message}\n.*)$/m, replacement)
+ # On Thu, Nov 28, 2013 at 9:08 AM, A User
+ # <[1]request-7-skm40s2ls@xxx.xxxx> wrote:
+ text.gsub!(/^( On [^\n]+\n\s*\<[^>\n]+\> (wrote|said):\s*\n.*)$/m, replacement)
+
# Single line sections
text.gsub!(/^(>.*\n)/, replacement)
text.gsub!(/^(On .+ (wrote|said):\n)/, replacement)
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 4624cefaf..eadb66d54 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -113,8 +113,12 @@ class InfoRequest < ActiveRecord::Base
# Possible reasons that a request could be reported for administrator attention
def report_reasons
- ["Contains defamatory material", "Not a valid request", "Request for personal information",
- "Contains personal information", "Vexatious", "Other"]
+ [_("Contains defamatory material"),
+ _("Not a valid request"),
+ _("Request for personal information"),
+ _("Contains personal information"),
+ _("Vexatious"),
+ _("Other")]
end
def must_be_valid_state
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index 322ebe53c..6c3b2cfa0 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -70,21 +70,25 @@ class ProfilePhoto < ActiveRecord::Base
def data_and_draft_checks
if self.data.nil?
- errors.add(:data, N_("Please choose a file containing your photo."))
+ errors.add(:data, _("Please choose a file containing your photo."))
return
end
if self.image.nil?
- errors.add(:data, N_("Couldn't understand the image file that you uploaded. PNG, JPEG, GIF and many other common image file formats are supported."))
+ errors.add(:data, _("Couldn't understand the image file that you uploaded. PNG, JPEG, GIF and many other common image file formats are supported."))
return
end
if self.image.format != 'PNG'
- errors.add(:data, N_("Failed to convert image to a PNG"))
+ errors.add(:data, _("Failed to convert image to a PNG"))
end
if !self.draft && (self.image.columns != WIDTH || self.image.rows != HEIGHT)
- errors.add(:data, N_("Failed to convert image to the correct size: at {{cols}}x{{rows}}, need {{width}}x{{height}}", :cols => self.image.columns, :rows => self.image.rows, :width => WIDTH, :height => HEIGHT))
+ errors.add(:data, _("Failed to convert image to the correct size: at {{cols}}x{{rows}}, need {{width}}x{{height}}",
+ :cols => self.image.columns,
+ :rows => self.image.rows,
+ :width => WIDTH,
+ :height => HEIGHT))
end
if self.draft && self.user_id
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 933825d2a..a78a6677e 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -346,22 +346,26 @@ class PublicBody < ActiveRecord::Base
# The "internal admin" is a special body for internal use.
def PublicBody.internal_admin_body
- I18n.with_locale(I18n.default_locale) do
- pb = PublicBody.find_by_url_name("internal_admin_authority")
- if pb.nil?
- pb = PublicBody.new(
- :name => 'Internal admin authority',
- :short_name => "",
- :request_email => AlaveteliConfiguration::contact_email,
- :home_page => "",
- :notes => "",
- :publication_scheme => "",
- :last_edit_editor => "internal_admin",
- :last_edit_comment => "Made by PublicBody.internal_admin_body"
- )
- pb.save!
+ # Use find_by_sql to avoid the search being specific to a
+ # locale, since url_name is a translated field:
+ sql = "SELECT * FROM public_bodies WHERE url_name = 'internal_admin_authority'"
+ matching_pbs = PublicBody.find_by_sql sql
+ case
+ when matching_pbs.empty? then
+ I18n.with_locale(I18n.default_locale) do
+ PublicBody.create!(:name => 'Internal admin authority',
+ :short_name => "",
+ :request_email => AlaveteliConfiguration::contact_email,
+ :home_page => "",
+ :notes => "",
+ :publication_scheme => "",
+ :last_edit_editor => "internal_admin",
+ :last_edit_comment => "Made by PublicBody.internal_admin_body")
end
- return pb
+ when matching_pbs.length == 1 then
+ matching_pbs[0]
+ else
+ raise "Multiple public bodies (#{matching_pbs.length}) found with url_name 'internal_admin_authority'"
end
end