146 |
146 |
move_to_project_without_transaction(*args) || raise(ActiveRecord::Rollback)
|
147 |
147 |
end || false
|
148 |
148 |
end
|
149 |
|
|
150 |
|
def move_to_project_without_transaction(new_project, new_tracker = nil, options = {})
|
|
149 |
|
|
150 |
def move_to_project_without_transaction(new_project, notes = '', new_tracker = nil, options = {})
|
151 |
151 |
options ||= {}
|
152 |
|
issue = options[:copy] ? self.class.new.copy_from(self) : self
|
|
152 |
|
|
153 |
if options[:copy]
|
|
154 |
issue = self.class.new.copy_from(self)
|
|
155 |
issue.init_journal(User.current, notes, false) if notes.present?
|
|
156 |
else
|
|
157 |
issue = self
|
|
158 |
issue.init_journal(User.current, notes)
|
|
159 |
end
|
153 |
160 |
|
154 |
161 |
if new_project && issue.project_id != new_project.id
|
155 |
162 |
# delete issue relations
|
... | ... | |
188 |
195 |
issue.attributes = options[:attributes]
|
189 |
196 |
end
|
190 |
197 |
if issue.save
|
191 |
|
if options[:copy]
|
192 |
|
if current_journal && current_journal.notes.present?
|
193 |
|
issue.init_journal(current_journal.user, current_journal.notes)
|
194 |
|
issue.current_journal.notify = false
|
195 |
|
issue.save
|
196 |
|
end
|
197 |
|
else
|
|
198 |
unless options[:copy]
|
198 |
199 |
# Manually update project_id on related time entries
|
199 |
200 |
TimeEntry.update_all("project_id = #{new_project.id}", {:issue_id => id})
|
200 |
201 |
|
... | ... | |
381 |
382 |
end
|
382 |
383 |
end
|
383 |
384 |
|
384 |
|
def init_journal(user, notes = "")
|
|
385 |
def init_journal(user, notes = '', notify_on_save = true)
|
385 |
386 |
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
|
387 |
@current_journal.notify = notify_on_save
|
386 |
388 |
@issue_before_change = self.clone
|
387 |
389 |
@issue_before_change.status = self.status
|
388 |
390 |
@custom_values_before_change = {}
|