Mercurial > hg > soundsoftware-site
annotate app/controllers/files_controller.rb @ 929:5f33065ddc4b redmine-1.3
Update to Redmine SVN rev 9414 on 1.3-stable branch
author | Chris Cannam |
---|---|
date | Wed, 27 Jun 2012 14:54:18 +0100 |
parents | cbce1fd3b1b7 |
children | 350acce374a2 433d4f72a19b |
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@22 | 11 sort_init 'filename', 'asc' |
chris@22 | 12 sort_update 'filename' => "#{Attachment.table_name}.filename", |
chris@22 | 13 'created_on' => "#{Attachment.table_name}.created_on", |
chris@22 | 14 'size' => "#{Attachment.table_name}.filesize", |
chris@22 | 15 'downloads' => "#{Attachment.table_name}.downloads" |
Chris@441 | 16 |
chris@22 | 17 @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)] |
chris@22 | 18 @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse |
chris@22 | 19 render :layout => !request.xhr? |
chris@22 | 20 end |
chris@22 | 21 |
chris@22 | 22 def new |
chris@22 | 23 @versions = @project.versions.sort |
chris@22 | 24 end |
chris@22 | 25 |
chris@22 | 26 def create |
chris@22 | 27 container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) |
chris@22 | 28 attachments = Attachment.attach_files(container, params[:attachments]) |
chris@22 | 29 render_attachment_warning_if_needed(container) |
chris@22 | 30 |
chris@37 | 31 if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') |
chris@22 | 32 Mailer.deliver_attachments_added(attachments[:files]) |
chris@22 | 33 end |
chris@22 | 34 redirect_to project_files_path(@project) |
chris@22 | 35 end |
chris@22 | 36 end |