app/controllers/katello/consumers_controller_logic.rb in katello-1.5.0 vs app/controllers/katello/consumers_controller_logic.rb in katello-2.2.2
- old
+ new
@@ -1,7 +1,7 @@
#
-# Copyright 2013 Red Hat, Inc.
+# Copyright 2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
@@ -9,49 +9,47 @@
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
module Katello
-module ConsumersControllerLogic
+ module ConsumersControllerLogic
+ # Consumed subscriptions
+ # Note: Finding the provider is necessary for cross-linking in the UI
+ def consumed_subscriptions(consumer)
+ consumed = consumer.consumed_entitlements.collect do |entitlement|
+ pool = Katello::Pool.find_pool(entitlement.poolId)
+ product = Product.where(:cp_id => pool.product_id).all.select do |p|
+ !Provider.where(:id => p.provider_id, :organization_id => current_organization.id).first.nil?
+ end
+ next if product.empty?
- # Consumed subscriptions
- # Note: Finding the provider is necessary for cross-linking in the UI
- def consumed_subscriptions(consumer)
- consumed = consumer.consumed_entitlements.collect do |entitlement|
- pool = Katello::Pool.find_pool(entitlement.poolId)
- product = Product.where(:cp_id => pool.product_id).all.select do |p|
- !Provider.where(:id => p.provider_id, :organization_id => current_organization.id).first.nil?
+ entitlement.provider_id = product[0].provider_id
+ entitlement
end
- next if product.empty?
- entitlement.provider_id = product[0].provider_id
- entitlement
+ return consumed
end
- return consumed
- end
+ # Available subscriptions
+ # Note: Finding the provider is necessary for cross-linking in the UI
+ def available_subscriptions(cp_pools, organization = current_organization)
+ if cp_pools
+ pools = cp_pools.collect { |cp_pool| ::Katello::Pool.find_pool(cp_pool['id'], cp_pool) }
- # Available subscriptions
- # Note: Finding the provider is necessary for cross-linking in the UI
- def available_subscriptions(cp_pools, organization = current_organization)
- if cp_pools
- pools = cp_pools.collect{|cp_pool| ::Katello::Pool.find_pool(cp_pool['id'], cp_pool)}
+ subscriptions = pools.collect do |pool|
+ product = Product.where(:cp_id => pool.product_id).all.select do |p|
+ !Provider.where(:id => p.provider_id, :organization_id => organization.id).first.nil?
+ end
+ next if product.empty?
- subscriptions = pools.collect do |pool|
- product = Product.where(:cp_id => pool.product_id).all.select do |p|
- !Provider.where(:id => p.provider_id, :organization_id => organization.id).first.nil?
+ pool.provider_id = product[0].provider_id
+ pool
end
- next if product.empty?
-
- pool.provider_id = product[0].provider_id
- pool
+ subscriptions.compact!
+ else
+ subscriptions = []
end
- subscriptions.compact!
- else
- subscriptions = []
- end
- return subscriptions
+ return subscriptions
+ end
end
-
-end
end