diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-13 20:35:03 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-09-13 20:35:03 +0000 |
commit | 41c055363ee4826799b9ffe7d76fd399c89190d3 (patch) | |
tree | 78321389f47072812eeb42dc6d5759f8c15addbb /app | |
parent | 12e10f6956fcd276fc3da19beb0c7bf4ade5f0da (diff) | |
download | redmine-41c055363ee4826799b9ffe7d76fd399c89190d3.tar.gz redmine-41c055363ee4826799b9ffe7d76fd399c89190d3.zip |
Refactor: split FilesController#new into #new and #create.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4084 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/files_controller.rb | 21 | ||||
-rw-r--r-- | app/views/files/new.html.erb | 2 |
2 files changed, 11 insertions, 12 deletions
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index fe5eb48c8..0a4903d08 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -19,19 +19,18 @@ class FilesController < ApplicationController render :layout => !request.xhr? end - # TODO: split method into new (GET) and create (POST) def new - if request.post? - container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) - attachments = Attachment.attach_files(container, params[:attachments]) - render_attachment_warning_if_needed(container) + @versions = @project.versions.sort + end - if !attachments.empty? && Setting.notified_events.include?('file_added') - Mailer.deliver_attachments_added(attachments[:files]) - end - redirect_to :controller => 'files', :action => 'index', :id => @project - return + def create + container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) + attachments = Attachment.attach_files(container, params[:attachments]) + render_attachment_warning_if_needed(container) + + if !attachments.empty? && Setting.notified_events.include?('file_added') + Mailer.deliver_attachments_added(attachments[:files]) end - @versions = @project.versions.sort + redirect_to :controller => 'files', :action => 'index', :id => @project end end diff --git a/app/views/files/new.html.erb b/app/views/files/new.html.erb index bbb3b1733..870a315c9 100644 --- a/app/views/files/new.html.erb +++ b/app/views/files/new.html.erb @@ -2,7 +2,7 @@ <%= error_messages_for 'attachment' %> <div class="box"> -<% form_tag({ :action => 'new', :id => @project }, :multipart => true, :class => "tabular") do %> +<% form_tag({ :action => 'create', :id => @project }, :multipart => true, :class => "tabular") do %> <% if @versions.any? %> <p><label for="version_id"><%=l(:field_version)%></label> |