diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-16 21:00:11 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-02-16 21:00:11 +0000 |
commit | d4e6355eb3f220787e9374eeef6fb496f213f0d1 (patch) | |
tree | 1fe20acbf595c1df2407cc563ed37acf74292c10 /app/models/issue.rb | |
parent | a8f98bb74903954f28c4299f4ea7a7279d9028dd (diff) | |
download | redmine-d4e6355eb3f220787e9374eeef6fb496f213f0d1.tar.gz redmine-d4e6355eb3f220787e9374eeef6fb496f213f0d1.zip |
Better handling of attachments when issue validation fails (#10253).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8891 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 2750d7f63..eced77684 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -680,8 +680,7 @@ class Issue < ActiveRecord::Base s end - # Saves an issue, time_entry, attachments, and a journal from the parameters - # Returns false if save fails + # Saves an issue and a time_entry from the parameters def save_issue_with_child_records(params, existing_time_entry=nil) Issue.transaction do if params[:time_entry] && (params[:time_entry][:hours].present? || params[:time_entry][:comments].present?) && User.current.allowed_to?(:log_time, project) @@ -694,21 +693,13 @@ class Issue < ActiveRecord::Base self.time_entries << @time_entry end - if valid? - attachments = Attachment.attach_files(self, params[:attachments]) + # TODO: Rename hook + Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal}) + if save # TODO: Rename hook - Redmine::Hook.call_hook(:controller_issues_edit_before_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal}) - begin - if save - # TODO: Rename hook - Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal}) - else - raise ActiveRecord::Rollback - end - rescue ActiveRecord::StaleObjectError - attachments[:files].each(&:destroy) - raise ActiveRecord::StaleObjectError - end + Redmine::Hook.call_hook(:controller_issues_edit_after_save, { :params => params, :issue => self, :time_entry => @time_entry, :journal => @current_journal}) + else + raise ActiveRecord::Rollback end end end |