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 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 TrackersController < ApplicationController
  18. layout 'base'
  19. before_filter :require_admin
  20. def index
  21. list
  22. render :action => 'list' unless request.xhr?
  23. end
  24. # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
  25. verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list }
  26. def list
  27. @tracker_pages, @trackers = paginate :trackers, :per_page => 10
  28. render :action => "list", :layout => false if request.xhr?
  29. end
  30. def new
  31. @tracker = Tracker.new(params[:tracker])
  32. if request.post? and @tracker.save
  33. flash[:notice] = l(:notice_successful_create)
  34. redirect_to :action => 'list'
  35. end
  36. end
  37. def edit
  38. @tracker = Tracker.find(params[:id])
  39. if request.post? and @tracker.update_attributes(params[:tracker])
  40. flash[:notice] = l(:notice_successful_update)
  41. redirect_to :action => 'list'
  42. end
  43. end
  44. def destroy
  45. @tracker = Tracker.find(params[:id])
  46. unless @tracker.issues.empty?
  47. flash[:notice] = "This tracker contains issues and can\'t be deleted."
  48. else
  49. @tracker.destroy
  50. end
  51. redirect_to :action => 'list'
  52. end
  53. end