app/models/katello/activation_key.rb in katello-3.3.2 vs app/models/katello/activation_key.rb in katello-3.4.0.rc1
- old
+ new
@@ -47,14 +47,14 @@
validates_with Validators::ContentViewEnvironmentValidator
scope :in_environment, ->(env) { where(:environment_id => env) }
scoped_search :on => :name, :complete_value => true
- scoped_search :on => :organization_id, :complete_value => true, :only_explicit => true
- scoped_search :rename => :environment, :on => :name, :in => :environment, :complete_value => true
- scoped_search :rename => :content_view, :on => :name, :in => :content_view, :complete_value => true
- scoped_search :on => :content_view_id, :complete_value => true, :only_explicit => true
+ scoped_search :on => :organization_id, :complete_value => true, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
+ scoped_search :rename => :environment, :on => :name, :relation => :environment, :complete_value => true
+ scoped_search :rename => :content_view, :on => :name, :relation => :content_view, :complete_value => true
+ scoped_search :on => :content_view_id, :complete_value => true, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER
scoped_search :on => :description, :complete_value => true
def environment_exists
if environment_id && environment.nil?
errors.add(:environment, _("ID: %s doesn't exist ") % environment_id)
@@ -83,37 +83,33 @@
self.pools
end
def available_subscriptions
all_pools = self.get_pools.map { |pool| pool["id"] }
- added_pools = self.get_key_pools.map { |pool| pool["id"] }
+ added_pools = self.pools.pluck(:cp_id)
available_pools = all_pools - added_pools
Pool.where(:cp_id => available_pools,
:subscription_id => Subscription.with_subscribable_content)
end
def products
all_products = []
- cp_pools = self.get_key_pools
- if cp_pools
- pools = cp_pools.collect { |cp_pool| Pool.find_by(:cp_id => cp_pool['id']) }
- pools.each do |pool|
- if pool.subscription
- all_products << pool.subscription.products
- else
- Rails.logger.error("Pool #{pool.id} is missing its subscription id.")
- end
+ self.pools.each do |pool|
+ if pool.subscription
+ all_products << pool.subscription.products
+ else
+ Rails.logger.error("Pool #{pool.id} is missing its subscription id.")
end
end
all_products.flatten!
end
def available_content
self.products ? self.products.map(&:available_content).flatten.uniq { |product| product.content.id } : []
end
- def valid_content_label?(content_label)
+ def valid_content_override_label?(content_label)
self.available_content.map(&:content).any? { |content| content.label == content_label }
end
def calculate_consumption(product, pools, _allocate)
pools = pools.sort_by { |pool| [pool.start_date, pool.cp_id] }