Refactor: extract method in IssuesController#move.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3917 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0bcde4ab28
commit
e4af6e77a7
|
@ -264,15 +264,9 @@ class IssuesController < ApplicationController
|
||||||
moved_issues = []
|
moved_issues = []
|
||||||
@issues.each do |issue|
|
@issues.each do |issue|
|
||||||
issue.reload
|
issue.reload
|
||||||
changed_attributes = {}
|
|
||||||
[:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute|
|
|
||||||
unless params[valid_attribute].blank?
|
|
||||||
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
|
|
||||||
end
|
|
||||||
end
|
|
||||||
issue.init_journal(User.current)
|
issue.init_journal(User.current)
|
||||||
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
|
call_hook(:controller_issues_move_before_save, { :params => params, :issue => issue, :target_project => @target_project, :copy => !!@copy })
|
||||||
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => changed_attributes})
|
if r = issue.move_to_project(@target_project, new_tracker, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
|
||||||
moved_issues << r
|
moved_issues << r
|
||||||
else
|
else
|
||||||
unsaved_issue_ids << issue.id
|
unsaved_issue_ids << issue.id
|
||||||
|
@ -485,4 +479,14 @@ private
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def extract_changed_attributes_for_move(params)
|
||||||
|
changed_attributes = {}
|
||||||
|
[:assigned_to_id, :status_id, :start_date, :due_date].each do |valid_attribute|
|
||||||
|
unless params[valid_attribute].blank?
|
||||||
|
changed_attributes[valid_attribute] = (params[valid_attribute] == 'none' ? nil : params[valid_attribute])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
changed_attributes
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue