Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Pass the cause into the `CreateService`

Klaus Zanders5f85c13e4a99
diff --git a/app/services/journals/create_service.rb b/app/services/journals/create_service.rb
index d5901f2be5f..85151328d3d 100644
--- a/app/services/journals/create_service.rb
+++ b/app/services/journals/create_service.rb
@@ -48,7 +48,9 @@ module Journals
self.journable = journable
end
- def call(notes: '')
+ def call(notes: '', cause: nil)
+ Rails.logger.info("Journalin with cause #{cause}")
+
Journal.transaction do
journal = create_journal(notes)
diff --git a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/save_hooks.rb b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/save_hooks.rb
index 99b289403b5..e374743609f 100644
--- a/lib_static/plugins/acts_as_journalized/lib/acts/journalized/save_hooks.rb
+++ b/lib_static/plugins/acts_as_journalized/lib/acts/journalized/save_hooks.rb
@@ -53,7 +53,7 @@ module Acts::Journalized
base.class_eval do
after_save :save_journals
- attr_accessor :journal_notes, :journal_user
+ attr_accessor :journal_notes, :journal_user, :journal_cause
end
end
@@ -61,7 +61,7 @@ module Acts::Journalized
with_ensured_journal_attributes do
create_call = Journals::CreateService
.new(self, @journal_user)
- .call(notes: @journal_notes)
+ .call(notes: @journal_notes, cause: @journal_cause)
if create_call.success? && create_call.result
OpenProject::Notifications.send(OpenProject::Events::JOURNAL_CREATED,
@@ -73,9 +73,10 @@ module Acts::Journalized
end
end
- def add_journal(user: User.current, notes: '')
+ def add_journal(user: User.current, notes: '', cause: nil)
self.journal_user ||= user
self.journal_notes ||= notes
+ self.journal_cause ||= cause
end
private
@@ -88,6 +89,7 @@ module Acts::Journalized
ensure
self.journal_user = nil
self.journal_notes = nil
+ self.journal_cause = nil
end
end
end