annotate app/controllers/.svn/text-base/files_controller.rb.svn-base @ 45:65d9e2cabaa3 luisf

Added tipoftheday to the config/settings in order to correct previous issues. Tip of the day is now working correctly. Added the heading strings to the locales files.
author luisf
date Tue, 23 Nov 2010 11:50:01 +0000
parents 94944d00e43c
children cbce1fd3b1b7
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@22 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