##// END OF EJS Templates
remove trailing white-spaces from app/controllers/documents_controller.rb....
Toshi MARUYAMA -
r6683:c3a9d10e3b7f
parent child
Show More
@@ -1,16 +1,16
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -22,9 +22,9 class DocumentsController < ApplicationController
22 before_filter :find_model_object, :except => [:index, :new]
22 before_filter :find_model_object, :except => [:index, :new]
23 before_filter :find_project_from_association, :except => [:index, :new]
23 before_filter :find_project_from_association, :except => [:index, :new]
24 before_filter :authorize
24 before_filter :authorize
25
25
26 helper :attachments
26 helper :attachments
27
27
28 def index
28 def index
29 @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
29 @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
30 documents = @project.documents.find :all, :include => [:attachments, :category]
30 documents = @project.documents.find :all, :include => [:attachments, :category]
@@ -41,13 +41,13 class DocumentsController < ApplicationController
41 @document = @project.documents.build
41 @document = @project.documents.build
42 render :layout => false if request.xhr?
42 render :layout => false if request.xhr?
43 end
43 end
44
44
45 def show
45 def show
46 @attachments = @document.attachments.find(:all, :order => "created_on DESC")
46 @attachments = @document.attachments.find(:all, :order => "created_on DESC")
47 end
47 end
48
48
49 def new
49 def new
50 @document = @project.documents.build(params[:document])
50 @document = @project.documents.build(params[:document])
51 if request.post? and @document.save
51 if request.post? and @document.save
52 attachments = Attachment.attach_files(@document, params[:attachments])
52 attachments = Attachment.attach_files(@document, params[:attachments])
53 render_attachment_warning_if_needed(@document)
53 render_attachment_warning_if_needed(@document)
@@ -55,20 +55,20 class DocumentsController < ApplicationController
55 redirect_to :action => 'index', :project_id => @project
55 redirect_to :action => 'index', :project_id => @project
56 end
56 end
57 end
57 end
58
58
59 def edit
59 def edit
60 @categories = DocumentCategory.active #TODO: use it in the views
60 @categories = DocumentCategory.active #TODO: use it in the views
61 if request.post? and @document.update_attributes(params[:document])
61 if request.post? and @document.update_attributes(params[:document])
62 flash[:notice] = l(:notice_successful_update)
62 flash[:notice] = l(:notice_successful_update)
63 redirect_to :action => 'show', :id => @document
63 redirect_to :action => 'show', :id => @document
64 end
64 end
65 end
65 end
66
66
67 def destroy
67 def destroy
68 @document.destroy
68 @document.destroy
69 redirect_to :controller => 'documents', :action => 'index', :project_id => @project
69 redirect_to :controller => 'documents', :action => 'index', :project_id => @project
70 end
70 end
71
71
72 def add_attachment
72 def add_attachment
73 attachments = Attachment.attach_files(@document, params[:attachments])
73 attachments = Attachment.attach_files(@document, params[:attachments])
74 render_attachment_warning_if_needed(@document)
74 render_attachment_warning_if_needed(@document)
General Comments 0
You need to be logged in to leave comments. Login now