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
This commit is contained in:
Jean-Philippe Lang 2010-01-10 14:05:42 +00:00
parent ee64310df4
commit d7c9886b8c
1 changed files with 15 additions and 15 deletions

View File

@ -187,12 +187,11 @@ 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]
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 (@time_entry.hours.nil? || @time_entry.valid?) && @issue.save
if @issue.save
# Log spend time
if User.current.allowed_to?(:log_time, @project)
@time_entry.save
@ -205,6 +204,7 @@ class IssuesController < ApplicationController
redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
end
end
end
rescue ActiveRecord::StaleObjectError
# Optimistic locking exception
flash.now[:error] = l(:notice_locking_conflict)