Skip to content

Commit

Permalink
Merge branch 'devel-1.0.4' of github.com:anteo/redmine_custom_workflo…
Browse files Browse the repository at this point in the history
…ws into devel-1.0.4
  • Loading branch information
picman committed Oct 30, 2020
2 parents a93da15 + 5759caa commit 7f97fd9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/models/custom_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CustomWorkflow < ActiveRecord::Base
validate :validate_syntax, :validate_scripts_presence, if: Proc.new { |workflow| workflow.respond_to?(:observable) and workflow.active? }

scope :active, lambda { where(active: true) }
scope :sorted, lambda { order(:position) }
scope :for_project, (lambda do |project|
where("is_for_all=? OR EXISTS (SELECT * FROM #{reflect_on_association(:projects).join_table} WHERE project_id=? AND custom_workflow_id=id)",
true, project.id)
Expand All @@ -57,7 +58,7 @@ def self.log_message(str, object)
def self.run_shared_code(object)
log_message '= Running shared code', object
if CustomWorkflow.table_exists? # Due to DB migration
CustomWorkflow.active.where(observable: :shared).find_each do |workflow|
CustomWorkflow.active.where(observable: :shared).sorted.each do |workflow|
unless workflow.run(object, :shared_code)
log_message '= Abort running shared code', object
return false
Expand All @@ -77,7 +78,7 @@ def self.run_custom_workflows(observable, object, event)
end
return true unless workflows.any?
log_message "= Running #{event} custom workflows", object
workflows.each do |workflow|
workflows.sorted.each do |workflow|
unless workflow.run(object, event)
log_message "= Abort running #{event} custom workflows", object
return false
Expand Down

0 comments on commit 7f97fd9

Please sign in to comment.