Sha256: ab739f0275d9299a179e6e5c787be2b346db7b70e58b79150494d9961cbf0be7

Contents?: true

Size: 1.7 KB

Versions: 70

Compression:

Stored size: 1.7 KB

Contents

module Katello
  class ProductContent < Katello::Model
    belongs_to :product, :class_name => 'Katello::Product', :foreign_key => 'product_id', :inverse_of => :product_contents
    belongs_to :content, :class_name => 'Katello::Content', :foreign_key => 'content_id', :inverse_of => :product_contents

    default_scope { includes(:content) }

    delegate :content_type, to: :content

    scope :displayable, -> {
      joins(:content).where.not("#{content_table_name}.content_type IN (?)", Katello::Repository.undisplayable_types)
    }

    scope :redhat, -> {
      where(:product_id => Product.redhat.select(:id))
    }

    scoped_search :on => :name, :relation => :content
    scoped_search :on => :content_type, :relation => :content
    scoped_search :on => :label, :relation => :content
    scoped_search :on => :name, :relation => :product, :rename => :product_name
    scoped_search :on => :id, :relation => :product, :rename => :product_id, :only_explicit => true
    scoped_search :on => :label, :relation => :content, :rename => :content_label

    def self.content_table_name
      Katello::Content.table_name
    end

    def self.enabled(organization)
      joins(:content).where("#{self.content_table_name}.cp_content_id" => Katello::RootRepository.in_organization(organization).select(:content_id))
    end

    def self.with_valid_subscription(organization)
      where(:product_id => Katello::PoolProduct.where(:pool_id => organization.pools).select(:product_id))
    end

    # used by Katello::Api::V2::RepositorySetsController#index
    def repositories
      Katello::Repository.in_default_view.where(:root_id => product.root_repositories.has_url.where(:content_id => content.cp_content_id))
    end
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
katello-4.0.3 app/models/katello/product_content.rb
katello-3.18.5 app/models/katello/product_content.rb
katello-4.0.2.1 app/models/katello/product_content.rb
katello-4.0.2 app/models/katello/product_content.rb
katello-3.18.4 app/models/katello/product_content.rb
katello-4.0.1.2 app/models/katello/product_content.rb
katello-3.18.3.1 app/models/katello/product_content.rb
katello-4.0.1.1 app/models/katello/product_content.rb
katello-3.18.3 app/models/katello/product_content.rb
katello-4.0.1 app/models/katello/product_content.rb
katello-4.0.0 app/models/katello/product_content.rb
katello-4.0.0.rc3.1 app/models/katello/product_content.rb
katello-4.0.0.rc3 app/models/katello/product_content.rb
katello-3.18.2.1 app/models/katello/product_content.rb
katello-3.18.2 app/models/katello/product_content.rb
katello-3.17.3 app/models/katello/product_content.rb
katello-4.0.0.rc2 app/models/katello/product_content.rb
katello-3.18.1.1 app/models/katello/product_content.rb
katello-3.17.2 app/models/katello/product_content.rb
katello-4.0.0.rc1 app/models/katello/product_content.rb