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

extract CustomFieldFormat#enterprise_feature_allowed?

Ivan Kuchinf48a54ec2b22
diff --git a/lib/open_project/custom_field_format.rb b/lib/open_project/custom_field_format.rb
index a416dc33103..dc2c8440465 100644
--- a/lib/open_project/custom_field_format.rb
+++ b/lib/open_project/custom_field_format.rb
@@ -34,7 +34,7 @@ module OpenProject
class_attribute :registered, default: {}
- attr_reader :name, :order, :label, :edit_as, :class_names, :enterprise_feature
+ attr_reader :name, :order, :label, :edit_as, :class_names
def initialize(name,
label:,
@@ -73,6 +73,10 @@ module OpenProject
!enabled?
end
+ def enterprise_feature_allowed?
+ !@enterprise_feature || EnterpriseToken.allows_to?(@enterprise_feature)
+ end
+
class << self
def map(&)
yield self
@@ -85,7 +89,7 @@ module OpenProject
def available
registered.select do |_, format|
- format.enabled? && (!format.enterprise_feature || EnterpriseToken.allows_to?(format.enterprise_feature))
+ format.enabled? && format.enterprise_feature_allowed?
end
end