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