diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/comment.rb | 5 | ||||
-rw-r--r-- | app/models/info_request.rb | 13 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 6 |
3 files changed, 20 insertions, 4 deletions
diff --git a/app/models/comment.rb b/app/models/comment.rb index 250b94c20..af6a4f9ef 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -19,7 +19,7 @@ # Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: comment.rb,v 1.16 2009-06-26 14:28:37 francis Exp $ +# $Id: comment.rb,v 1.17 2009-08-18 20:51:26 francis Exp $ class Comment < ActiveRecord::Base strip_attributes! @@ -58,6 +58,9 @@ class Comment < ActiveRecord::Base if self.body.empty? || self.body =~ /^\s+$/ errors.add(:body, "^Please enter your annotation") end + if !MySociety::Validate.uses_mixed_capitals(self.body) + errors.add(:body, '^Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.') + end end # Return body for display as HTML diff --git a/app/models/info_request.rb b/app/models/info_request.rb index dfa66102e..13d5c8a2e 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -24,7 +24,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.198 2009-07-03 11:43:37 francis Exp $ +# $Id: info_request.rb,v 1.199 2009-08-18 20:51:26 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -279,6 +279,17 @@ public end end + def find_existing_outgoing_message(body) + # XXX can add other databases here which have regexp_replace + if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" + # Exclude spaces from the body comparison using regexp_replace + return self.outgoing_messages.find(:first, :conditions => [ "regexp_replace(outgoing_messages.body, '[[:space:]]', '', 'g') = regexp_replace(?, '[[:space:]]', '', 'g')", body ]) + else + # For other databases (e.g. SQLite) not the end of the world being space-sensitive for this check + return self.outgoing_messages.find(:first, :conditions => [ "outgoing_messages.body = ?", body ]) + end + end + # A new incoming email to this request def receive(email, raw_email_data, override_stop_new_responses = false) if !override_stop_new_responses diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 6d1900d64..28701185a 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -22,7 +22,7 @@ # 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.87 2009-07-21 12:09:30 francis Exp $ +# $Id: outgoing_message.rb,v 1.88 2009-08-18 20:51:26 francis Exp $ class OutgoingMessage < ActiveRecord::Base strip_attributes! @@ -129,8 +129,10 @@ class OutgoingMessage < ActiveRecord::Base if self.body =~ /#{get_signoff}\s*\Z/ms errors.add(:body, '^Please sign at the bottom with your name, or alter the "' + get_signoff + '" signature') 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.') + end if self.what_doing.nil? || !['new_information', 'internal_review', 'normal_sort'].include?(self.what_doing) - errors.add(:what_doing_dummy, '^Please choose what sort of reply you are making.') end end |