summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-15 08:27:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-15 08:27:38 +0000
commitaec989707edc47161192eba74f1a88123b12360a (patch)
tree5a810a6a3fb4fb76b9cfdb439eedc666bf4d049a /app/controllers
parent993b60d61eb927cff21ea0b06c1631eb986f6a51 (diff)
downloadredmine-aec989707edc47161192eba74f1a88123b12360a.tar.gz
redmine-aec989707edc47161192eba74f1a88123b12360a.zip
Workflow copy:
* added the ability the copy an existing workflow when creating a new role (closes #841) * use a single raw insert statement to copy tracker/role workflow rather than instantiating hundreds/thousands of objects git-svn-id: http://redmine.rubyforge.org/svn/trunk@1252 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/roles_controller.rb5
-rw-r--r--app/controllers/trackers_controller.rb8
2 files changed, 7 insertions, 6 deletions
diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb
index 4796bb7f0..9fdd9701b 100644
--- a/app/controllers/roles_controller.rb
+++ b/app/controllers/roles_controller.rb
@@ -36,10 +36,15 @@ class RolesController < ApplicationController
# Prefills the form with 'Non member' role permissions
@role = Role.new(params[:role] || {:permissions => Role.non_member.permissions})
if request.post? && @role.save
+ # workflow copy
+ if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
+ @role.workflows.copy(copy_from)
+ end
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'list'
end
@permissions = @role.setable_permissions
+ @roles = Role.find :all, :order => 'builtin, position'
end
def edit
diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb
index 46edea548..3d7dbd5c5 100644
--- a/app/controllers/trackers_controller.rb
+++ b/app/controllers/trackers_controller.rb
@@ -37,16 +37,12 @@ class TrackersController < ApplicationController
if request.post? and @tracker.save
# workflow copy
if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
- Workflow.transaction do
- copy_from.workflows.find(:all, :include => [:role, :old_status, :new_status]).each do |w|
- Workflow.create(:tracker_id => @tracker.id, :role => w.role, :old_status => w.old_status, :new_status => w.new_status)
- end
- end
+ @tracker.workflows.copy(copy_from)
end
flash[:notice] = l(:notice_successful_create)
redirect_to :action => 'list'
end
- @trackers = Tracker.find :all
+ @trackers = Tracker.find :all, :order => 'position'
end
def edit