To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / b3 / b3ae8401c116d3c968d234881e8c4c29afe48532.svn-base @ 1297:0a574315af3e
History | View | Annotate | Download (1.24 KB)
| 1 |
class FilesController < ApplicationController |
|---|---|
| 2 |
menu_item :files |
| 3 |
|
| 4 |
before_filter :find_project_by_project_id |
| 5 |
before_filter :authorize |
| 6 |
|
| 7 |
helper :sort |
| 8 |
include SortHelper |
| 9 |
|
| 10 |
def index |
| 11 |
sort_init 'filename', 'asc' |
| 12 |
sort_update 'filename' => "#{Attachment.table_name}.filename",
|
| 13 |
'created_on' => "#{Attachment.table_name}.created_on",
|
| 14 |
'size' => "#{Attachment.table_name}.filesize",
|
| 15 |
'downloads' => "#{Attachment.table_name}.downloads"
|
| 16 |
|
| 17 |
@containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] |
| 18 |
@containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
| 19 |
render :layout => !request.xhr? |
| 20 |
end |
| 21 |
|
| 22 |
def new |
| 23 |
@versions = @project.versions.sort |
| 24 |
end |
| 25 |
|
| 26 |
def create |
| 27 |
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) |
| 28 |
attachments = Attachment.attach_files(container, params[:attachments]) |
| 29 |
render_attachment_warning_if_needed(container) |
| 30 |
|
| 31 |
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
| 32 |
Mailer.deliver_attachments_added(attachments[:files]) |
| 33 |
end |
| 34 |
redirect_to project_files_path(@project) |
| 35 |
end |
| 36 |
end |