Class: Katello::ContentViewEnvironmentContentFacet

Inherits:
Model
  • Object
show all
Defined in:
app/models/katello/content_view_environment_content_facet.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#destroy!

Class Method Details

.reprioritize_for_content_facet(content_facet, new_cves) ⇒ Object



25
26
27
28
29
30
31
32
# File 'app/models/katello/content_view_environment_content_facet.rb', line 25

def self.reprioritize_for_content_facet(content_facet, new_cves)
  new_order = new_cves.map do |cve|
    content_facet.content_view_environment_content_facets.find_by(:content_view_environment_id => cve.id)
  end
  new_order.compact.each_with_index do |cvecf, index|
    cvecf.update_column(:priority, index)
  end
end

Instance Method Details

#ensure_valid_content_sourceObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/katello/content_view_environment_content_facet.rb', line 12

def ensure_valid_content_source
  source = self.content_facet&.content_source
  return if source&.pulp_primary? # pulp_primary smart proxy always has all content
  env = self.content_view_environment&.environment
  hostname = self.content_facet&.host&.name
  return unless [source, env].all? { |x| x.present? }
  unless source.lifecycle_environments.include?(env)
    error_msg = _("Host %{hostname}: Cannot add content view environment to content facet. The host's content source '%{content_source}' does not sync lifecycle environment '%{lce}'.") % { hostname: hostname, content_source: source.name, lce: env.name }
    Rails.logger.warn error_msg
    errors.add(:base, error_msg)
  end
end