Removed superfluous method and statement

pull/294/head
Hagen Schink 11 years ago
parent 8c758ae7fa
commit b684eb5f0a
  1. 45
      app/controllers/work_packages/moves_controller.rb
  2. 39
      app/controllers/work_packages_controller.rb

@ -23,33 +23,31 @@ class WorkPackages::MovesController < ApplicationController
def create def create
prepare_for_work_package_move prepare_for_work_package_move
if request.post? new_type = params[:new_type_id].blank? ? nil : @target_project.types.find_by_id(params[:new_type_id])
new_type = params[:new_type_id].blank? ? nil : @target_project.types.find_by_id(params[:new_type_id]) unsaved_work_package_ids = []
unsaved_work_package_ids = [] moved_work_packages = []
moved_work_packages = [] @work_packages.each do |work_package|
@work_packages.each do |work_package| work_package.reload
work_package.reload work_package.init_journal(User.current, @notes || "")
work_package.init_journal(User.current, @notes || "") call_hook(:controller_work_packages_move_before_save, { :params => params, :work_package => work_package, :target_project => @target_project, :copy => !!@copy })
call_hook(:controller_work_packages_move_before_save, { :params => params, :work_package => work_package, :target_project => @target_project, :copy => !!@copy }) if r = work_package.move_to_project(@target_project, new_type, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)})
if r = work_package.move_to_project(@target_project, new_type, {:copy => @copy, :attributes => extract_changed_attributes_for_move(params)}) moved_work_packages << r
moved_work_packages << r else
else unsaved_work_package_ids << work_package.id
unsaved_work_package_ids << work_package.id
end
end end
set_flash_from_bulk_work_package_save(@work_packages, unsaved_work_package_ids) end
set_flash_from_bulk_work_package_save(@work_packages, unsaved_work_package_ids)
if params[:follow] if params[:follow]
if @work_packages.size == 1 && moved_work_packages.size == 1 if @work_packages.size == 1 && moved_work_packages.size == 1
redirect_to work_package_path(moved_work_packages.first) redirect_to work_package_path(moved_work_packages.first)
else
redirect_to project_issues_path(@target_project || @project)
end
else else
redirect_to project_issues_path(@project) redirect_to project_issues_path(@target_project || @project)
end end
return else
redirect_to project_issues_path(@project)
end end
return
end end
def set_flash_from_bulk_work_package_save(work_packages, unsaved_work_package_ids) def set_flash_from_bulk_work_package_save(work_packages, unsaved_work_package_ids)
@ -71,7 +69,8 @@ class WorkPackages::MovesController < ApplicationController
# Filter for bulk work package operations # Filter for bulk work package operations
def find_work_packages def find_work_packages
@work_packages = WorkPackage.find_all_by_id(params[:work_package_id] || params[:ids]) @work_packages = WorkPackage.includes(:project)
.find_all_by_id(params[:work_package_id] || params[:ids])
raise ActiveRecord::RecordNotFound if @work_packages.empty? raise ActiveRecord::RecordNotFound if @work_packages.empty?
@projects = @work_packages.collect(&:project).compact.uniq @projects = @work_packages.collect(&:project).compact.uniq
@project = @projects.first if @projects.size == 1 @project = @projects.first if @projects.size == 1

@ -41,7 +41,6 @@ class WorkPackagesController < ApplicationController
before_filter :authorize, before_filter :authorize,
:assign_planning_elements :assign_planning_elements
before_filter :apply_at_timestamp, :only => [:show] before_filter :apply_at_timestamp, :only => [:show]
before_filter :build_new_work_package_from_params, :only => [:new]
helper :timelines helper :timelines
helper :timelines_journals helper :timelines_journals
@ -309,42 +308,4 @@ class WorkPackagesController < ApplicationController
render_errors(:at => 'unknown format') render_errors(:at => 'unknown format')
end end
private
def build_new_work_package_from_params
if params[:id].blank?
@work_package = WorkPackage.new
@work_package.copy_from(params[:copy_from]) if params[:copy_from]
else
@work_package = @project.work_packages.visible.find(params[:id])
end
@work_package.project = @project
# Type must be set before custom field values
@work_package.type ||= @project.types.find((params[:issue] && params[:issue][:type_id]) || params[:type_id] || :first)
#if @work_package.type.nil?
# render_error l(:error_no_type_in_project)
# return false
#end
@work_package.start_date ||= User.current.today if Setting.issue_startdate_is_adddate?
if params[:issue].is_a?(Hash)
@work_package.safe_attributes = params[:issue]
@work_package.priority_id = params[:issue][:priority_id] unless params[:issue][:priority_id].nil?
if User.current.allowed_to?(:add_work_package_watchers, @project) && @issue.new_record?
@work_package.watcher_user_ids = params[:issue]['watcher_user_ids']
end
end
# Copy watchers if we're copying a work package
if params[:copy_from] && User.current.allowed_to?(:add_work_package_watchers, @project)
@work_package.watcher_user_ids = WorkPackage.visible.find(params[:copy_from]).watcher_user_ids
end
@work_package.author = User.current
@priorities = IssuePriority.all
@allowed_statuses = @work_package.new_statuses_allowed_to(User.current, true)
end
end end

Loading…
Cancel
Save