issue_statuses_controller.rb
87 lines
| 2.5 KiB
| text/x-ruby
|
RubyLexer
|
r6768 | # Redmine - project management software | ||
|
r14856 | # Copyright (C) 2006-2016 Jean-Philippe Lang | ||
|
r330 | # | ||
# This program is free software; you can redistribute it and/or | ||||
# modify it under the terms of the GNU General Public License | ||||
# as published by the Free Software Foundation; either version 2 | ||||
# of the License, or (at your option) any later version. | ||||
|
r6768 | # | ||
|
r330 | # This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | ||||
|
r6768 | # | ||
|
r330 | # You should have received a copy of the GNU General Public License | ||
# along with this program; if not, write to the Free Software | ||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
class IssueStatusesController < ApplicationController | ||||
|
r3062 | layout 'admin' | ||
|
r6768 | |||
|
r15273 | before_action :require_admin, :except => :index | ||
before_action :require_admin_or_api_request, :only => :index | ||||
|
r7758 | accept_api_auth :index | ||
|
r330 | |||
|
r2 | def index | ||
|
r14891 | @issue_statuses = IssueStatus.sorted.to_a | ||
|
r7758 | respond_to do |format| | ||
|
r14891 | format.html { render :layout => false if request.xhr? } | ||
format.api | ||||
|
r7758 | end | ||
|
r2 | end | ||
def new | ||||
@issue_status = IssueStatus.new | ||||
end | ||||
def create | ||||
|
r15309 | @issue_status = IssueStatus.new | ||
@issue_status.safe_attributes = params[:issue_status] | ||||
|
r11377 | if @issue_status.save | ||
|
r15 | flash[:notice] = l(:notice_successful_create) | ||
|
r10754 | redirect_to issue_statuses_path | ||
|
r2 | else | ||
render :action => 'new' | ||||
end | ||||
end | ||||
def edit | ||||
@issue_status = IssueStatus.find(params[:id]) | ||||
end | ||||
def update | ||||
@issue_status = IssueStatus.find(params[:id]) | ||||
|
r15309 | @issue_status.safe_attributes = params[:issue_status] | ||
if @issue_status.save | ||||
|
r14954 | respond_to do |format| | ||
format.html { | ||||
flash[:notice] = l(:notice_successful_update) | ||||
redirect_to issue_statuses_path(:page => params[:page]) | ||||
} | ||||
|
r15305 | format.js { head 200 } | ||
|
r14954 | end | ||
|
r2 | else | ||
|
r14954 | respond_to do |format| | ||
format.html { render :action => 'edit' } | ||||
|
r15305 | format.js { head 422 } | ||
|
r14954 | end | ||
|
r2 | end | ||
|
r330 | end | ||
|
r2 | |||
def destroy | ||||
IssueStatus.find(params[:id]).destroy | ||||
|
r10754 | redirect_to issue_statuses_path | ||
|
r330 | rescue | ||
|
r3302 | flash[:error] = l(:error_unable_delete_issue_status) | ||
|
r10754 | redirect_to issue_statuses_path | ||
|
r11183 | end | ||
|
r6768 | |||
|
r3037 | def update_issue_done_ratio | ||
|
r7770 | if request.post? && IssueStatus.update_issue_done_ratios | ||
|
r3037 | flash[:notice] = l(:notice_issue_done_ratios_updated) | ||
else | ||||
flash[:error] = l(:error_issue_done_ratios_not_updated) | ||||
end | ||||
|
r10754 | redirect_to issue_statuses_path | ||
|
r3037 | end | ||
|
r2 | end | ||