Sha256: 05376afa47575514cbc87c16d2e3e71c344a4c2843a2a7d509f8d3fb4ca0365f
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
module Katello class Subscription < Katello::Model include Glue::Candlepin::CandlepinObject include Glue::Candlepin::Subscription include Katello::Authorization::Subscription has_many :products, :through => :subscription_products, :class_name => "Katello::Product" has_many :subscription_products, :class_name => "Katello::SubscriptionProduct", :dependent => :destroy, :inverse_of => :subscription has_many :pools, :class_name => "Katello::Pool", :inverse_of => :subscription, :dependent => :destroy belongs_to :organization, :class_name => "Organization", :inverse_of => :subscriptions scope :in_organization, ->(org) { where(:organization => org) } def self.with_subscribable_content joins(:products). where("#{Katello::Product.table_name}.id" => Product.with_subscribable_content) end def self.using_virt_who joins(:pools).where("#{Katello::Pool.table_name}.virt_who" => true) end def redhat? # for custom subscriptions, there is no separate marketing and engineering product # so query our Products table and check there product = Katello::Product.where(:cp_id => self.product_id, :organization => self.organization).first product.nil? || product.redhat? end def active? pools.any?(&:active?) end def expiring_soon? pools.any?(&:expiring_soon?) end def recently_expired? pools.any?(&:recently_expired?) end def virt_who_pools pools.where("#{Katello::Pool.table_name}.virt_who" => true) end def virt_who? virt_who_pools.any? end def self.humanize_class_name(_name = nil) _("Subscription") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katello-3.5.0.rc2 | app/models/katello/subscription.rb |