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