aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-04-24 16:01:39 +0100
committerLouise Crow <louise.crow@gmail.com>2013-04-24 16:01:39 +0100
commitd3eec6f983f8524e28e8ffe42ba3a10efaa0a30e (patch)
tree4c9cd3a9709a18a46d179e4af63bc7bcfa117b66 /app/models
parentcc3da49bc927175a49d7150b98d762f65e143d21 (diff)
parentd3aae5cc48c92473e06b2104bb9431305d5a92f0 (diff)
Merge branch 'release/0.9' into rails-3-develop
Conflicts: Gemfile.lock app/controllers/public_body_controller.rb app/mailers/track_mailer.rb app/views/request/_hidden_correspondence.html.erb app/views/request/_sidebar.html.erb app/views/request/hidden.html.erb app/views/request/new_please_describe.html.erb app/views/request/preview.html.erb app/views/user/show.html.erb config/environment.rb config/routes.rb spec/controllers/public_body_controller_spec.rb
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request.rb11
-rw-r--r--app/models/outgoing_message.rb2
-rw-r--r--app/models/profile_photo.rb2
3 files changed, 13 insertions, 2 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 156399b99..cf1af0e87 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -478,6 +478,17 @@ public
incoming_message = IncomingMessage.new
ActiveRecord::Base.transaction do
+
+ # To avoid a deadlock when simultaneously dealing with two
+ # incoming emails that refer to the same InfoRequest, we
+ # lock the row for update. In Rails 3.2.0 and later this
+ # can be done with info_request.with_lock or
+ # info_request.lock!, but upgrading to that version of
+ # Rails creates many other problems at the moment. In the
+ # interim, just use raw SQL to do the SELECT ... FOR UPDATE
+ raw_sql = "SELECT * FROM info_requests WHERE id = #{self.id} LIMIT 1 FOR UPDATE"
+ ActiveRecord::Base.connection.execute(raw_sql)
+
raw_email = RawEmail.new
incoming_message.raw_email = raw_email
incoming_message.info_request = self
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index 11711090e..dbe2cf1ca 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -269,7 +269,7 @@ class OutgoingMessage < ActiveRecord::Base
end
end
if self.body =~ /#{get_signoff}\s*\Z/m
- errors.add(:body, _("Please sign at the bottom with your name, or alter the \"%{signoff}\" signature" % { :signoff => get_signoff }))
+ errors.add(:body, _("Please sign at the bottom with your name, or alter the \"{{signoff}}\" signature", :signoff => get_signoff))
end
if !MySociety::Validate.uses_mixed_capitals(self.body)
errors.add(:body, _('Please write your message using a mixture of capital and lower case letters. This makes it easier for others to read.'))
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index 8a6fe1636..5d542daf1 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -85,7 +85,7 @@ class ProfilePhoto < ActiveRecord::Base
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, 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))
end
if self.draft && self.user_id