comparison app/controllers/trackers_controller.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children e248c7af89ec
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 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.
23 accept_api_auth :index 23 accept_api_auth :index
24 24
25 def index 25 def index
26 respond_to do |format| 26 respond_to do |format|
27 format.html { 27 format.html {
28 @tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' 28 @tracker_pages, @trackers = paginate Tracker.sorted, :per_page => 25
29 render :action => "index", :layout => false if request.xhr? 29 render :action => "index", :layout => false if request.xhr?
30 } 30 }
31 format.api { 31 format.api {
32 @trackers = Tracker.sorted.all 32 @trackers = Tracker.sorted.all
33 } 33 }
34 end 34 end
35 end 35 end
36 36
37 def new 37 def new
38 @tracker ||= Tracker.new(params[:tracker]) 38 @tracker ||= Tracker.new(params[:tracker])
39 @trackers = Tracker.find :all, :order => 'position' 39 @trackers = Tracker.sorted.all
40 @projects = Project.find(:all) 40 @projects = Project.all
41 end 41 end
42 42
43 def create 43 def create
44 @tracker = Tracker.new(params[:tracker]) 44 @tracker = Tracker.new(params[:tracker])
45 if request.post? and @tracker.save 45 if @tracker.save
46 # workflow copy 46 # workflow copy
47 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]))
48 @tracker.workflow_rules.copy(copy_from) 48 @tracker.workflow_rules.copy(copy_from)
49 end 49 end
50 flash[:notice] = l(:notice_successful_create) 50 flash[:notice] = l(:notice_successful_create)
51 redirect_to :action => 'index' 51 redirect_to trackers_path
52 return 52 return
53 end 53 end
54 new 54 new
55 render :action => 'new' 55 render :action => 'new'
56 end 56 end
57 57
58 def edit 58 def edit
59 @tracker ||= Tracker.find(params[:id]) 59 @tracker ||= Tracker.find(params[:id])
60 @projects = Project.find(:all) 60 @projects = Project.all
61 end 61 end
62 62
63 def update 63 def update
64 @tracker = Tracker.find(params[:id]) 64 @tracker = Tracker.find(params[:id])
65 if request.put? and @tracker.update_attributes(params[:tracker]) 65 if @tracker.update_attributes(params[:tracker])
66 flash[:notice] = l(:notice_successful_update) 66 flash[:notice] = l(:notice_successful_update)
67 redirect_to :action => 'index' 67 redirect_to trackers_path
68 return 68 return
69 end 69 end
70 edit 70 edit
71 render :action => 'edit' 71 render :action => 'edit'
72 end 72 end
76 unless @tracker.issues.empty? 76 unless @tracker.issues.empty?
77 flash[:error] = l(:error_can_not_delete_tracker) 77 flash[:error] = l(:error_can_not_delete_tracker)
78 else 78 else
79 @tracker.destroy 79 @tracker.destroy
80 end 80 end
81 redirect_to :action => 'index' 81 redirect_to trackers_path
82 end 82 end
83 83
84 def fields 84 def fields
85 if request.post? && params[:trackers] 85 if request.post? && params[:trackers]
86 params[:trackers].each do |tracker_id, tracker_params| 86 params[:trackers].each do |tracker_id, tracker_params|
90 tracker.custom_field_ids = tracker_params[:custom_field_ids] 90 tracker.custom_field_ids = tracker_params[:custom_field_ids]
91 tracker.save 91 tracker.save
92 end 92 end
93 end 93 end
94 flash[:notice] = l(:notice_successful_update) 94 flash[:notice] = l(:notice_successful_update)
95 redirect_to :action => 'fields' 95 redirect_to fields_trackers_path
96 return 96 return
97 end 97 end
98 @trackers = Tracker.sorted.all 98 @trackers = Tracker.sorted.all
99 @custom_fields = IssueCustomField.all.sort 99 @custom_fields = IssueCustomField.all.sort
100 end 100 end