Mercurial > hg > soundsoftware-site
comparison app/controllers/workflows_controller.rb @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 513646585e45 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
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 { |old, news| | 35 (params[:issue_status] || []).each { |status_id, transitions| |
36 news.each { |new| | 36 transitions.each { |new_status_id, options| |
37 @role.workflows.build(:tracker_id => @tracker.id, :old_status_id => old, :new_status_id => new) | 37 author = options.is_a?(Array) && options.include?('author') && !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) | |
38 } | 40 } |
39 } | 41 } |
40 if @role.save | 42 if @role.save |
41 flash[:notice] = l(:notice_successful_update) | 43 flash[:notice] = l(:notice_successful_update) |
42 redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker | 44 redirect_to :action => 'edit', :role_id => @role, :tracker_id => @tracker |
45 return | |
43 end | 46 end |
44 end | 47 end |
45 | 48 |
46 @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true) | 49 @used_statuses_only = (params[:used_statuses_only] == '0' ? false : true) |
47 if @tracker && @used_statuses_only && @tracker.issue_statuses.any? | 50 if @tracker && @used_statuses_only && @tracker.issue_statuses.any? |
48 @statuses = @tracker.issue_statuses | 51 @statuses = @tracker.issue_statuses |
49 end | 52 end |
50 @statuses ||= IssueStatus.find(:all, :order => 'position') | 53 @statuses ||= IssueStatus.find(:all, :order => 'position') |
54 | |
55 if @tracker && @role && @statuses.any? | |
56 workflows = Workflow.all(:conditions => {:role_id => @role.id, :tracker_id => @tracker.id}) | |
57 @workflows = {} | |
58 @workflows['always'] = workflows.select {|w| !w.author && !w.assignee} | |
59 @workflows['author'] = workflows.select {|w| w.author} | |
60 @workflows['assignee'] = workflows.select {|w| w.assignee} | |
61 end | |
51 end | 62 end |
52 | 63 |
53 def copy | 64 def copy |
54 | 65 |
55 if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any' | 66 if params[:source_tracker_id].blank? || params[:source_tracker_id] == 'any' |