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:
Eric Davis
2010-03-03 17:05:00 +00:00
parent 44955a519c
commit fe1e3ccd18
8 changed files with 26 additions and 19 deletions
+3 -3
View File
@@ -77,7 +77,7 @@ class WikiController < ApplicationController
else
if !@page.new_record? && @content.text == params[:content][:text]
attachments = Attachment.attach_files(@page, params[:attachments])
flash[:warning] = attachments[:flash] if attachments[:flash]
render_attachment_warning_if_needed(@page)
# don't save if text wasn't changed
redirect_to :action => 'index', :id => @project, :page => @page.title
return
@@ -89,7 +89,7 @@ class WikiController < ApplicationController
# if page is new @page.save will also save content, but not if page isn't a new record
if (@page.new_record? ? @page.save : @content.save)
attachments = Attachment.attach_files(@page, params[:attachments])
flash[:warning] = attachments[:flash] if attachments[:flash]
render_attachment_warning_if_needed(@page)
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
redirect_to :action => 'index', :id => @project, :page => @page.title
end
@@ -214,7 +214,7 @@ class WikiController < ApplicationController
def add_attachment
return render_403 unless editable?
attachments = Attachment.attach_files(@page, params[:attachments])
flash[:warning] = attachments[:flash] if attachments[:flash]
render_attachment_warning_if_needed(@page)
redirect_to :action => 'index', :page => @page.title
end