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

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