1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 #
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.
8 #
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.
13 #
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.
17
18 class IssueStatusesController < ApplicationController
19 layout 'admin'
20
21 before_filter :require_admin, :except => :index
22 before_filter :require_admin_or_api_request, :only => :index
23 accept_api_auth :index
24
25 def index
26 respond_to do |format|
27 format.html {
28 @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
29 render :action => "index", :layout => false if request.xhr?
30 }
31 format.api {
32 @issue_statuses = IssueStatus.all(:order => 'position')
33 }
34 end
35 end
36
37 def new
38 @issue_status = IssueStatus.new
39 end
40
41 def create
42 @issue_status = IssueStatus.new(params[:issue_status])
43 if request.post? && @issue_status.save
44 flash[:notice] = l(:notice_successful_create)
45 redirect_to :action => 'index'
46 else
47 render :action => 'new'
48 end
49 end
50
51 def edit
52 @issue_status = IssueStatus.find(params[:id])
53 end
54
55 def update
56 @issue_status = IssueStatus.find(params[:id])
57 if request.put? && @issue_status.update_attributes(params[:issue_status])
58 flash[:notice] = l(:notice_successful_update)
59 redirect_to :action => 'index'
60 else
61 render :action => 'edit'
62 end
63 end
64
65 def destroy
66 IssueStatus.find(params[:id]).destroy
67 redirect_to :action => 'index'
68 rescue
69 flash[:error] = l(:error_unable_delete_issue_status)
70 redirect_to :action => 'index'
71 end
72
73 def update_issue_done_ratio
74 if request.post? && IssueStatus.update_issue_done_ratios
75 flash[:notice] = l(:notice_issue_done_ratios_updated)
76 else
77 flash[:error] = l(:error_issue_done_ratios_not_updated)
78 end
79 redirect_to :action => 'index'
80 end
81 end