Chris@0
|
1 # Redmine - project management software
|
Chris@1295
|
2 # Copyright (C) 2006-2013 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@1295
|
28 @tracker_pages, @trackers = paginate Tracker.sorted, :per_page => 25
|
Chris@909
|
29 render :action => "index", :layout => false if request.xhr?
|
Chris@909
|
30 }
|
Chris@909
|
31 format.api {
|
Chris@1115
|
32 @trackers = Tracker.sorted.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@1295
|
39 @trackers = Tracker.sorted.all
|
Chris@1295
|
40 @projects = Project.all
|
Chris@909
|
41 end
|
Chris@909
|
42
|
Chris@909
|
43 def create
|
Chris@0
|
44 @tracker = Tracker.new(params[:tracker])
|
Chris@1295
|
45 if @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@1115
|
48 @tracker.workflow_rules.copy(copy_from)
|
Chris@0
|
49 end
|
Chris@0
|
50 flash[:notice] = l(:notice_successful_create)
|
Chris@1295
|
51 redirect_to trackers_path
|
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@1295
|
60 @projects = Project.all
|
Chris@909
|
61 end
|
Chris@1115
|
62
|
Chris@909
|
63 def update
|
Chris@0
|
64 @tracker = Tracker.find(params[:id])
|
Chris@1295
|
65 if @tracker.update_attributes(params[:tracker])
|
Chris@0
|
66 flash[:notice] = l(:notice_successful_update)
|
Chris@1295
|
67 redirect_to trackers_path
|
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@0
|
74 def destroy
|
Chris@0
|
75 @tracker = Tracker.find(params[:id])
|
Chris@0
|
76 unless @tracker.issues.empty?
|
Chris@0
|
77 flash[:error] = l(:error_can_not_delete_tracker)
|
Chris@0
|
78 else
|
Chris@0
|
79 @tracker.destroy
|
Chris@0
|
80 end
|
Chris@1295
|
81 redirect_to trackers_path
|
Chris@909
|
82 end
|
Chris@1115
|
83
|
Chris@1115
|
84 def fields
|
Chris@1115
|
85 if request.post? && params[:trackers]
|
Chris@1115
|
86 params[:trackers].each do |tracker_id, tracker_params|
|
Chris@1115
|
87 tracker = Tracker.find_by_id(tracker_id)
|
Chris@1115
|
88 if tracker
|
Chris@1115
|
89 tracker.core_fields = tracker_params[:core_fields]
|
Chris@1115
|
90 tracker.custom_field_ids = tracker_params[:custom_field_ids]
|
Chris@1115
|
91 tracker.save
|
Chris@1115
|
92 end
|
Chris@1115
|
93 end
|
Chris@1115
|
94 flash[:notice] = l(:notice_successful_update)
|
Chris@1295
|
95 redirect_to fields_trackers_path
|
Chris@1115
|
96 return
|
Chris@1115
|
97 end
|
Chris@1115
|
98 @trackers = Tracker.sorted.all
|
Chris@1115
|
99 @custom_fields = IssueCustomField.all.sort
|
Chris@1115
|
100 end
|
Chris@0
|
101 end
|