From c01c64e9783dc361d98ca8dc37d2b3a661ae1945 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 29 Feb 2008 22:54:07 +0000 Subject: Let the user choose when deleting issues with reported hours (closes #734, #71): * to delete the hours * to assign the hours to the project * to reassign the hours to another issue git-svn-id: http://redmine.rubyforge.org/svn/trunk@1182 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/controllers') diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e03afb252..53627db92 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -263,6 +263,26 @@ class IssuesController < ApplicationController end def destroy + @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f + if @hours > 0 + case params[:todo] + when 'destroy' + # nothing to do + when 'nullify' + TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) + end + else + # display the destroy form + return + end + end @issues.each(&:destroy) redirect_to :action => 'index', :project_id => @project end -- cgit v1.2.3