diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-02 19:26:03 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-03-02 19:26:03 +0000 |
commit | 0fd7e2d696cf2d94da8b4cbcdb8fa4b36eb395fd (patch) | |
tree | d2e93da10c1c871b04783dccfd56f92ec0ef502a /app/controllers/documents_controller.rb | |
parent | 81d617cd5b97a811503282a5a5d056fa5b3adc0f (diff) | |
download | redmine-0fd7e2d696cf2d94da8b4cbcdb8fa4b36eb395fd.tar.gz redmine-0fd7e2d696cf2d94da8b4cbcdb8fa4b36eb395fd.zip |
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
Diffstat (limited to 'app/controllers/documents_controller.rb')
-rw-r--r-- | app/controllers/documents_controller.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 9d9c5a7d0..135ae2198 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -47,7 +47,8 @@ class DocumentsController < ApplicationController def new @document = @project.documents.build(params[:document]) if request.post? and @document.save - attach_files(@document, params[:attachments]) + attachments = Attachment.attach_files(@document, params[:attachments]) + flash[:warning] = attachments[:flash] if attachments[:flash] flash[:notice] = l(:notice_successful_create) redirect_to :action => 'index', :project_id => @project end @@ -67,8 +68,10 @@ class DocumentsController < ApplicationController end def add_attachment - attachments = attach_files(@document, params[:attachments]) - Mailer.deliver_attachments_added(attachments) if !attachments.empty? && Setting.notified_events.include?('document_added') + attachments = Attachment.attach_files(@document, params[:attachments]) + flash[:warning] = attachments[:flash] if attachments[:flash] + + Mailer.deliver_attachments_added(attachments[:files]) if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added') redirect_to :action => 'show', :id => @document end |