mirror of
https://github.com/redmine/redmine.git
synced 2026-05-07 18:17:27 +02:00
Move VersionsController#download to AttachmentsController.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1685 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
class AttachmentsController < ApplicationController
|
||||
layout 'base'
|
||||
before_filter :find_project, :check_project_privacy
|
||||
before_filter :find_project
|
||||
|
||||
def show
|
||||
if @attachment.is_diff?
|
||||
@@ -32,6 +32,8 @@ class AttachmentsController < ApplicationController
|
||||
end
|
||||
|
||||
def download
|
||||
@attachment.increment_download if @attachment.container.is_a?(Version)
|
||||
|
||||
# images are sent inline
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => @attachment.content_type,
|
||||
@@ -41,9 +43,11 @@ class AttachmentsController < ApplicationController
|
||||
private
|
||||
def find_project
|
||||
@attachment = Attachment.find(params[:id])
|
||||
#render_404 and return false unless File.readable?(@attachment.diskfile)
|
||||
@project = @attachment.project
|
||||
#rescue
|
||||
# render_404
|
||||
permission = @attachment.container.is_a?(Version) ? :view_files : "view_#{@attachment.container.class.name.underscore.pluralize}".to_sym
|
||||
allowed = User.current.allowed_to?(permission, @project)
|
||||
allowed ? true : (User.current.logged? ? render_403 : require_login)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,15 +65,6 @@ class DocumentsController < ApplicationController
|
||||
@document.destroy
|
||||
redirect_to :controller => 'documents', :action => 'index', :project_id => @project
|
||||
end
|
||||
|
||||
def download
|
||||
@attachment = @document.attachments.find(params[:attachment_id])
|
||||
@attachment.increment_download
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => @attachment.content_type
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
def add_attachment
|
||||
attachments = attach_files(@document, params[:attachments])
|
||||
|
||||
@@ -37,15 +37,6 @@ class VersionsController < ApplicationController
|
||||
flash[:error] = "Unable to delete version"
|
||||
redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
|
||||
end
|
||||
|
||||
def download
|
||||
@attachment = @version.attachments.find(params[:attachment_id])
|
||||
@attachment.increment_download
|
||||
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => @attachment.content_type
|
||||
rescue
|
||||
render_404
|
||||
end
|
||||
|
||||
def destroy_file
|
||||
@version.attachments.find(params[:attachment_id]).destroy
|
||||
|
||||
Reference in New Issue
Block a user