aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/change_email_validator.rb12
-rw-r--r--app/models/comment.rb6
-rw-r--r--app/models/incoming_message.rb6
-rw-r--r--app/models/public_body_category.rb7
-rw-r--r--app/models/public_body_category_link.rb2
-rw-r--r--app/models/public_body_heading.rb6
6 files changed, 26 insertions, 13 deletions
diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb
index 7ee6654bb..65f2fd81c 100644
--- a/app/models/change_email_validator.rb
+++ b/app/models/change_email_validator.rb
@@ -55,10 +55,20 @@ class ChangeEmailValidator
def check_email_is_present_and_valid(email)
if !send(email).blank? && !MySociety::Validate.is_valid_email(send(email))
- errors.add(email, _("#{ email.to_s.humanize } doesn't look like a valid address"))
+ msg_string = check_email_is_present_and_valid_msg_string(email)
+ errors.add(email, msg_string)
end
end
+ def check_email_is_present_and_valid_msg_string(email)
+ case email.to_sym
+ when :old_email then _("Old email doesn't look like a valid address")
+ when :new_email then _("New email doesn't look like a valid address")
+ else
+ raise "Unsupported email type #{ email }"
+ end
+ end
+
def email_belongs_to_user?(email)
email.downcase == logged_in_user.email.downcase
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index a286aa1f5..cc8d0e94b 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -91,9 +91,9 @@ class Comment < ActiveRecord::Base
def check_body_uses_mixed_capitals
unless MySociety::Validate.uses_mixed_capitals(body)
- msg = 'Please write your annotation using a mixture of capital and ' \
- 'lower case letters. This makes it easier for others to read.'
- errors.add(:body, _(msg))
+ msg = _('Please write your annotation using a mixture of capital and ' \
+ 'lower case letters. This makes it easier for others to read.')
+ errors.add(:body, msg)
end
end
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 135a6bdaf..db6722976 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -693,8 +693,10 @@ class IncomingMessage < ActiveRecord::Base
self.reload
# get the main body part from the set of attachments we just created,
- # not from the self.foi_attachments association - some of the total set of
- # self.foi_attachments may now be obsolete
+ # not from the self.foi_attachments association - some of the total set
+ # of self.foi_attachments may now be obsolete. Sometimes (e.g. when
+ # parsing mail from Apple Mail) we can end up with less attachments
+ # because the hexdigest of an attachment is identical.
main_part = get_main_body_text_part(attachments)
# we don't use get_main_body_text_internal, as we want to avoid charset
# conversions, since /usr/bin/uudecode needs to deal with those.
diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb
index 8eaecd596..bb83c4c82 100644
--- a/app/models/public_body_category.rb
+++ b/app/models/public_body_category.rb
@@ -19,9 +19,10 @@ class PublicBodyCategory < ActiveRecord::Base
has_many :public_body_headings, :through => :public_body_category_links
translates :title, :description
- validates_uniqueness_of :category_tag, :message => N_('Tag is already taken')
- validates_presence_of :title, :message => N_("Title can't be blank")
- validates_presence_of :category_tag, :message => N_("Tag can't be blank")
+ validates_uniqueness_of :category_tag, :message => 'Tag is already taken'
+ validates_presence_of :title, :message => "Title can't be blank"
+ validates_presence_of :category_tag, :message => "Tag can't be blank"
+ validates_presence_of :description, :message => "Description can't be blank"
def self.get
locale = I18n.locale.to_s || default_locale.to_s || ""
diff --git a/app/models/public_body_category_link.rb b/app/models/public_body_category_link.rb
index eb233b56f..ba3ff1f95 100644
--- a/app/models/public_body_category_link.rb
+++ b/app/models/public_body_category_link.rb
@@ -15,7 +15,7 @@ class PublicBodyCategoryLink < ActiveRecord::Base
validates_presence_of :public_body_category
validates_presence_of :public_body_heading
validates :category_display_order, :numericality => { :only_integer => true,
- :message => N_('Display order must be a number') }
+ :message => 'Display order must be a number' }
before_validation :on => :create do
unless self.category_display_order
diff --git a/app/models/public_body_heading.rb b/app/models/public_body_heading.rb
index c38800561..f1916d233 100644
--- a/app/models/public_body_heading.rb
+++ b/app/models/public_body_heading.rb
@@ -16,10 +16,10 @@ class PublicBodyHeading < ActiveRecord::Base
translates :name
- validates_uniqueness_of :name, :message => N_('Name is already taken')
- validates_presence_of :name, :message => N_('Name can\'t be blank')
+ validates_uniqueness_of :name, :message => 'Name is already taken'
+ validates_presence_of :name, :message => 'Name can\'t be blank'
validates :display_order, :numericality => { :only_integer => true,
- :message => N_('Display order must be a number') }
+ :message => 'Display order must be a number' }
before_validation :on => :create do
unless self.display_order