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

WIP: format project journal attributes for activity

Christophe Bliard5b33b67f751e
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 35c994a701a..089d315d039 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -39,6 +39,7 @@ class Journal < ApplicationRecord
register_journal_formatter :custom_field, OpenProject::JournalFormatter::CustomField
register_journal_formatter :schedule_manually, OpenProject::JournalFormatter::ScheduleManually
register_journal_formatter :ignore_non_working_days, OpenProject::JournalFormatter::IgnoreNonWorkingDays
+ register_journal_formatter :active_status, OpenProject::JournalFormatter::ActiveStatus
# Make sure each journaled model instance only has unique version ids
validates :version, uniqueness: { scope: %i[journable_id journable_type] }
diff --git a/app/models/project.rb b/app/models/project.rb
index b09223f0341..e8506185fb7 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -104,6 +104,8 @@ class Project < ApplicationRecord
author: nil,
datetime: :created_at
+ register_on_journal_formatter(:active_status, 'active')
+
has_paper_trail
validates :name,
diff --git a/lib/open_project/journal_formatter/active_status.rb b/lib/open_project/journal_formatter/active_status.rb
new file mode 100644
index 00000000000..20fa3397bff
--- /dev/null
+++ b/lib/open_project/journal_formatter/active_status.rb
@@ -0,0 +1,45 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+class OpenProject::JournalFormatter::ActiveStatus < JournalFormatter::Base
+ def format_details(_key, values, _options = {})
+ result = if values.last
+ "active"
+ else
+ "archived"
+ end
+
+ [label, nil, result]
+ end
+
+ private
+
+ def label
+ "Active status"
+ end
+end