summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-01-10 14:05:42 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-01-10 14:05:42 +0000
commitd7c9886b8c6d8b7c997ef0bddcd497cf094a4012 (patch)
tree1fcbd99a23200a7e30a66bc54e1faca27fcf9f1e
parentee64310df4f513aece73206d709f199264e51ab3 (diff)
downloadredmine-d7c9886b8c6d8b7c997ef0bddcd497cf094a4012.tar.gz
redmine-d7c9886b8c6d8b7c997ef0bddcd497cf094a4012.zip
Fixed: attachments get saved on issue update even if validation fails (#4401).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3305 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/issues_controller.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index cd435ebe7..ded4e1a52 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -187,22 +187,22 @@ class IssuesController < ApplicationController
if request.post?
@time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
@time_entry.attributes = params[:time_entry]
- attachments = attach_files(@issue, params[:attachments])
- attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
-
- call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
-
- if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
- # Log spend time
- if User.current.allowed_to?(:log_time, @project)
- @time_entry.save
- end
- if !journal.new_record?
- # Only send notification if something was actually changed
- flash[:notice] = l(:notice_successful_update)
+ if (@time_entry.hours.nil? || @time_entry.valid?) && @issue.valid?
+ attachments = attach_files(@issue, params[:attachments])
+ attachments.each {|a| journal.details << JournalDetail.new(:property => 'attachment', :prop_key => a.id, :value => a.filename)}
+ call_hook(:controller_issues_edit_before_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
+ if @issue.save
+ # Log spend time
+ if User.current.allowed_to?(:log_time, @project)
+ @time_entry.save
+ end
+ if !journal.new_record?
+ # Only send notification if something was actually changed
+ flash[:notice] = l(:notice_successful_update)
+ end
+ call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
+ redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
end
- call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
- redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
end
end
rescue ActiveRecord::StaleObjectError