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