##// END OF EJS Templates
remove trailing white-spaces from app/controllers/workflows_controller.rb....
Toshi MARUYAMA -
r6751:13d44f9d7007
parent child
Show More
@@ -1,42 +1,42
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 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 WorkflowsController < ApplicationController
18 class WorkflowsController < ApplicationController
19 layout 'admin'
19 layout 'admin'
20
20
21 before_filter :require_admin
21 before_filter :require_admin
22 before_filter :find_roles
22 before_filter :find_roles
23 before_filter :find_trackers
23 before_filter :find_trackers
24
24
25 def index
25 def index
26 @workflow_counts = Workflow.count_by_tracker_and_role
26 @workflow_counts = Workflow.count_by_tracker_and_role
27 end
27 end
28
28
29 def edit
29 def edit
30 @role = Role.find_by_id(params[:role_id])
30 @role = Role.find_by_id(params[:role_id])
31 @tracker = Tracker.find_by_id(params[:tracker_id])
31 @tracker = Tracker.find_by_id(params[:tracker_id])
32
32
33 if request.post?
33 if request.post?
34 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
34 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
35 (params[:issue_status] || []).each { |status_id, transitions|
35 (params[:issue_status] || []).each { |status_id, transitions|
36 transitions.each { |new_status_id, options|
36 transitions.each { |new_status_id, options|
37 author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
37 author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
38 assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
38 assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
39 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee)
39 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => status_id, :new_status_id => new_status_id, :author => author, :assignee => assignee)
40 }
40 }
41 }
41 }
42 if @role.save
42 if @role.save
@@ -45,13 +45,13 class WorkflowsController < ApplicationController
45 return
45 return
46 end
46 end
47 end
47 end
48
48
49 @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
49 @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
50 if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
50 if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
51 @statuses = @tracker.issue_statuses
51 @statuses = @tracker.issue_statuses
52 end
52 end
53 @statuses ||= IssueStatus.find(:all, :order => 'position')
53 @statuses ||= IssueStatus.find(:all, :order => 'position')
54
54
55 if @tracker && @role && @statuses.any?
55 if @tracker && @role && @statuses.any?
56 workflows = Workflow.all(:conditions => {:role_id => @role.id, :tracker_id => @tracker.id})
56 workflows = Workflow.all(:conditions => {:role_id => @role.id, :tracker_id => @tracker.id})
57 @workflows = {}
57 @workflows = {}
@@ -60,9 +60,9 class WorkflowsController < ApplicationController
60 @workflows['assignee'] = workflows.select {|w| w.assignee}
60 @workflows['assignee'] = workflows.select {|w| w.assignee}
61 end
61 end
62 end
62 end
63
63
64 def copy
64 def copy
65
65
66 if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any'
66 if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any'
67 @source_tracker = nil
67 @source_tracker = nil
68 else
68 else
@@ -73,10 +73,10 class WorkflowsController < ApplicationController
73 else
73 else
74 @source_role = Role.find_by_id(params[:source_role_id].to_i)
74 @source_role = Role.find_by_id(params[:source_role_id].to_i)
75 end
75 end
76
76
77 @target_trackers = params[:target_tracker_ids].blank? ? nil : Tracker.find_all_by_id(params[:target_tracker_ids])
77 @target_trackers = params[:target_tracker_ids].blank? ? nil : Tracker.find_all_by_id(params[:target_tracker_ids])
78 @target_roles = params[:target_role_ids].blank? ? nil : Role.find_all_by_id(params[:target_role_ids])
78 @target_roles = params[:target_role_ids].blank? ? nil : Role.find_all_by_id(params[:target_role_ids])
79
79
80 if request.post?
80 if request.post?
81 if params[:source_tracker_id].blank? || params[:source_role_id].blank? || (@source_tracker.nil? && @source_role.nil?)
81 if params[:source_tracker_id].blank? || params[:source_role_id].blank? || (@source_tracker.nil? && @source_role.nil?)
82 flash.now[:error] = l(:error_workflow_copy_source)
82 flash.now[:error] = l(:error_workflow_copy_source)
@@ -95,7 +95,7 class WorkflowsController < ApplicationController
95 def find_roles
95 def find_roles
96 @roles = Role.find(:all, :order => 'builtin, position')
96 @roles = Role.find(:all, :order => 'builtin, position')
97 end
97 end
98
98
99 def find_trackers
99 def find_trackers
100 @trackers = Tracker.find(:all, :order => 'position')
100 @trackers = Tracker.find(:all, :order => 'position')
101 end
101 end
General Comments 0
You need to be logged in to leave comments. Login now