To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / files_controller.rb @ 443:350acce374a2
History | View | Annotate | Download (1.29 KB)
| 1 | 22:40f7cfd4df19 | chris | 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 | 326:2cf35a3bc0c5 | Chris | sort_init 'active', 'desc' |
| 12 | 22:40f7cfd4df19 | chris | sort_update 'filename' => "#{Attachment.table_name}.filename", |
| 13 | 254:0c9da2b87ad6 | chris | 'active' => "#{Attachment.table_name}.active", |
| 14 | 22:40f7cfd4df19 | chris | 'created_on' => "#{Attachment.table_name}.created_on", |
| 15 | 'size' => "#{Attachment.table_name}.filesize", |
||
| 16 | 'downloads' => "#{Attachment.table_name}.downloads" |
||
| 17 | 441:cbce1fd3b1b7 | Chris | |
| 18 | 22:40f7cfd4df19 | chris | @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] |
| 19 | @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
||
| 20 | render :layout => !request.xhr?
|
||
| 21 | end
|
||
| 22 | |||
| 23 | def new |
||
| 24 | @versions = @project.versions.sort |
||
| 25 | end
|
||
| 26 | |||
| 27 | def create |
||
| 28 | container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) |
||
| 29 | attachments = Attachment.attach_files(container, params[:attachments]) |
||
| 30 | render_attachment_warning_if_needed(container) |
||
| 31 | |||
| 32 | 37:94944d00e43c | chris | if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') |
| 33 | 22:40f7cfd4df19 | chris | Mailer.deliver_attachments_added(attachments[:files]) |
| 34 | end
|
||
| 35 | redirect_to project_files_path(@project)
|
||
| 36 | end
|
||
| 37 | 257:3ecf99348b9f | chris | |
| 38 | 22:40f7cfd4df19 | chris | end |