annotate app/controllers/files_controller.rb @ 1327:287f201c2802 redmine-2.2-integration

Add italic
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 19 Jun 2013 20:56:22 +0100
parents bb32da3bea34
children 4f746d8966dd
rev   line source
Chris@1115 1 # Redmine - project management software
Chris@1115 2 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@1115 3 #
Chris@1115 4 # This program is free software; you can redistribute it and/or
Chris@1115 5 # modify it under the terms of the GNU General Public License
Chris@1115 6 # as published by the Free Software Foundation; either version 2
Chris@1115 7 # of the License, or (at your option) any later version.
Chris@1115 8 #
Chris@1115 9 # This program is distributed in the hope that it will be useful,
Chris@1115 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1115 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1115 12 # GNU General Public License for more details.
Chris@1115 13 #
Chris@1115 14 # You should have received a copy of the GNU General Public License
Chris@1115 15 # along with this program; if not, write to the Free Software
Chris@1115 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1115 17
chris@22 18 class FilesController < ApplicationController
chris@22 19 menu_item :files
chris@22 20
chris@22 21 before_filter :find_project_by_project_id
chris@22 22 before_filter :authorize
chris@22 23
chris@22 24 helper :sort
chris@22 25 include SortHelper
chris@22 26
chris@22 27 def index
Chris@326 28 sort_init 'active', 'desc'
chris@22 29 sort_update 'filename' => "#{Attachment.table_name}.filename",
chris@254 30 'active' => "#{Attachment.table_name}.active",
chris@22 31 'created_on' => "#{Attachment.table_name}.created_on",
chris@22 32 'size' => "#{Attachment.table_name}.filesize",
chris@22 33 'downloads' => "#{Attachment.table_name}.downloads"
Chris@441 34
chris@22 35 @containers = [ Project.find(@project.id, :include => :attachments, :order => sort_clause)]
chris@22 36 @containers += @project.versions.find(:all, :include => :attachments, :order => sort_clause).sort.reverse
chris@22 37 render :layout => !request.xhr?
chris@22 38 end
chris@22 39
chris@22 40 def new
chris@22 41 @versions = @project.versions.sort
chris@22 42 end
chris@22 43
chris@22 44 def create
chris@22 45 container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
chris@22 46 attachments = Attachment.attach_files(container, params[:attachments])
chris@22 47 render_attachment_warning_if_needed(container)
chris@22 48
chris@37 49 if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Chris@1115 50 Mailer.attachments_added(attachments[:files]).deliver
chris@22 51 end
chris@22 52 redirect_to project_files_path(@project)
chris@22 53 end
chris@257 54
chris@22 55 end