Sha256: 971e1b180a0d7aa966f51608cce1bb3183e0c2e918a0dbd1657b8b35a2d28f2c
Contents?: true
Size: 1.41 KB
Versions: 4
Compression:
Stored size: 1.41 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) } validates :content_id, :presence => true, :uniqueness => { :scope => :product_id } validates :product_id, :presence => true delegate :content_type, to: :content scope :displayable, -> { joins(:content).where.not("#{content_table_name}.content_type IN (?)", Katello::Repository.undisplayable_types) .order("LOWER(#{content_table_name}.name) ASC") } 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 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::Repository.in_organization(organization).select(:content_id)) end # used by Katello::Api::V2::RepositorySetsController#index def repositories product.repositories.in_default_view.has_url.where(:content_id => content.cp_content_id) end end end
Version data entries
4 entries across 4 versions & 1 rubygems