Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2493 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-4
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user