@@ -1,117 +1,117 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2012 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 => [:index, :new, :create] |
|
22 | 22 | before_filter :find_project_from_association, :except => [:index, :new, :create] |
|
23 | 23 | before_filter :find_project_by_project_id, :only => [:index, :new, :create] |
|
24 | 24 | before_filter :authorize |
|
25 | 25 | accept_api_auth :index, :show, :create, :update, :destroy |
|
26 | ||
|
26 | ||
|
27 | 27 | def index |
|
28 | 28 | respond_to do |format| |
|
29 | 29 | format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project } |
|
30 | 30 | format.api { @categories = @project.issue_categories.all } |
|
31 | 31 | end |
|
32 | 32 | end |
|
33 | 33 | |
|
34 | 34 | def show |
|
35 | 35 | respond_to do |format| |
|
36 | 36 | format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project } |
|
37 | 37 | format.api |
|
38 | 38 | end |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def new |
|
42 | 42 | @category = @project.issue_categories.build |
|
43 | 43 | @category.safe_attributes = params[:issue_category] |
|
44 | 44 | |
|
45 | 45 | respond_to do |format| |
|
46 | 46 | format.html |
|
47 | 47 | format.js |
|
48 | 48 | end |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | def create |
|
52 | 52 | @category = @project.issue_categories.build |
|
53 | 53 | @category.safe_attributes = params[:issue_category] |
|
54 | 54 | if @category.save |
|
55 | 55 | respond_to do |format| |
|
56 | 56 | format.html do |
|
57 | 57 | flash[:notice] = l(:notice_successful_create) |
|
58 | 58 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project |
|
59 | 59 | end |
|
60 | 60 | format.js |
|
61 | 61 | format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) } |
|
62 | 62 | end |
|
63 | 63 | else |
|
64 | 64 | respond_to do |format| |
|
65 | 65 | format.html { render :action => 'new'} |
|
66 | 66 | format.js { render :action => 'new'} |
|
67 | 67 | format.api { render_validation_errors(@category) } |
|
68 | 68 | end |
|
69 | 69 | end |
|
70 | 70 | end |
|
71 | 71 | |
|
72 | 72 | def edit |
|
73 | 73 | end |
|
74 | 74 | |
|
75 | 75 | def update |
|
76 | 76 | @category.safe_attributes = params[:issue_category] |
|
77 | 77 | if @category.save |
|
78 | 78 | respond_to do |format| |
|
79 | 79 | format.html { |
|
80 | 80 | flash[:notice] = l(:notice_successful_update) |
|
81 | 81 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project |
|
82 | 82 | } |
|
83 | 83 | format.api { render_api_ok } |
|
84 | 84 | end |
|
85 | 85 | else |
|
86 | 86 | respond_to do |format| |
|
87 | 87 | format.html { render :action => 'edit' } |
|
88 | 88 | format.api { render_validation_errors(@category) } |
|
89 | 89 | end |
|
90 | 90 | end |
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | def destroy |
|
94 | 94 | @issue_count = @category.issues.size |
|
95 |
if @issue_count == 0 || params[:todo] || api_request? |
|
|
95 | if @issue_count == 0 || params[:todo] || api_request? | |
|
96 | 96 | reassign_to = nil |
|
97 | 97 | if params[:reassign_to_id] && (params[:todo] == 'reassign' || params[:todo].blank?) |
|
98 | 98 | reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) |
|
99 | 99 | end |
|
100 | 100 | @category.destroy(reassign_to) |
|
101 | 101 | respond_to do |format| |
|
102 | 102 | format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' } |
|
103 | 103 | format.api { render_api_ok } |
|
104 | 104 | end |
|
105 | 105 | return |
|
106 | 106 | end |
|
107 | 107 | @categories = @project.issue_categories - [@category] |
|
108 | 108 | end |
|
109 | 109 | |
|
110 | 110 | private |
|
111 | 111 | # Wrap ApplicationController's find_model_object method to set |
|
112 | 112 | # @category instead of just @issue_category |
|
113 | 113 | def find_model_object |
|
114 | 114 | super |
|
115 | 115 | @category = @object |
|
116 | 116 | end |
|
117 | 117 | end |
General Comments 0
You need to be logged in to leave comments.
Login now