Class: Katello::ProductContent
- Defined in:
- app/models/katello/product_content.rb
Class Method Summary collapse
- .content_table_name ⇒ Object
- .enabled(organization) ⇒ 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
32 33 34 |
# File 'app/models/katello/product_content.rb', line 32 def self.content_table_name Katello::Content.table_name end |
.enabled(organization) ⇒ Object
36 37 38 |
# File 'app/models/katello/product_content.rb', line 36 def self.enabled(organization) joins(:content).where("#{self.content_table_name}.cp_content_id" => Katello::RootRepository.in_organization(organization).select(:content_id)) end |
.with_valid_subscription(organization) ⇒ Object
40 41 42 |
# File 'app/models/katello/product_content.rb', line 40 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
54 55 56 |
# File 'app/models/katello/product_content.rb', line 54 def arch unfiltered_repositories.first&.arch end |
#enabled_value_from_candlepin ⇒ Object
62 63 64 65 66 |
# File 'app/models/katello/product_content.rb', line 62 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
58 59 60 |
# File 'app/models/katello/product_content.rb', line 58 def os_versions unfiltered_repositories.first&.os_versions || [] end |
#repositories ⇒ Object
following 4 methods used by Katello::Api::V2::RepositorySetsController#index
45 46 47 |
# File 'app/models/katello/product_content.rb', line 45 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
68 69 70 71 72 73 74 75 76 77 |
# File 'app/models/katello/product_content.rb', line 68 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
49 50 51 52 |
# File 'app/models/katello/product_content.rb', line 49 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 |