Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8526 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ca1958972e
commit
f3a2c8d7f7
|
@ -151,9 +151,10 @@ class Issue < ActiveRecord::Base
|
||||||
issue = self.class.new.copy_from(self)
|
issue = self.class.new.copy_from(self)
|
||||||
else
|
else
|
||||||
issue = self
|
issue = self
|
||||||
issue.init_journal(User.current, options[:notes])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
issue.init_journal(User.current, options[:notes])
|
||||||
|
|
||||||
issue.project = new_project
|
issue.project = new_project
|
||||||
if new_tracker
|
if new_tracker
|
||||||
issue.tracker = new_tracker
|
issue.tracker = new_tracker
|
||||||
|
@ -162,10 +163,7 @@ class Issue < ActiveRecord::Base
|
||||||
if options[:attributes]
|
if options[:attributes]
|
||||||
issue.attributes = options[:attributes]
|
issue.attributes = options[:attributes]
|
||||||
end
|
end
|
||||||
if options[:copy] && options[:notes].present?
|
|
||||||
issue.init_journal(User.current, options[:notes])
|
|
||||||
issue.current_journal.notify = false
|
|
||||||
end
|
|
||||||
unless issue.save
|
unless issue.save
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -385,9 +383,13 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
def init_journal(user, notes = "")
|
def init_journal(user, notes = "")
|
||||||
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
||||||
@attributes_before_change = attributes.dup
|
if new_record?
|
||||||
@custom_values_before_change = {}
|
@current_journal.notify = false
|
||||||
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
|
else
|
||||||
|
@attributes_before_change = attributes.dup
|
||||||
|
@custom_values_before_change = {}
|
||||||
|
self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
|
||||||
|
end
|
||||||
# Make sure updated_on is updated when adding a note.
|
# Make sure updated_on is updated when adding a note.
|
||||||
updated_on_will_change!
|
updated_on_will_change!
|
||||||
@current_journal
|
@current_journal
|
||||||
|
@ -932,25 +934,29 @@ class Issue < ActiveRecord::Base
|
||||||
def create_journal
|
def create_journal
|
||||||
if @current_journal
|
if @current_journal
|
||||||
# attributes changes
|
# attributes changes
|
||||||
(Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
|
if @attributes_before_change
|
||||||
before = @attributes_before_change[c]
|
(Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
|
||||||
after = send(c)
|
before = @attributes_before_change[c]
|
||||||
next if before == after || (before.blank? && after.blank?)
|
after = send(c)
|
||||||
@current_journal.details << JournalDetail.new(:property => 'attr',
|
next if before == after || (before.blank? && after.blank?)
|
||||||
:prop_key => c,
|
@current_journal.details << JournalDetail.new(:property => 'attr',
|
||||||
:old_value => before,
|
:prop_key => c,
|
||||||
:value => after)
|
:old_value => before,
|
||||||
}
|
:value => after)
|
||||||
# custom fields changes
|
}
|
||||||
custom_values.each {|c|
|
end
|
||||||
before = @custom_values_before_change[c.custom_field_id]
|
if @custom_values_before_change
|
||||||
after = c.value
|
# custom fields changes
|
||||||
next if before == after || (before.blank? && after.blank?)
|
custom_values.each {|c|
|
||||||
@current_journal.details << JournalDetail.new(:property => 'cf',
|
before = @custom_values_before_change[c.custom_field_id]
|
||||||
:prop_key => c.custom_field_id,
|
after = c.value
|
||||||
:old_value => before,
|
next if before == after || (before.blank? && after.blank?)
|
||||||
:value => after)
|
@current_journal.details << JournalDetail.new(:property => 'cf',
|
||||||
}
|
:prop_key => c.custom_field_id,
|
||||||
|
:old_value => before,
|
||||||
|
:value => after)
|
||||||
|
}
|
||||||
|
end
|
||||||
@current_journal.save
|
@current_journal.save
|
||||||
# reset current journal
|
# reset current journal
|
||||||
init_journal @current_journal.user, @current_journal.notes
|
init_journal @current_journal.user, @current_journal.notes
|
||||||
|
|
Loading…
Reference in New Issue