##// END OF EJS Templates
Merged r4177 from trunk....
Eric Davis -
r4084:22bcce63aad6
parent child
Show More
@@ -1,37 +1,37
1 class FilesController < ApplicationController
1 class FilesController < ApplicationController
2 menu_item :files
2 menu_item :files
3
3
4 before_filter :find_project
4 before_filter :find_project
5 before_filter :authorize
5 before_filter :authorize
6
6
7 helper :sort
7 helper :sort
8 include SortHelper
8 include SortHelper
9
9
10 def index
10 def index
11 sort_init 'filename', 'asc'
11 sort_init 'filename', 'asc'
12 sort_update 'filename' => "#{Attachment.table_name}.filename",
12 sort_update 'filename' => "#{Attachment.table_name}.filename",
13 'created_on' => "#{Attachment.table_name}.created_on",
13 'created_on' => "#{Attachment.table_name}.created_on",
14 'size' => "#{Attachment.table_name}.filesize",
14 'size' => "#{Attachment.table_name}.filesize",
15 'downloads' => "#{Attachment.table_name}.downloads"
15 'downloads' => "#{Attachment.table_name}.downloads"
16
16
17 @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
17 @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
18 @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
18 @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
19 render :layout => !request.xhr?
19 render :layout => !request.xhr?
20 end
20 end
21
21
22 # TODO: split method into new (GET) and create (POST)
22 # TODO: split method into new (GET) and create (POST)
23 def new
23 def new
24 if request.post?
24 if request.post?
25 container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
25 container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
26 attachments = Attachment.attach_files(container, params[:attachments])
26 attachments = Attachment.attach_files(container, params[:attachments])
27 render_attachment_warning_if_needed(container)
27 render_attachment_warning_if_needed(container)
28
28
29 if !attachments.empty? && Setting.notified_events.include?('file_added')
29 if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
30 Mailer.deliver_attachments_added(attachments[:files])
30 Mailer.deliver_attachments_added(attachments[:files])
31 end
31 end
32 redirect_to :controller => 'files', :action => 'index', :id => @project
32 redirect_to :controller => 'files', :action => 'index', :id => @project
33 return
33 return
34 end
34 end
35 @versions = @project.versions.sort
35 @versions = @project.versions.sort
36 end
36 end
37 end
37 end
General Comments 0
You need to be logged in to leave comments. Login now