Refactor: Decouple failed attachments and the flash messages
Attachment#attach_files will no longer need to return a flash message, instead it will put unsaved attachments into object#unsaved_attachments where the calling object can access them. A utility method #render_attachment_warning_if_needed is included for setting the standard flash warning. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3528 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -159,7 +159,7 @@ class IssuesController < ApplicationController
|
||||
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
|
||||
if @issue.save
|
||||
attachments = Attachment.attach_files(@issue, params[:attachments])
|
||||
flash[:warning] = attachments[:flash] if attachments[:flash]
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
|
||||
respond_to do |format|
|
||||
@@ -571,7 +571,8 @@ private
|
||||
|
||||
if @issue.valid?
|
||||
attachments = Attachment.attach_files(@issue, params[:attachments])
|
||||
flash[:warning] = attachments[:flash] if attachments[:flash]
|
||||
render_attachment_warning_if_needed(@issue)
|
||||
|
||||
attachments[:files].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
|
||||
|
||||
Reference in New Issue
Block a user