annotate app/controllers/trackers_controller.rb @ 929:5f33065ddc4b redmine-1.3

Update to Redmine SVN rev 9414 on 1.3-stable branch
author Chris Cannam
date Wed, 27 Jun 2012 14:54:18 +0100
parents cbb26bc654de
children 433d4f72a19b
rev   line source
Chris@0 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 class TrackersController < ApplicationController
Chris@0 19 layout 'admin'
Chris@0 20
Chris@909 21 before_filter :require_admin, :except => :index
Chris@909 22 before_filter :require_admin_or_api_request, :only => :index
Chris@909 23 accept_api_auth :index
Chris@0 24
Chris@0 25 def index
Chris@909 26 respond_to do |format|
Chris@909 27 format.html {
Chris@909 28 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position'
Chris@909 29 render :action => "index", :layout => false if request.xhr?
Chris@909 30 }
Chris@909 31 format.api {
Chris@909 32 @trackers = Tracker.all
Chris@909 33 }
Chris@909 34 end
Chris@0 35 end
Chris@0 36
Chris@0 37 def new
Chris@909 38 @tracker ||= Tracker.new(params[:tracker])
Chris@909 39 @trackers = Tracker.find :all, :order => 'position'
Chris@909 40 @projects = Project.find(:all)
Chris@909 41 end
Chris@909 42
Chris@909 43 def create
Chris@0 44 @tracker = Tracker.new(params[:tracker])
Chris@0 45 if request.post? and @tracker.save
Chris@0 46 # workflow copy
Chris@0 47 if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
Chris@0 48 @tracker.workflows.copy(copy_from)
Chris@0 49 end
Chris@0 50 flash[:notice] = l(:notice_successful_create)
Chris@0 51 redirect_to :action => 'index'
Chris@0 52 return
Chris@0 53 end
Chris@909 54 new
Chris@909 55 render :action => 'new'
Chris@0 56 end
Chris@0 57
Chris@0 58 def edit
Chris@909 59 @tracker ||= Tracker.find(params[:id])
Chris@909 60 @projects = Project.find(:all)
Chris@909 61 end
Chris@909 62
Chris@909 63 def update
Chris@0 64 @tracker = Tracker.find(params[:id])
Chris@909 65 if request.put? and @tracker.update_attributes(params[:tracker])
Chris@0 66 flash[:notice] = l(:notice_successful_update)
Chris@0 67 redirect_to :action => 'index'
Chris@0 68 return
Chris@0 69 end
Chris@909 70 edit
Chris@909 71 render :action => 'edit'
Chris@0 72 end
Chris@909 73
Chris@909 74 verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index }
Chris@0 75 def destroy
Chris@0 76 @tracker = Tracker.find(params[:id])
Chris@0 77 unless @tracker.issues.empty?
Chris@0 78 flash[:error] = l(:error_can_not_delete_tracker)
Chris@0 79 else
Chris@0 80 @tracker.destroy
Chris@0 81 end
Chris@0 82 redirect_to :action => 'index'
Chris@909 83 end
Chris@0 84 end