summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-01 15:17:45 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-01 15:17:45 +0000
commitb5e90972d88c69a1ef2c9e90879e8926d192acff (patch)
tree9370cd677e484caf9ec4576d5e8f5ffcd04aab1f /app/controllers
parentdaa8eaa9aebcc284e2904d1258cbfdd78ea23876 (diff)
downloadredmine-b5e90972d88c69a1ef2c9e90879e8926d192acff.tar.gz
redmine-b5e90972d88c69a1ef2c9e90879e8926d192acff.zip
Refactor: move method, ProjectsController#add_file to FilesController#new.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4052 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/files_controller.rb15
-rw-r--r--app/controllers/projects_controller.rb16
2 files changed, 15 insertions, 16 deletions
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index c84ce5f51..fe5eb48c8 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -19,4 +19,19 @@ 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)
+
+ 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
+ end
+ @versions = @project.versions.sort
+ end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 05c8d969d..61c7a7c71 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -18,7 +18,6 @@
class ProjectsController < ApplicationController
menu_item :overview
menu_item :roadmap, :only => :roadmap
- menu_item :files, :only => [:add_file]
menu_item :settings, :only => :settings
before_filter :find_project, :except => [ :index, :list, :add, :copy ]
@@ -239,21 +238,6 @@ class ProjectsController < ApplicationController
@project = nil
end
- def add_file
- 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)
-
- 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
- end
- @versions = @project.versions.sort
- end
-
def save_activities
if request.post? && params[:enumerations]
Project.transaction do