##// END OF EJS Templates
remove trailing white space from app/controllers/files_controller.rb...
Toshi MARUYAMA -
r15779:84b880e1aa0d
parent child
Show More
@@ -1,76 +1,76
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2016 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class FilesController < ApplicationController
19 19 menu_item :files
20 20
21 21 before_action :find_project_by_project_id
22 22 before_action :authorize
23 23 accept_api_auth :index, :create
24 24
25 helper :attachments
25 helper :attachments
26 26 helper :sort
27 27 include SortHelper
28 28
29 29 def index
30 30 sort_init 'filename', 'asc'
31 31 sort_update 'filename' => "#{Attachment.table_name}.filename",
32 32 'created_on' => "#{Attachment.table_name}.created_on",
33 33 'size' => "#{Attachment.table_name}.filesize",
34 34 'downloads' => "#{Attachment.table_name}.downloads"
35 35
36 36 @containers = [Project.includes(:attachments).
37 37 references(:attachments).reorder(sort_clause).find(@project.id)]
38 38 @containers += @project.versions.includes(:attachments).
39 39 references(:attachments).reorder(sort_clause).to_a.sort.reverse
40 40 respond_to do |format|
41 41 format.html { render :layout => !request.xhr? }
42 42 format.api
43 43 end
44 44 end
45 45
46 46 def new
47 47 @versions = @project.versions.sort
48 48 end
49 49
50 50 def create
51 51 version_id = params[:version_id] || (params[:file] && params[:file][:version_id])
52 52 container = version_id.blank? ? @project : @project.versions.find_by_id(version_id)
53 53 attachments = Attachment.attach_files(container, (params[:attachments] || (params[:file] && params[:file][:token] && params)))
54 54 render_attachment_warning_if_needed(container)
55 55
56 56 if attachments[:files].present?
57 57 if Setting.notified_events.include?('file_added')
58 58 Mailer.attachments_added(attachments[:files]).deliver
59 59 end
60 60 respond_to do |format|
61 61 format.html {
62 62 flash[:notice] = l(:label_file_added)
63 63 redirect_to project_files_path(@project) }
64 64 format.api { render_api_ok }
65 65 end
66 66 else
67 67 respond_to do |format|
68 68 format.html {
69 69 flash.now[:error] = l(:label_attachment) + " " + l('activerecord.errors.messages.invalid')
70 70 new
71 71 render :action => 'new' }
72 72 format.api { render :status => :bad_request }
73 73 end
74 74 end
75 75 end
76 76 end
General Comments 0
You need to be logged in to leave comments. Login now