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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # redMine - project management software
  2. # Copyright (C) 2006 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 'base'
  19. before_filter :require_admin
  20. verify :method => :post, :only => [ :destroy, :create, :update, :move ],
  21. :redirect_to => { :action => :list }
  22. def index
  23. list
  24. render :action => 'list' unless request.xhr?
  25. end
  26. def list
  27. @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
  28. render :action => "list", :layout => false if request.xhr?
  29. end
  30. def new
  31. @issue_status = IssueStatus.new
  32. end
  33. def create
  34. @issue_status = IssueStatus.new(params[:issue_status])
  35. if @issue_status.save
  36. flash[:notice] = l(:notice_successful_create)
  37. redirect_to :action => 'list'
  38. else
  39. render :action => 'new'
  40. end
  41. end
  42. def edit
  43. @issue_status = IssueStatus.find(params[:id])
  44. end
  45. def update
  46. @issue_status = IssueStatus.find(params[:id])
  47. if @issue_status.update_attributes(params[:issue_status])
  48. flash[:notice] = l(:notice_successful_update)
  49. redirect_to :action => 'list'
  50. else
  51. render :action => 'edit'
  52. end
  53. end
  54. def move
  55. @issue_status = IssueStatus.find(params[:id])
  56. case params[:position]
  57. when 'highest'
  58. @issue_status.move_to_top
  59. when 'higher'
  60. @issue_status.move_higher
  61. when 'lower'
  62. @issue_status.move_lower
  63. when 'lowest'
  64. @issue_status.move_to_bottom
  65. end if params[:position]
  66. redirect_to :action => 'list'
  67. end
  68. def destroy
  69. IssueStatus.find(params[:id]).destroy
  70. redirect_to :action => 'list'
  71. rescue
  72. flash[:error] = "Unable to delete issue status"
  73. redirect_to :action => 'list'
  74. end
  75. end