diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-03-04 15:24:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-03-04 15:24:14 +0000 |
commit | 6b47cad8cea807222d1adf70dee5db95d4a39236 (patch) | |
tree | 4362716faa7ac56f01440993d934a3c50fafc501 /app/controllers/timelog_controller.rb | |
parent | dc50edae5e27fdfc72a7de4d9b7021d98d9621bc (diff) | |
download | redmine-6b47cad8cea807222d1adf70dee5db95d4a39236.tar.gz redmine-6b47cad8cea807222d1adf70dee5db95d4a39236.zip |
Cleanup in TimelogController#destroy.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9095 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/timelog_controller.rb')
-rw-r--r-- | app/controllers/timelog_controller.rb | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index 2feb129e2..d6d1911e7 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -199,30 +199,30 @@ class TimelogController < ApplicationController end def destroy - @time_entries.each do |t| - begin + destroyed = TimeEntry.transaction do + @time_entries.each do |t| unless t.destroy && t.destroyed? - respond_to do |format| - format.html { - flash[:error] = l(:notice_unable_delete_time_entry) - redirect_to :back - } - format.api { render_validation_errors(t) } - end - return + raise ActiveRecord::Rollback end - rescue ::ActionController::RedirectBackError - redirect_to :action => 'index', :project_id => @projects.first - return end end respond_to do |format| format.html { - flash[:notice] = l(:notice_successful_delete) + if destroyed + flash[:notice] = l(:notice_successful_delete) + else + flash[:error] = l(:notice_unable_delete_time_entry) + end redirect_back_or_default(:action => 'index', :project_id => @projects.first) } - format.api { head :ok } + format.api { + if destroyed + head :ok + else + render_validation_errors(@time_entries) + end + } end end |