You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

issue_statuses_controller.rb 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2021 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. class IssueStatusesController < ApplicationController
  19. layout 'admin'
  20. self.main_menu = false
  21. before_action :require_admin, :except => :index
  22. before_action :require_admin_or_api_request, :only => :index
  23. accept_api_auth :index
  24. def index
  25. @issue_statuses = IssueStatus.sorted.to_a
  26. respond_to do |format|
  27. format.html {render :layout => false if request.xhr?}
  28. format.api
  29. end
  30. end
  31. def new
  32. @issue_status = IssueStatus.new
  33. end
  34. def create
  35. @issue_status = IssueStatus.new
  36. @issue_status.safe_attributes = params[:issue_status]
  37. if @issue_status.save
  38. flash[:notice] = l(:notice_successful_create)
  39. redirect_to issue_statuses_path
  40. else
  41. render :action => 'new'
  42. end
  43. end
  44. def edit
  45. @issue_status = IssueStatus.find(params[:id])
  46. end
  47. def update
  48. @issue_status = IssueStatus.find(params[:id])
  49. @issue_status.safe_attributes = params[:issue_status]
  50. if @issue_status.save
  51. respond_to do |format|
  52. format.html do
  53. flash[:notice] = l(:notice_successful_update)
  54. redirect_to issue_statuses_path(:page => params[:page])
  55. end
  56. format.js {head 200}
  57. end
  58. else
  59. respond_to do |format|
  60. format.html {render :action => 'edit'}
  61. format.js {head 422}
  62. end
  63. end
  64. end
  65. def destroy
  66. IssueStatus.find(params[:id]).destroy
  67. redirect_to issue_statuses_path
  68. rescue => e
  69. flash[:error] = l(:error_unable_delete_issue_status, ERB::Util.h(e.message))
  70. redirect_to issue_statuses_path
  71. end
  72. def update_issue_done_ratio
  73. if request.post? && IssueStatus.update_issue_done_ratios
  74. flash[:notice] = l(:notice_issue_done_ratios_updated)
  75. else
  76. flash[:error] = l(:error_issue_done_ratios_not_updated)
  77. end
  78. redirect_to issue_statuses_path
  79. end
  80. end