obsolete.ChilliProject/app/controllers/issue_moves_controller.rb

69 lines
2.4 KiB
Ruby
Raw Normal View History

class IssueMovesController < ApplicationController
default_search_scope :issues
before_filter :find_issues, :check_project_uniqueness
before_filter :authorize
Merge branch 'master' into master-journalized Conflicts: app/controllers/application_controller.rb app/controllers/context_menus_controller.rb app/controllers/gantts_controller.rb app/controllers/issue_moves_controller.rb app/controllers/issues_controller.rb app/controllers/journals_controller.rb app/controllers/previews_controller.rb app/controllers/timelog_controller.rb app/helpers/issues_helper.rb app/helpers/journals_helper.rb app/models/issue.rb app/models/journal.rb app/models/journal_observer.rb app/views/admin/projects.rhtml app/views/context_menus/issues.html.erb app/views/issues/_action_menu.rhtml app/views/issues/_history.rhtml app/views/news/_news.rhtml app/views/news/index.rhtml app/views/repositories/diff.rhtml config/locales/bg.yml config/locales/bs.yml config/locales/ca.yml config/locales/cs.yml config/locales/da.yml config/locales/de.yml config/locales/el.yml config/locales/en-GB.yml config/locales/es.yml config/locales/eu.yml config/locales/fi.yml config/locales/fr.yml config/locales/gl.yml config/locales/he.yml config/locales/hr.yml config/locales/hu.yml config/locales/id.yml config/locales/it.yml config/locales/ko.yml config/locales/lt.yml config/locales/lv.yml config/locales/mn.yml config/locales/nl.yml config/locales/no.yml config/locales/pl.yml config/locales/pt-BR.yml config/locales/pt.yml config/locales/ro.yml config/locales/ru.yml config/locales/sk.yml config/locales/sl.yml config/locales/sr-YU.yml config/locales/sr.yml config/locales/sv.yml config/locales/th.yml config/locales/tr.yml config/locales/uk.yml config/locales/vi.yml config/locales/zh-TW.yml config/locales/zh.yml config/routes.rb doc/CHANGELOG lib/redmine.rb lib/redmine/export/pdf.rb lib/redmine/helpers/gantt.rb lib/redmine/version.rb public/stylesheets/application.css test/functional/context_menus_controller_test.rb test/functional/issues_controller_test.rb test/functional/journals_controller_test.rb test/functional/previews_controller_test.rb test/functional/users_controller_test.rb test/functional/wiki_controller_test.rb test/integration/routing_test.rb test/unit/issue_test.rb test/unit/mailer_test.rb test/unit/query_test.rb
2010-10-26 20:20:57 +04:00
def new
prepare_for_issue_move
render :layout => false if request.xhr?
end
def create
prepare_for_issue_move
if request.post?
new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
unsaved_issue_ids = []
moved_issues = []
@issues.each do |issue|
issue.reload
issue.init_journal(User.current)
issue.current_journal.notes = @notes if @notes.present?
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 => extract_changed_attributes_for_move(params)})
moved_issues << r
else
unsaved_issue_ids << issue.id
end
end
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
if params[:follow]
if @issues.size == 1 && moved_issues.size == 1
redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
else
redirect_to :controller => 'issues', :action => 'index', :project_id => (@target_project || @project)
end
else
redirect_to :controller => 'issues', :action => 'index', :project_id => @project
end
return
end
end
private
def prepare_for_issue_move
@issues.sort!
@copy = params[:copy_options] && params[:copy_options][:copy]
@allowed_projects = Issue.allowed_target_projects_on_move
@target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
Merge branch 'master' into master-journalized Conflicts: app/controllers/application_controller.rb app/controllers/context_menus_controller.rb app/controllers/gantts_controller.rb app/controllers/issue_moves_controller.rb app/controllers/issues_controller.rb app/controllers/journals_controller.rb app/controllers/previews_controller.rb app/controllers/timelog_controller.rb app/helpers/issues_helper.rb app/helpers/journals_helper.rb app/models/issue.rb app/models/journal.rb app/models/journal_observer.rb app/views/admin/projects.rhtml app/views/context_menus/issues.html.erb app/views/issues/_action_menu.rhtml app/views/issues/_history.rhtml app/views/news/_news.rhtml app/views/news/index.rhtml app/views/repositories/diff.rhtml config/locales/bg.yml config/locales/bs.yml config/locales/ca.yml config/locales/cs.yml config/locales/da.yml config/locales/de.yml config/locales/el.yml config/locales/en-GB.yml config/locales/es.yml config/locales/eu.yml config/locales/fi.yml config/locales/fr.yml config/locales/gl.yml config/locales/he.yml config/locales/hr.yml config/locales/hu.yml config/locales/id.yml config/locales/it.yml config/locales/ko.yml config/locales/lt.yml config/locales/lv.yml config/locales/mn.yml config/locales/nl.yml config/locales/no.yml config/locales/pl.yml config/locales/pt-BR.yml config/locales/pt.yml config/locales/ro.yml config/locales/ru.yml config/locales/sk.yml config/locales/sl.yml config/locales/sr-YU.yml config/locales/sr.yml config/locales/sv.yml config/locales/th.yml config/locales/tr.yml config/locales/uk.yml config/locales/vi.yml config/locales/zh-TW.yml config/locales/zh.yml config/routes.rb doc/CHANGELOG lib/redmine.rb lib/redmine/export/pdf.rb lib/redmine/helpers/gantt.rb lib/redmine/version.rb public/stylesheets/application.css test/functional/context_menus_controller_test.rb test/functional/issues_controller_test.rb test/functional/journals_controller_test.rb test/functional/previews_controller_test.rb test/functional/users_controller_test.rb test/functional/wiki_controller_test.rb test/integration/routing_test.rb test/unit/issue_test.rb test/unit/mailer_test.rb test/unit/query_test.rb
2010-10-26 20:20:57 +04:00
@target_project ||= @project
@trackers = @target_project.trackers
@available_statuses = Workflow.available_statuses(@project)
@notes = params[:notes]
@notes ||= ''
end
def extract_changed_attributes_for_move(params)
changed_attributes = {}
[:assigned_to_id, :status_id, :start_date, :due_date, :priority_id].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