##// END OF EJS Templates
Fixes an error with postgres....
Jean-Philippe Lang -
r3079:008ad85d10c2
parent child
Show More
@@ -1,75 +1,83
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2008 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 WorkflowsController < ApplicationController
19 19 layout 'admin'
20 20
21 21 before_filter :require_admin
22 22
23 23 def index
24 24 @workflow_counts = Workflow.count_by_tracker_and_role
25 25 end
26 26
27 27 def edit
28 28 @role = Role.find_by_id(params[:role_id])
29 29 @tracker = Tracker.find_by_id(params[:tracker_id])
30 30
31 31 if request.post?
32 32 Workflow.destroy_all( ["role_id=? and tracker_id=?", @role.id, @tracker.id])
33 33 (params[:issue_status] || []).each { |old, news|
34 34 news.each { |new|
35 35 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new)
36 36 }
37 37 }
38 38 if @role.save
39 39 flash[:notice] = l(:notice_successful_update)
40 40 redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker
41 41 end
42 42 end
43 43 @roles = Role.find(:all, :order => 'builtin, position')
44 44 @trackers = Tracker.find(:all, :order => 'position')
45 45
46 46 @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true)
47 47 if @tracker && @used_statuses_only && @tracker.issue_statuses.any?
48 48 @statuses = @tracker.issue_statuses
49 49 end
50 50 @statuses ||= IssueStatus.find(:all, :order => 'position')
51 51 end
52 52
53 53 def copy
54 54 @trackers = Tracker.find(:all, :order => 'position')
55 55 @roles = Role.find(:all, :order => 'builtin, position')
56 56
57 @source_tracker = params[:source_tracker_id].blank? ? nil : Tracker.find_by_id(params[:source_tracker_id])
58 @source_role = params[:source_role_id].blank? ? nil : Role.find_by_id(params[:source_role_id])
57 if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any'
58 @source_tracker = nil
59 else
60 @source_tracker = Tracker.find_by_id(params[:source_tracker_id].to_i)
61 end
62 if params[:source_role_id].blank? || params[:source_role_id] == 'any'
63 @source_role = nil
64 else
65 @source_role = Role.find_by_id(params[:source_role_id].to_i)
66 end
59 67
60 68 @target_trackers = params[:target_tracker_ids].blank? ? nil : Tracker.find_all_by_id(params[:target_tracker_ids])
61 69 @target_roles = params[:target_role_ids].blank? ? nil : Role.find_all_by_id(params[:target_role_ids])
62 70
63 71 if request.post?
64 72 if params[:source_tracker_id].blank? || params[:source_role_id].blank? || (@source_tracker.nil? && @source_role.nil?)
65 73 flash.now[:error] = l(:error_workflow_copy_source)
66 74 elsif @target_trackers.nil? || @target_roles.nil?
67 75 flash.now[:error] = l(:error_workflow_copy_target)
68 76 else
69 77 Workflow.copy(@source_tracker, @source_role, @target_trackers, @target_roles)
70 78 flash[:notice] = l(:notice_successful_update)
71 79 redirect_to :action => 'copy', :source_tracker_id => @source_tracker, :source_role_id => @source_role
72 80 end
73 81 end
74 82 end
75 83 end
General Comments 0
You need to be logged in to leave comments. Login now