##// END OF EJS Templates
post method verification for trackers/move...
Jean-Philippe Lang -
r207:d3b831bf7b55
parent child
Show More
@@ -1,75 +1,75
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
2 # Copyright (C) 2006 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class TrackersController < ApplicationController
18 class TrackersController < ApplicationController
19 layout 'base'
19 layout 'base'
20 before_filter :require_admin
20 before_filter :require_admin
21
21
22 def index
22 def index
23 list
23 list
24 render :action => 'list' unless request.xhr?
24 render :action => 'list' unless request.xhr?
25 end
25 end
26
26
27 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
27 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
28 verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :list }
28 verify :method => :post, :only => [ :destroy, :move ], :redirect_to => { :action => :list }
29
29
30 def list
30 def list
31 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position'
31 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position'
32 render :action => "list", :layout => false if request.xhr?
32 render :action => "list", :layout => false if request.xhr?
33 end
33 end
34
34
35 def new
35 def new
36 @tracker = Tracker.new(params[:tracker])
36 @tracker = Tracker.new(params[:tracker])
37 if request.post? and @tracker.save
37 if request.post? and @tracker.save
38 flash[:notice] = l(:notice_successful_create)
38 flash[:notice] = l(:notice_successful_create)
39 redirect_to :action => 'list'
39 redirect_to :action => 'list'
40 end
40 end
41 end
41 end
42
42
43 def edit
43 def edit
44 @tracker = Tracker.find(params[:id])
44 @tracker = Tracker.find(params[:id])
45 if request.post? and @tracker.update_attributes(params[:tracker])
45 if request.post? and @tracker.update_attributes(params[:tracker])
46 flash[:notice] = l(:notice_successful_update)
46 flash[:notice] = l(:notice_successful_update)
47 redirect_to :action => 'list'
47 redirect_to :action => 'list'
48 end
48 end
49 end
49 end
50
50
51 def move
51 def move
52 @tracker = Tracker.find(params[:id])
52 @tracker = Tracker.find(params[:id])
53 case params[:position]
53 case params[:position]
54 when 'highest'
54 when 'highest'
55 @tracker.move_to_top
55 @tracker.move_to_top
56 when 'higher'
56 when 'higher'
57 @tracker.move_higher
57 @tracker.move_higher
58 when 'lower'
58 when 'lower'
59 @tracker.move_lower
59 @tracker.move_lower
60 when 'lowest'
60 when 'lowest'
61 @tracker.move_to_bottom
61 @tracker.move_to_bottom
62 end if params[:position]
62 end if params[:position]
63 redirect_to :action => 'list'
63 redirect_to :action => 'list'
64 end
64 end
65
65
66 def destroy
66 def destroy
67 @tracker = Tracker.find(params[:id])
67 @tracker = Tracker.find(params[:id])
68 unless @tracker.issues.empty?
68 unless @tracker.issues.empty?
69 flash[:notice] = "This tracker contains issues and can\'t be deleted."
69 flash[:notice] = "This tracker contains issues and can\'t be deleted."
70 else
70 else
71 @tracker.destroy
71 @tracker.destroy
72 end
72 end
73 redirect_to :action => 'list'
73 redirect_to :action => 'list'
74 end
74 end
75 end
75 end
General Comments 0
You need to be logged in to leave comments. Login now