app/models/katello/activation_key.rb in katello-3.4.0.2 vs app/models/katello/activation_key.rb in katello-3.4.1
- old
+ new
@@ -99,14 +99,33 @@
all_products << pool.subscription.products
else
Rails.logger.error("Pool #{pool.id} is missing its subscription id.")
end
end
- all_products.flatten!
+ all_products.uniq.flatten
end
- def available_content
- self.products ? self.products.map(&:available_content).flatten.uniq { |product| product.content.id } : []
+ def all_products
+ Katello::Product.joins(:subscriptions => :pools).where(:organization_id => organization.id).enabled.uniq
+ end
+
+ def available_content(content_access_mode_all = false, content_access_mode_env = false)
+ if content_access_mode_env
+ return [] unless environment_id && content_view_id
+ version = ContentViewVersion.in_environment(environment_id).where(:content_view_id => content_view_id).first
+ content_view_version_id = version.id
+ end
+
+ if content_access_mode_all
+ content = all_products.flat_map do |product|
+ product.available_content(content_view_version_id)
+ end
+ else
+ content = products.flat_map do |product|
+ product.available_content(content_view_version_id)
+ end
+ end
+ content.uniq
end
def valid_content_override_label?(content_label)
self.available_content.map(&:content).any? { |content| content.label == content_label }
end