comparison app/controllers/.svn/text-base/trackers_controller.rb.svn-base @ 0:513646585e45

* Import Redmine trunk SVN rev 3859
author Chris Cannam
date Fri, 23 Jul 2010 15:52:44 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:513646585e45
1 # Redmine - project management software
2 # Copyright (C) 2006-2009 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
18 class TrackersController < ApplicationController
19 layout 'admin'
20
21 before_filter :require_admin
22
23 verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
24
25 def index
26 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position'
27 render :action => "index", :layout => false if request.xhr?
28 end
29
30 def new
31 @tracker = Tracker.new(params[:tracker])
32 if request.post? and @tracker.save
33 # workflow copy
34 if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
35 @tracker.workflows.copy(copy_from)
36 end
37 flash[:notice] = l(:notice_successful_create)
38 redirect_to :action => 'index'
39 return
40 end
41 @trackers = Tracker.find :all, :order => 'position'
42 @projects = Project.find(:all)
43 end
44
45 def edit
46 @tracker = Tracker.find(params[:id])
47 if request.post? and @tracker.update_attributes(params[:tracker])
48 flash[:notice] = l(:notice_successful_update)
49 redirect_to :action => 'index'
50 return
51 end
52 @projects = Project.find(:all)
53 end
54
55 def destroy
56 @tracker = Tracker.find(params[:id])
57 unless @tracker.issues.empty?
58 flash[:error] = l(:error_can_not_delete_tracker)
59 else
60 @tracker.destroy
61 end
62 redirect_to :action => 'index'
63 end
64 end