Class: Katello::ProductContent
- Defined in:
- app/models/katello/product_content.rb
Class Method Summary collapse
- .content_table_name ⇒ Object
- .enabled(organization) ⇒ Object
- .search_by_redhat(_key, _operator, value) ⇒ Object
- .with_valid_subscription(organization) ⇒ Object
Instance Method Summary collapse
- #arch ⇒ Object
- #enabled_value_from_candlepin ⇒ Object
- #os_versions ⇒ Object
-
#repositories ⇒ Object
following 4 methods used by Katello::Api::V2::RepositorySetsController#index.
- #set_enabled_from_candlepin! ⇒ Object
- #unfiltered_repositories ⇒ Object
Methods inherited from Model
Class Method Details
.content_table_name ⇒ Object
43 44 45 |
# File 'app/models/katello/product_content.rb', line 43 def self.content_table_name Katello::Content.table_name end |
.enabled(organization) ⇒ Object
47 48 49 50 51 |
# File 'app/models/katello/product_content.rb', line 47 def self.enabled(organization) content_ids = Katello::RootRepository.in_organization(organization).where.not(content_id: nil).pluck(:content_id) deb_content_ids = Katello::Repository.in_organization(organization).library.deb_type.pluck(:content_id) joins(:content).where("#{self.content_table_name}.cp_content_id" => content_ids + deb_content_ids) end |
.search_by_redhat(_key, _operator, value) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'app/models/katello/product_content.rb', line 34 def self.search_by_redhat(_key, _operator, value) conditions = Arel.sql(value == 'true' ? "#{Provider.table_name}.provider_type = 'Red Hat'" : "#{Provider.table_name}.provider_type != 'Red Hat'") { :conditions => conditions, :order => "#{Product.table_name}.name", :include => :product, :joins => {:product => :provider} } end |
.with_valid_subscription(organization) ⇒ Object
53 54 55 |
# File 'app/models/katello/product_content.rb', line 53 def self.with_valid_subscription(organization) where(:product_id => Katello::PoolProduct.where(:pool_id => organization.pools).select(:product_id)) end |
Instance Method Details
#arch ⇒ Object
67 68 69 |
# File 'app/models/katello/product_content.rb', line 67 def arch unfiltered_repositories.first&.arch end |
#enabled_value_from_candlepin ⇒ Object
75 76 77 78 79 |
# File 'app/models/katello/product_content.rb', line 75 def enabled_value_from_candlepin cp_product = ::Katello::Resources::Candlepin::Product.get(product.organization.label, product.cp_id).first cp_content = cp_product['productContent'].find { |pc| pc['content']['id'] == content.cp_content_id } cp_content['enabled'] end |
#os_versions ⇒ Object
71 72 73 |
# File 'app/models/katello/product_content.rb', line 71 def os_versions unfiltered_repositories.first&.os_versions || [] end |
#repositories ⇒ Object
following 4 methods used by Katello::Api::V2::RepositorySetsController#index
58 59 60 |
# File 'app/models/katello/product_content.rb', line 58 def repositories Katello::Repository.in_default_view.where(:root_id => product.root_repositories.has_url.where(:content_id => content.cp_content_id)) end |
#set_enabled_from_candlepin! ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'app/models/katello/product_content.rb', line 81 def set_enabled_from_candlepin! new_value = enabled_value_from_candlepin if self.enabled != new_value Rails.logger.info "Setting enabled to #{new_value} for Candlepin content #{content.cp_content_id}, ProductContent #{self.id}" self.update!(:enabled => new_value) else Rails.logger.info "No change in enabled value for Candlepin content #{content.cp_content_id}, ProductContent #{self.id}" false end end |
#unfiltered_repositories ⇒ Object
62 63 64 65 |
# File 'app/models/katello/product_content.rb', line 62 def unfiltered_repositories # don't filter by url, as we want to show all repos in the product Katello::Repository.in_default_view.where(:root_id => product.root_repositories.where(:content_id => content.cp_content_id)) end |