##// END OF EJS Templates
Code cleanup....
Jean-Philippe Lang -
r8406:f3a2c8d7f72a
parent child
Show More
@@ -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)
386 if new_record?
387 @current_journal.notify = false
388 else
388 @attributes_before_change = attributes.dup
389 @attributes_before_change = attributes.dup
389 @custom_values_before_change = {}
390 @custom_values_before_change = {}
390 self.custom_values.each {|c| @custom_values_before_change.store c.custom_field_id, c.value }
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,6 +934,7 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
937 if @attributes_before_change
935 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
938 (Issue.column_names - %w(id root_id lft rgt lock_version created_on updated_on)).each {|c|
936 before = @attributes_before_change[c]
939 before = @attributes_before_change[c]
937 after = send(c)
940 after = send(c)
@@ -941,6 +944,8 class Issue < ActiveRecord::Base
941 :old_value => before,
944 :old_value => before,
942 :value => after)
945 :value => after)
943 }
946 }
947 end
948 if @custom_values_before_change
944 # custom fields changes
949 # custom fields changes
945 custom_values.each {|c|
950 custom_values.each {|c|
946 before = @custom_values_before_change[c.custom_field_id]
951 before = @custom_values_before_change[c.custom_field_id]
@@ -951,6 +956,7 class Issue < ActiveRecord::Base
951 :old_value => before,
956 :old_value => before,
952 :value => after)
957 :value => after)
953 }
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