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.5KB

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