Sha256: 3f33382f3bb7da06a83bbe4543701007c0e876ea162dff28f45323eacf4a87a7

Contents?: true

Size: 1.11 KB

Versions: 16

Compression:

Stored size: 1.11 KB

Contents

module Katello
  module Concerns
    module SettingExtensions
      extend ActiveSupport::Concern

      included do
        validates :value, inclusion: { in: ::Katello::RootRepository::DOWNLOAD_POLICIES },
          if: ->(setting) { setting.name == 'default_download_policy' }

        after_save :recalculate_errata_status
        after_commit :update_global_proxies
      end

      def recalculate_errata_status
        ForemanTasks.async_task(Actions::Katello::Host::RecalculateErrataStatus) if saved_change_to_attribute?(:value) && name == 'errata_status_installable'
      end

      def update_global_proxies
        if saved_change_to_attribute?(:value) && name == 'content_default_http_proxy'
          repos = ::Katello::Repository.joins(:root).merge(Katello::RootRepository.with_global_proxy).where.not(remote_href: nil).where(library_instance_id: nil)

          unless repos.empty?
            ForemanTasks.async_task(
              ::Actions::BulkAction,
              ::Actions::Katello::Repository::UpdateHttpProxyDetails,
              repos.sort_by(&:pulp_id))
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
katello-4.4.2.2 app/models/katello/concerns/setting_extensions.rb
katello-4.4.2.1 app/models/katello/concerns/setting_extensions.rb
katello-4.4.2 app/models/katello/concerns/setting_extensions.rb
katello-4.4.1 app/models/katello/concerns/setting_extensions.rb
katello-4.4.0.2 app/models/katello/concerns/setting_extensions.rb
katello-4.4.0.1 app/models/katello/concerns/setting_extensions.rb
katello-4.3.1 app/models/katello/concerns/setting_extensions.rb
katello-4.4.0 app/models/katello/concerns/setting_extensions.rb
katello-4.4.0.rc2 app/models/katello/concerns/setting_extensions.rb
katello-4.4.0.rc1 app/models/katello/concerns/setting_extensions.rb
katello-4.3.0 app/models/katello/concerns/setting_extensions.rb
katello-4.3.0.rc4 app/models/katello/concerns/setting_extensions.rb
katello-4.3.0.rc3 app/models/katello/concerns/setting_extensions.rb
katello-4.3.0.rc2.1 app/models/katello/concerns/setting_extensions.rb
katello-4.3.0.rc2 app/models/katello/concerns/setting_extensions.rb
katello-4.3.0.rc1 app/models/katello/concerns/setting_extensions.rb