2013-02-11 14:31:19 -05:00
|
|
|
class FilesController < ApplicationController
|
|
|
|
def download
|
2013-02-15 02:51:21 -05:00
|
|
|
note = Note.find(params[:id])
|
2013-05-15 15:35:59 -04:00
|
|
|
uploader = note.attachment
|
2013-02-15 02:51:21 -05:00
|
|
|
|
2013-05-15 15:35:59 -04:00
|
|
|
if uploader.file_storage?
|
|
|
|
if can?(current_user, :read_project, note.project)
|
|
|
|
send_file uploader.file.path, disposition: 'attachment'
|
|
|
|
else
|
|
|
|
not_found!
|
|
|
|
end
|
2013-02-15 02:51:21 -05:00
|
|
|
else
|
2013-05-15 15:35:59 -04:00
|
|
|
redirect_to uploader.url
|
2013-02-15 02:51:21 -05:00
|
|
|
end
|
2013-02-11 14:31:19 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|