summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/changeset.rb2
-rw-r--r--app/models/custom_field.rb6
-rw-r--r--app/models/custom_value.rb16
-rw-r--r--app/models/issue.rb8
-rw-r--r--app/models/issue_relation.rb6
-rw-r--r--app/models/mail_handler.rb5
-rw-r--r--app/models/mailer.rb1
-rw-r--r--app/models/member.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/query.rb6
-rw-r--r--app/models/repository.rb2
-rw-r--r--app/models/time_entry.rb10
-rw-r--r--app/models/version.rb2
-rw-r--r--app/models/watcher.rb2
-rw-r--r--app/models/wiki_page.rb6
15 files changed, 40 insertions, 36 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 0824a980e..e29de363b 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -109,7 +109,7 @@ class Changeset < ActiveRecord::Base
if self.scmid && (! (csettext =~ /^r[0-9]+$/))
csettext = "commit:\"#{self.scmid}\""
end
- journal = issue.init_journal(user || User.anonymous, l(:text_status_changed_by_changeset, csettext))
+ journal = issue.init_journal(user || User.anonymous, ll(Setting.default_language, :text_status_changed_by_changeset, csettext))
issue.status = fix_status
issue.done_ratio = done_ratio if done_ratio
issue.save
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index f277dc349..5160fcf8a 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -48,14 +48,14 @@ class CustomField < ActiveRecord::Base
def validate
if self.field_format == "list"
- errors.add(:possible_values, :activerecord_error_blank) if self.possible_values.nil? || self.possible_values.empty?
- errors.add(:possible_values, :activerecord_error_invalid) unless self.possible_values.is_a? Array
+ errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
+ errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
end
# validate default value
v = CustomValue.new(:custom_field => self.clone, :value => default_value, :customized => nil)
v.custom_field.is_required = false
- errors.add(:default_value, :activerecord_error_invalid) unless v.valid?
+ errors.add(:default_value, :invalid) unless v.valid?
end
# Makes possible_values accept a multiline string
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb
index 1f662baa7..2d7d1cffe 100644
--- a/app/models/custom_value.rb
+++ b/app/models/custom_value.rb
@@ -45,22 +45,22 @@ class CustomValue < ActiveRecord::Base
protected
def validate
if value.blank?
- errors.add(:value, :activerecord_error_blank) if custom_field.is_required? and value.blank?
+ errors.add(:value, :blank) if custom_field.is_required? and value.blank?
else
- errors.add(:value, :activerecord_error_invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
- errors.add(:value, :activerecord_error_too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length
- errors.add(:value, :activerecord_error_too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
+ errors.add(:value, :invalid) unless custom_field.regexp.blank? or value =~ Regexp.new(custom_field.regexp)
+ errors.add(:value, :too_short) if custom_field.min_length > 0 and value.length < custom_field.min_length
+ errors.add(:value, :too_long) if custom_field.max_length > 0 and value.length > custom_field.max_length
# Format specific validations
case custom_field.field_format
when 'int'
- errors.add(:value, :activerecord_error_not_a_number) unless value =~ /^[+-]?\d+$/
+ errors.add(:value, :not_a_number) unless value =~ /^[+-]?\d+$/
when 'float'
- begin; Kernel.Float(value); rescue; errors.add(:value, :activerecord_error_invalid) end
+ begin; Kernel.Float(value); rescue; errors.add(:value, :invalid) end
when 'date'
- errors.add(:value, :activerecord_error_not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/
+ errors.add(:value, :not_a_date) unless value =~ /^\d{4}-\d{2}-\d{2}$/
when 'list'
- errors.add(:value, :activerecord_error_inclusion) unless custom_field.possible_values.include?(value)
+ errors.add(:value, :inclusion) unless custom_field.possible_values.include?(value)
end
end
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 46a28708d..3a278a759 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -129,20 +129,20 @@ class Issue < ActiveRecord::Base
def validate
if self.due_date.nil? && @attributes['due_date'] && !@attributes['due_date'].empty?
- errors.add :due_date, :activerecord_error_not_a_date
+ errors.add :due_date, :not_a_date
end
if self.due_date and self.start_date and self.due_date < self.start_date
- errors.add :due_date, :activerecord_error_greater_than_start_date
+ errors.add :due_date, :greater_than_start_date
end
if start_date && soonest_start && start_date < soonest_start
- errors.add :start_date, :activerecord_error_invalid
+ errors.add :start_date, :invalid
end
end
def validate_on_create
- errors.add :tracker_id, :activerecord_error_invalid unless project.trackers.include?(tracker)
+ errors.add :tracker_id, :invalid unless project.trackers.include?(tracker)
end
def before_create
diff --git a/app/models/issue_relation.rb b/app/models/issue_relation.rb
index 13e14cccc..d26292c37 100644
--- a/app/models/issue_relation.rb
+++ b/app/models/issue_relation.rb
@@ -39,9 +39,9 @@ class IssueRelation < ActiveRecord::Base
def validate
if issue_from && issue_to
- errors.add :issue_to_id, :activerecord_error_invalid if issue_from_id == issue_to_id
- errors.add :issue_to_id, :activerecord_error_not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
- errors.add_to_base :activerecord_error_circular_dependency if issue_to.all_dependent_issues.include? issue_from
+ errors.add :issue_to_id, :invalid if issue_from_id == issue_to_id
+ errors.add :issue_to_id, :not_same_project unless issue_from.project_id == issue_to.project_id || Setting.cross_project_issue_relations?
+ errors.add_to_base :circular_dependency if issue_to.all_dependent_issues.include? issue_from
end
end
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 8e19bcdf4..8d73f0d6e 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -236,4 +236,9 @@ class MailHandler < ActionMailer::Base
end
@plain_text_body.strip!
end
+
+
+ def self.full_sanitizer
+ @full_sanitizer ||= HTML::FullSanitizer.new
+ end
end
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index c8deeffbd..7560e53b5 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -21,6 +21,7 @@ class Mailer < ActionMailer::Base
helper :custom_fields
include ActionController::UrlWriter
+ include Redmine::I18n
def issue_add(issue)
redmine_headers 'Project' => issue.project.identifier,
diff --git a/app/models/member.rb b/app/models/member.rb
index b4617c229..0f644dbe7 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -24,7 +24,7 @@ class Member < ActiveRecord::Base
validates_uniqueness_of :user_id, :scope => :project_id
def validate
- errors.add :role_id, :activerecord_error_invalid if role && !role.member?
+ errors.add :role_id, :invalid if role && !role.member?
end
def name
diff --git a/app/models/project.rb b/app/models/project.rb
index e4db6d867..980d194b1 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -306,7 +306,7 @@ class Project < ActiveRecord::Base
protected
def validate
- errors.add(:identifier, :activerecord_error_invalid) if !identifier.blank? && identifier.match(/^\d*$/)
+ errors.add(:identifier, :invalid) if !identifier.blank? && identifier.match(/^\d*$/)
end
private
diff --git a/app/models/query.rb b/app/models/query.rb
index 23742cfa5..84e127b6b 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -17,7 +17,7 @@
class QueryColumn
attr_accessor :name, :sortable, :default_order
- include GLoc
+ include Redmine::I18n
def initialize(name, options={})
self.name = name
@@ -26,7 +26,6 @@ class QueryColumn
end
def caption
- set_language_if_valid(User.current.language)
l("field_#{name}")
end
end
@@ -113,7 +112,6 @@ class Query < ActiveRecord::Base
def initialize(attributes = nil)
super attributes
self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} }
- set_language_if_valid(User.current.language)
end
def after_initialize
@@ -123,7 +121,7 @@ class Query < ActiveRecord::Base
def validate
filters.each_key do |field|
- errors.add label_for(field), :activerecord_error_blank unless
+ errors.add label_for(field), :blank unless
# filter requires one or more values
(values_for(field) and !values_for(field).first.blank?) or
# filter doesn't require any value
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 920cf2460..a205af5b4 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -25,7 +25,7 @@ class Repository < ActiveRecord::Base
before_destroy :clear_changesets
# Checks if the SCM is enabled when creating a repository
- validate_on_create { |r| r.errors.add(:type, :activerecord_error_invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
+ validate_on_create { |r| r.errors.add(:type, :invalid) unless Setting.enabled_scm.include?(r.class.name.demodulize) }
# Removes leading and trailing whitespace
def url=(arg)
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 4cb76441b..7d165492a 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -26,13 +26,13 @@ class TimeEntry < ActiveRecord::Base
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
acts_as_customizable
- acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
+ acts_as_event :title => Proc.new {|o| "#{o.user}: #{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
:url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
:author => :user,
:description => :comments
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
- validates_numericality_of :hours, :allow_nil => true, :message => :activerecord_error_invalid
+ validates_numericality_of :hours, :allow_nil => true, :message => :invalid
validates_length_of :comments, :maximum => 255, :allow_nil => true
def after_initialize
@@ -48,9 +48,9 @@ class TimeEntry < ActiveRecord::Base
end
def validate
- errors.add :hours, :activerecord_error_invalid if hours && (hours < 0 || hours >= 1000)
- errors.add :project_id, :activerecord_error_invalid if project.nil?
- errors.add :issue_id, :activerecord_error_invalid if (issue_id && !issue) || (issue && project!=issue.project)
+ errors.add :hours, :invalid if hours && (hours < 0 || hours >= 1000)
+ errors.add :project_id, :invalid if project.nil?
+ errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project)
end
def hours=(h)
diff --git a/app/models/version.rb b/app/models/version.rb
index 7f96cea6b..679854340 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -25,7 +25,7 @@ class Version < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name, :scope => [:project_id]
validates_length_of :name, :maximum => 60
- validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => 'activerecord_error_not_a_date', :allow_nil => true
+ validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :not_a_date, :allow_nil => true
def start_date
effective_date
diff --git a/app/models/watcher.rb b/app/models/watcher.rb
index 38110c584..b13039f84 100644
--- a/app/models/watcher.rb
+++ b/app/models/watcher.rb
@@ -25,6 +25,6 @@ class Watcher < ActiveRecord::Base
protected
def validate
- errors.add :user_id, :activerecord_error_invalid unless user.nil? || user.active?
+ errors.add :user_id, :invalid unless user.nil? || user.active?
end
end
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index 0d96cc047..f8bbcdebd 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -129,9 +129,9 @@ class WikiPage < ActiveRecord::Base
protected
def validate
- errors.add(:parent_title, :activerecord_error_invalid) if !@parent_title.blank? && parent.nil?
- errors.add(:parent_title, :activerecord_error_circular_dependency) if parent && (parent == self || parent.ancestors.include?(self))
- errors.add(:parent_title, :activerecord_error_not_same_project) if parent && (parent.wiki_id != wiki_id)
+ errors.add(:parent_title, :invalid) if !@parent_title.blank? && parent.nil?
+ errors.add(:parent_title, :circular_dependency) if parent && (parent == self || parent.ancestors.include?(self))
+ errors.add(:parent_title, :not_same_project) if parent && (parent.wiki_id != wiki_id)
end
end