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.

trackers_controller.rb 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 TrackersController < 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. @tracker_pages, @trackers = paginate Tracker.sorted, :per_page => 25
  26. render :action => "index", :layout => false if request.xhr?
  27. }
  28. format.api {
  29. @trackers = Tracker.sorted.all
  30. }
  31. end
  32. end
  33. def new
  34. @tracker ||= Tracker.new(params[:tracker])
  35. @trackers = Tracker.sorted.all
  36. @projects = Project.all
  37. end
  38. def create
  39. @tracker = Tracker.new(params[:tracker])
  40. if @tracker.save
  41. # workflow copy
  42. if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
  43. @tracker.workflow_rules.copy(copy_from)
  44. end
  45. flash[:notice] = l(:notice_successful_create)
  46. redirect_to trackers_path
  47. return
  48. end
  49. new
  50. render :action => 'new'
  51. end
  52. def edit
  53. @tracker ||= Tracker.find(params[:id])
  54. @projects = Project.all
  55. end
  56. def update
  57. @tracker = Tracker.find(params[:id])
  58. if @tracker.update_attributes(params[:tracker])
  59. flash[:notice] = l(:notice_successful_update)
  60. redirect_to trackers_path
  61. return
  62. end
  63. edit
  64. render :action => 'edit'
  65. end
  66. def destroy
  67. @tracker = Tracker.find(params[:id])
  68. unless @tracker.issues.empty?
  69. flash[:error] = l(:error_can_not_delete_tracker)
  70. else
  71. @tracker.destroy
  72. end
  73. redirect_to trackers_path
  74. end
  75. def fields
  76. if request.post? && params[:trackers]
  77. params[:trackers].each do |tracker_id, tracker_params|
  78. tracker = Tracker.find_by_id(tracker_id)
  79. if tracker
  80. tracker.core_fields = tracker_params[:core_fields]
  81. tracker.custom_field_ids = tracker_params[:custom_field_ids]
  82. tracker.save
  83. end
  84. end
  85. flash[:notice] = l(:notice_successful_update)
  86. redirect_to fields_trackers_path
  87. return
  88. end
  89. @trackers = Tracker.sorted.all
  90. @custom_fields = IssueCustomField.all.sort
  91. end
  92. end