Refactor: Moved ApplicationController#attach_files to the Attachment model

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3523 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2010-03-02 19:26:03 +00:00
parent 81d617cd5b
commit 0fd7e2d696
7 changed files with 54 additions and 37 deletions
+6 -3
View File
@@ -76,7 +76,8 @@ class WikiController < ApplicationController
@content.version = @page.content.version
else
if !@page.new_record? && @content.text == params[:content][:text]
attach_files(@page, params[:attachments])
attachments = Attachment.attach_files(@page, params[:attachments])
flash[:warning] = attachments[:flash] if attachments[:flash]
# don't save if text wasn't changed
redirect_to :action => 'index', :id => @project, :page => @page.title
return
@@ -87,7 +88,8 @@ class WikiController < ApplicationController
@content.author = User.current
# 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)
attach_files(@page, params[:attachments])
attachments = Attachment.attach_files(@page, params[:attachments])
flash[:warning] = attachments[:flash] if attachments[:flash]
call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page})
redirect_to :action => 'index', :id => @project, :page => @page.title
end
@@ -211,7 +213,8 @@ class WikiController < ApplicationController
def add_attachment
return render_403 unless editable?
attach_files(@page, params[:attachments])
attachments = Attachment.attach_files(@page, params[:attachments])
flash[:warning] = attachments[:flash] if attachments[:flash]
redirect_to :action => 'index', :page => @page.title
end