##// END OF EJS Templates
remove trailing white-spaces from app/controllers/issue_categories_controller.rb....
Toshi MARUYAMA -
r6783:fefb5fb298ef
parent child
Show More
@@ -1,91 +1,91
1 # redMine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006 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.
17
17
18 class IssueCategoriesController < ApplicationController
18 class IssueCategoriesController < ApplicationController
19 menu_item :settings
19 menu_item :settings
20 model_object IssueCategory
20 model_object IssueCategory
21 before_filter :find_model_object, :except => :new
21 before_filter :find_model_object, :except => :new
22 before_filter :find_project_from_association, :except => :new
22 before_filter :find_project_from_association, :except => :new
23 before_filter :find_project, :only => :new
23 before_filter :find_project, :only => :new
24 before_filter :authorize
24 before_filter :authorize
25
25
26 verify :method => :post, :only => :destroy
26 verify :method => :post, :only => :destroy
27
27
28 def new
28 def new
29 @category = @project.issue_categories.build(params[:category])
29 @category = @project.issue_categories.build(params[:category])
30 if request.post?
30 if request.post?
31 if @category.save
31 if @category.save
32 respond_to do |format|
32 respond_to do |format|
33 format.html do
33 format.html do
34 flash[:notice] = l(:notice_successful_create)
34 flash[:notice] = l(:notice_successful_create)
35 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
35 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
36 end
36 end
37 format.js do
37 format.js do
38 # IE doesn't support the replace_html rjs method for select box options
38 # IE doesn't support the replace_html rjs method for select box options
39 render(:update) {|page| page.replace "issue_category_id",
39 render(:update) {|page| page.replace "issue_category_id",
40 content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
40 content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
41 }
41 }
42 end
42 end
43 end
43 end
44 else
44 else
45 respond_to do |format|
45 respond_to do |format|
46 format.html
46 format.html
47 format.js do
47 format.js do
48 render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
48 render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
49 end
49 end
50 end
50 end
51 end
51 end
52 end
52 end
53 end
53 end
54
54
55 def edit
55 def edit
56 if request.post? and @category.update_attributes(params[:category])
56 if request.post? and @category.update_attributes(params[:category])
57 flash[:notice] = l(:notice_successful_update)
57 flash[:notice] = l(:notice_successful_update)
58 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
58 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
59 end
59 end
60 end
60 end
61
61
62 def destroy
62 def destroy
63 @issue_count = @category.issues.size
63 @issue_count = @category.issues.size
64 if @issue_count == 0
64 if @issue_count == 0
65 # No issue assigned to this category
65 # No issue assigned to this category
66 @category.destroy
66 @category.destroy
67 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
67 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
68 return
68 return
69 elsif params[:todo]
69 elsif params[:todo]
70 reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
70 reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
71 @category.destroy(reassign_to)
71 @category.destroy(reassign_to)
72 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
72 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
73 return
73 return
74 end
74 end
75 @categories = @project.issue_categories - [@category]
75 @categories = @project.issue_categories - [@category]
76 end
76 end
77
77
78 private
78 private
79 # Wrap ApplicationController's find_model_object method to set
79 # Wrap ApplicationController's find_model_object method to set
80 # @category instead of just @issue_category
80 # @category instead of just @issue_category
81 def find_model_object
81 def find_model_object
82 super
82 super
83 @category = @object
83 @category = @object
84 end
84 end
85
85
86 def find_project
86 def find_project
87 @project = Project.find(params[:project_id])
87 @project = Project.find(params[:project_id])
88 rescue ActiveRecord::RecordNotFound
88 rescue ActiveRecord::RecordNotFound
89 render_404
89 render_404
90 end
90 end
91 end
91 end
General Comments 0
You need to be logged in to leave comments. Login now