From dfaf83616cc8f32d2a2341fddcbb726eb597de39 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Sat, 16 Nov 2013 20:24:53 +0000 Subject: [PATCH] Fixed error messages --- app/models/category.rb | 6 +++--- app/models/comment.rb | 2 +- app/models/create_enterprise.rb | 4 ++-- app/models/domain.rb | 4 ++-- app/models/event.rb | 2 +- app/models/image.rb | 2 +- app/models/person.rb | 2 +- app/models/uploaded_file.rb | 2 +- app/models/user.rb | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/models/category.rb b/app/models/category.rb index 885a19f..991278c 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -7,13 +7,13 @@ class Category < ActiveRecord::Base :slug => 1, } - validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('%{fn} cannot be like that.').fix_i18n + validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('{fn} cannot be like that.').fix_i18n validates_presence_of :name, :environment_id - validates_uniqueness_of :slug,:scope => [ :environment_id, :parent_id ], :message => N_('%{fn} is already being used by another category.').fix_i18n + validates_uniqueness_of :slug,:scope => [ :environment_id, :parent_id ], :message => N_('{fn} is already being used by another category.').fix_i18n belongs_to :environment validates_inclusion_of :display_color, :in => [ 1, 2, 3, 4, nil ] - validates_uniqueness_of :display_color, :scope => :environment_id, :if => (lambda { |cat| ! cat.display_color.nil? }), :message => N_('%{fn} was already assigned to another category.').fix_i18n + validates_uniqueness_of :display_color, :scope => :environment_id, :if => (lambda { |cat| ! cat.display_color.nil? }), :message => N_('{fn} was already assigned to another category.').fix_i18n # Finds all top level categories for a given environment. named_scope :top_level_for, lambda { |environment| diff --git a/app/models/comment.rb b/app/models/comment.rb index f5dd826..17c75a3 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -29,7 +29,7 @@ class Comment < ActiveRecord::Base validates_presence_of :author_id, :if => (lambda { |rec| rec.name.blank? && rec.email.blank? }) validates_each :name do |rec,attribute,value| if rec.author_id && (!rec.name.blank? || !rec.email.blank?) - rec.errors.add(:name, _('%{fn} can only be informed for unauthenticated authors').fix_i18n) + rec.errors.add(:name, _('{fn} can only be informed for unauthenticated authors').fix_i18n) end end diff --git a/app/models/create_enterprise.rb b/app/models/create_enterprise.rb index df11e4b..1afc10a 100644 --- a/app/models/create_enterprise.rb +++ b/app/models/create_enterprise.rb @@ -40,12 +40,12 @@ class CreateEnterprise < Task if self.region && self.target unless self.region.validators.include?(self.target) || self.target_type == "Environment" - self.errors.add(:target, _('%{fn} is not a validator for the chosen region').fix_i18n) + self.errors.add(:target, _('{fn} is not a validator for the chosen region').fix_i18n) end end if self.status != Task::Status::CANCELLED && self.identifier && Profile.exists?(:identifier => self.identifier) - self.errors.add(:identifier, _('%{fn} is already being as identifier by another enterprise, organization or person.').fix_i18n) + self.errors.add(:identifier, _('{fn} is already being as identifier by another enterprise, organization or person.').fix_i18n) end end diff --git a/app/models/domain.rb b/app/models/domain.rb index 9b89c61..d5ddf00 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -10,14 +10,14 @@ class Domain < ActiveRecord::Base # name must be sequences of alphanumeric characters (a to z, # 0 to 9), plus '_' or '-', separated by dots. Letters must be lowercase. - validates_format_of :name, :with => /^([a-z0-9_-]+\.)+[a-z0-9_-]+$/, :message => N_('%{fn} must be composed of sequences of lowercase letters (a to z), numbers (0 to 9), "_" and "-", separated by dots.').fix_i18n + validates_format_of :name, :with => /^([a-z0-9_-]+\.)+[a-z0-9_-]+$/, :message => N_('{fn} must be composed of sequences of lowercase letters (a to z), numbers (0 to 9), "_" and "-", separated by dots.').fix_i18n # checks validations that could not be expressed using Rails' predefined # validations. In particular: # * name must not start with 'www.' def validate if self.name =~ /^www\./ - self.errors.add(:name, _('%{fn} must not start with www.').fix_i18n) + self.errors.add(:name, _('{fn} must not start with www.').fix_i18n) end end diff --git a/app/models/event.rb b/app/models/event.rb index 712a4cd..72baea1 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -25,7 +25,7 @@ class Event < Article validates_each :start_date do |event,field,value| if event.end_date && event.start_date && event.start_date > event.end_date - event.errors.add(:start_date, _('%{fn} cannot come before end date.').fix_i18n) + event.errors.add(:start_date, _('{fn} cannot come before end date.').fix_i18n) end end diff --git a/app/models/image.rb b/app/models/image.rb index e0b953d..cbef186 100644 --- a/app/models/image.rb +++ b/app/models/image.rb @@ -17,7 +17,7 @@ class Image < ActiveRecord::Base :icon => '20x20!' }, :max_size => 5.megabytes # remember to update validate message below - validates_attachment :size => N_("%{fn} of uploaded file was larger than the maximum size of 5.0 MB").fix_i18n + validates_attachment :size => N_("{fn} of uploaded file was larger than the maximum size of 5.0 MB").fix_i18n delay_attachment_fu_thumbnails diff --git a/app/models/person.rb b/app/models/person.rb index 8729394..8358188 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -240,7 +240,7 @@ class Person < Profile validates_each :email, :on => :update do |record,attr,value| if User.find(:first, :conditions => ['email = ? and id != ? and environment_id = ?', value, record.user.id, record.environment.id]) - record.errors.add(attr, _('%{fn} is already used by other user').fix_i18n) + record.errors.add(attr, _('{fn} is already used by other user').fix_i18n) end end diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index 5be009e..ef6e5be 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -54,7 +54,7 @@ class UploadedFile < Article :thumbnail_class => Thumbnail, :max_size => 5.megabytes # remember to update validate message below - validates_attachment :size => N_("%{fn} of uploaded file was larger than the maximum size of 5.0 MB").fix_i18n + validates_attachment :size => N_("{fn} of uploaded file was larger than the maximum size of 5.0 MB").fix_i18n delay_attachment_fu_thumbnails diff --git a/app/models/user.rb b/app/models/user.rb index fd5d7aa..323ae22 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,7 +114,7 @@ class User < ActiveRecord::Base before_save :encrypt_password validates_format_of :email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda {|user| !user.email.blank?}) - validates_inclusion_of :terms_accepted, :in => [ '1' ], :if => lambda { |u| ! u.terms_of_use.blank? }, :message => N_('%{fn} must be checked in order to signup.').fix_i18n + validates_inclusion_of :terms_accepted, :in => [ '1' ], :if => lambda { |u| ! u.terms_of_use.blank? }, :message => N_('{fn} must be checked in order to signup.').fix_i18n # Authenticates a user by their login name or email and unencrypted password. Returns the user or nil. def self.authenticate(login, password, environment = nil) -- libgit2 0.21.2