1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 class IssueCategoriesController < ApplicationController
20 model_object IssueCategory
21 before_filter :find_model_object, :except => :new
22 before_filter :find_project_from_association, :except => :new
23 before_filter :find_project, :only => :new
24 before_filter :authorize
26 verify :method => :post, :only => :destroy
29 @category = @project.issue_categories.build(params[:category])
32 respond_to do |format|
34 flash[:notice] = l(:notice_successful_create)
35 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
38 # IE doesn't support the replace_html rjs method for select box options
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]')
45 respond_to do |format|
48 render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
56 if request.post? and @category.update_attributes(params[:category])
57 flash[:notice] = l(:notice_successful_update)
58 redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
63 @issue_count = @category.issues.size
65 # No issue assigned to this category
67 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
69 reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
70 @category.destroy(reassign_to)
71 redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
73 @categories = @project.issue_categories - [@category]
77 # Wrap ApplicationController's find_model_object method to set
78 # @category instead of just @issue_category
85 @project = Project.find(params[:project_id])
86 rescue ActiveRecord::RecordNotFound