annotate app/controllers/files_controller.rb @ 1471:d65e60e20a50
bug_531
Close obsolete branch bug_531
author |
Chris Cannam |
date |
Fri, 23 Nov 2012 18:10:33 +0000 |
parents |
350acce374a2 |
children |
251b380117ce bb32da3bea34 |
rev |
line source |
chris@22
|
1 class FilesController < ApplicationController
|
chris@22
|
2 menu_item :files
|
chris@22
|
3
|
chris@22
|
4 before_filter :find_project_by_project_id
|
chris@22
|
5 before_filter :authorize
|
chris@22
|
6
|
chris@22
|
7 helper :sort
|
chris@22
|
8 include SortHelper
|
chris@22
|
9
|
chris@22
|
10 def index
|
Chris@326
|
11 sort_init 'active', 'desc'
|
chris@22
|
12 sort_update 'filename' => "#{Attachment.table_name}.filename",
|
chris@254
|
13 'active' => "#{Attachment.table_name}.active",
|
chris@22
|
14 'created_on' => "#{Attachment.table_name}.created_on",
|
chris@22
|
15 'size' => "#{Attachment.table_name}.filesize",
|
chris@22
|
16 'downloads' => "#{Attachment.table_name}.downloads"
|
Chris@441
|
17
|
chris@22
|
18 @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
|
chris@22
|
19 @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
|
chris@22
|
20 render :layout => !request.xhr?
|
chris@22
|
21 end
|
chris@22
|
22
|
chris@22
|
23 def new
|
chris@22
|
24 @versions = @project.versions.sort
|
chris@22
|
25 end
|
chris@22
|
26
|
chris@22
|
27 def create
|
chris@22
|
28 container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
chris@22
|
29 attachments = Attachment.attach_files(container, params[:attachments])
|
chris@22
|
30 render_attachment_warning_if_needed(container)
|
chris@22
|
31
|
chris@37
|
32 if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
chris@22
|
33 Mailer.deliver_attachments_added(attachments[:files])
|
chris@22
|
34 end
|
chris@22
|
35 redirect_to project_files_path(@project)
|
chris@22
|
36 end
|
chris@257
|
37
|
chris@22
|
38 end
|