Mercurial > hg > soundsoftware-site
annotate app/controllers/.svn/text-base/files_controller.rb.svn-base @ 507:0c939c159af4 redmine-1.2
Update to Redmine 1.2.1 on 1.2-stable branch (Redmine SVN rev 6270)
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:32:19 +0100 |
parents | cbce1fd3b1b7 |
children |
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 |