Mercurial > hg > soundsoftware-site
comparison app/controllers/trackers_controller.rb @ 909:cbb26bc654de redmine-1.3
Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author | Chris Cannam |
---|---|
date | Fri, 24 Feb 2012 19:09:32 +0000 |
parents | 513646585e45 |
children | 433d4f72a19b |
comparison
equal
deleted
inserted
replaced
908:c6c2cbd0afee | 909:cbb26bc654de |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2009 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 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 'admin' | 19 layout 'admin' |
20 | |
21 before_filter :require_admin | |
22 | 20 |
23 verify :method => :post, :only => :destroy, :redirect_to => { :action => :index } | 21 before_filter :require_admin, :except => :index |
22 before_filter :require_admin_or_api_request, :only => :index | |
23 accept_api_auth :index | |
24 | 24 |
25 def index | 25 def index |
26 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' | 26 respond_to do |format| |
27 render :action => "index", :layout => false if request.xhr? | 27 format.html { |
28 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' | |
29 render :action => "index", :layout => false if request.xhr? | |
30 } | |
31 format.api { | |
32 @trackers = Tracker.all | |
33 } | |
34 end | |
28 end | 35 end |
29 | 36 |
30 def new | 37 def new |
38 @tracker ||= Tracker.new(params[:tracker]) | |
39 @trackers = Tracker.find :all, :order => 'position' | |
40 @projects = Project.find(:all) | |
41 end | |
42 | |
43 def create | |
31 @tracker = Tracker.new(params[:tracker]) | 44 @tracker = Tracker.new(params[:tracker]) |
32 if request.post? and @tracker.save | 45 if request.post? and @tracker.save |
33 # workflow copy | 46 # workflow copy |
34 if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) | 47 if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) |
35 @tracker.workflows.copy(copy_from) | 48 @tracker.workflows.copy(copy_from) |
36 end | 49 end |
37 flash[:notice] = l(:notice_successful_create) | 50 flash[:notice] = l(:notice_successful_create) |
38 redirect_to :action => 'index' | 51 redirect_to :action => 'index' |
39 return | 52 return |
40 end | 53 end |
41 @trackers = Tracker.find :all, :order => 'position' | 54 new |
42 @projects = Project.find(:all) | 55 render :action => 'new' |
43 end | 56 end |
44 | 57 |
45 def edit | 58 def edit |
59 @tracker ||= Tracker.find(params[:id]) | |
60 @projects = Project.find(:all) | |
61 end | |
62 | |
63 def update | |
46 @tracker = Tracker.find(params[:id]) | 64 @tracker = Tracker.find(params[:id]) |
47 if request.post? and @tracker.update_attributes(params[:tracker]) | 65 if request.put? and @tracker.update_attributes(params[:tracker]) |
48 flash[:notice] = l(:notice_successful_update) | 66 flash[:notice] = l(:notice_successful_update) |
49 redirect_to :action => 'index' | 67 redirect_to :action => 'index' |
50 return | 68 return |
51 end | 69 end |
52 @projects = Project.find(:all) | 70 edit |
71 render :action => 'edit' | |
53 end | 72 end |
54 | 73 |
74 verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index } | |
55 def destroy | 75 def destroy |
56 @tracker = Tracker.find(params[:id]) | 76 @tracker = Tracker.find(params[:id]) |
57 unless @tracker.issues.empty? | 77 unless @tracker.issues.empty? |
58 flash[:error] = l(:error_can_not_delete_tracker) | 78 flash[:error] = l(:error_can_not_delete_tracker) |
59 else | 79 else |
60 @tracker.destroy | 80 @tracker.destroy |
61 end | 81 end |
62 redirect_to :action => 'index' | 82 redirect_to :action => 'index' |
63 end | 83 end |
64 end | 84 end |