@@ -151,9 +151,10 class Issue < ActiveRecord::Base | |||||
151 | issue = self.class.new.copy_from(self) |
|
151 | issue = self.class.new.copy_from(self) | |
152 | else |
|
152 | else | |
153 | issue = self |
|
153 | issue = self | |
154 | issue.init_journal(User.current, options[:notes]) |
|
|||
155 | end |
|
154 | end | |
156 |
|
155 | |||
|
156 | issue.init_journal(User.current, options[:notes]) | |||
|
157 | ||||
157 | issue.project = new_project |
|
158 | issue.project = new_project | |
158 | if new_tracker |
|
159 | if new_tracker | |
159 | issue.tracker = new_tracker |
|
160 | issue.tracker = new_tracker | |
@@ -162,10 +163,7 class Issue < ActiveRecord::Base | |||||
162 | if options[:attributes] |
|
163 | if options[:attributes] | |
163 | issue.attributes = options[:attributes] |
|
164 | issue.attributes = options[:attributes] | |
164 | end |
|
165 | end | |
165 | if options[:copy] && options[:notes].present? |
|
166 | ||
166 | issue.init_journal(User.current, options[:notes]) |
|
|||
167 | issue.current_journal.notify = false |
|
|||
168 | end |
|
|||
169 | unless issue.save |
|
167 | unless issue.save | |
170 | return false |
|
168 | return false | |
171 | end |
|
169 | end | |
@@ -385,9 +383,13 class Issue < ActiveRecord::Base | |||||
385 |
|
383 | |||
386 | def init_journal(user, notes = "") |
|
384 | def init_journal(user, notes = "") | |
387 | @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes) |
|
385 | @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes) | |
388 | @attributes_before_change = attributes.dup |
|
386 | if new_record? | |
389 | @custom_values_before_change = {} |
|
387 | @current_journal.notify = false | |
390 | self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value } |
|
388 | else | |
|
389 | @attributes_before_change = attributes.dup | |||
|
390 | @custom_values_before_change = {} | |||
|
391 | self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value } | |||
|
392 | end | |||
391 | # Make sure updated_on is updated when adding a note. |
|
393 | # Make sure updated_on is updated when adding a note. | |
392 | updated_on_will_change! |
|
394 | updated_on_will_change! | |
393 | @current_journal |
|
395 | @current_journal | |
@@ -932,25 +934,29 class Issue < ActiveRecord::Base | |||||
932 | def create_journal |
|
934 | def create_journal | |
933 | if @current_journal |
|
935 | if @current_journal | |
934 | # attributes changes |
|
936 | # attributes changes | |
935 | (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c| |
|
937 | if @attributes_before_change | |
936 | before = @attributes_before_change[c] |
|
938 | (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c| | |
937 | after = send(c) |
|
939 | before = @attributes_before_change[c] | |
938 | next if before == after || (before.blank? && after.blank?) |
|
940 | after = send(c) | |
939 | @current_journal.details << JournalDetail.new(:property => 'attr', |
|
941 | next if before == after || (before.blank? && after.blank?) | |
940 | :prop_key => c, |
|
942 | @current_journal.details << JournalDetail.new(:property => 'attr', | |
941 |
|
|
943 | :prop_key => c, | |
942 |
:value => |
|
944 | :old_value => before, | |
943 | } |
|
945 | :value => after) | |
944 | # custom fields changes |
|
946 | } | |
945 | custom_values.each {|c| |
|
947 | end | |
946 |
|
|
948 | if @custom_values_before_change | |
947 | after = c.value |
|
949 | # custom fields changes | |
948 | next if before == after || (before.blank? && after.blank?) |
|
950 | custom_values.each {|c| | |
949 | @current_journal.details << JournalDetail.new(:property => 'cf', |
|
951 | before = @custom_values_before_change[c.custom_field_id] | |
950 | :prop_key => c.custom_field_id, |
|
952 | after = c.value | |
951 | :old_value => before, |
|
953 | next if before == after || (before.blank? && after.blank?) | |
952 | :value => after) |
|
954 | @current_journal.details << JournalDetail.new(:property => 'cf', | |
953 | } |
|
955 | :prop_key => c.custom_field_id, | |
|
956 | :old_value => before, | |||
|
957 | :value => after) | |||
|
958 | } | |||
|
959 | end | |||
954 | @current_journal.save |
|
960 | @current_journal.save | |
955 | # reset current journal |
|
961 | # reset current journal | |
956 | init_journal @current_journal.user, @current_journal.notes |
|
962 | init_journal @current_journal.user, @current_journal.notes |
General Comments 0
You need to be logged in to leave comments.
Login now