Sha256: 9098d87ca1614a5bf7e8eba91a1372a4a88ae624597b848afba444c56f046f68

Contents?: true

Size: 1.82 KB

Versions: 19

Compression:

Stored size: 1.82 KB

Contents

module Katello
  class ErrataMailer < ApplicationMailer
    helper :'katello/errata_mailer'

    def host_errata(options)
      user = ::User.find(options[:user])
      ::User.as(user.login) do
        @hosts = ::Host::Managed.authorized("view_hosts").reject do |host|
          !host.content_facet || host.content_facet.applicable_errata.empty?
        end

        set_locale_for(user) do
          mail(:to => user.mail, :subject => _("Host Errata Advisory"))
        end
      end
    end

    def sync_errata(options)
      user = options[:user]

      all_errata = options[:errata]
      @repo = options[:repo]
      @errata_counts = errata_counts(all_errata)
      @errata = all_errata.take(100).group_by(&:errata_type)

      set_locale_for(user) do
        mail(:to => user.mail, :subject => (_("Sync Summary for %s") % @repo.name))
      end
    end

    def promote_errata(options)
      user = options[:user]
      ::User.as(user.login) do
        @content_view = options[:content_view]
        @environment = options[:environment]
        @content_facets = Katello::Host::ContentFacet.in_content_views_and_environments(
          :lifecycle_environments => [@environment],
          :content_views => [@content_view]
        )
        @hosts = ::Host::Managed.authorized("view_hosts").where(:id => @content_facets.pluck(:host_id))
        @errata = @content_facets.map(&:installable_errata).flatten.uniq

        set_locale_for(user) do
          mail(:to => user.mail, :subject => (_("Promotion Summary for %{content_view}") % {:content_view => @content_view.name}))
        end
      end
    end

    private

    def errata_counts(errata)
      counts = {:total => errata.count}
      counts.merge(Hash[[:security, :bugfix, :enhancement].collect do |errata_type|
        [errata_type, errata.send(errata_type).count]
      end])
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
katello-4.11.1 app/mailers/katello/errata_mailer.rb
katello-4.11.0 app/mailers/katello/errata_mailer.rb
katello-4.11.0.rc2 app/mailers/katello/errata_mailer.rb
katello-4.11.0.rc1 app/mailers/katello/errata_mailer.rb
katello-4.10.0 app/mailers/katello/errata_mailer.rb
katello-4.9.2 app/mailers/katello/errata_mailer.rb
katello-4.10.0.rc2 app/mailers/katello/errata_mailer.rb
katello-4.10.0.rc1 app/mailers/katello/errata_mailer.rb
katello-4.8.4 app/mailers/katello/errata_mailer.rb
katello-4.9.1 app/mailers/katello/errata_mailer.rb
katello-4.8.3 app/mailers/katello/errata_mailer.rb
katello-4.9.0 app/mailers/katello/errata_mailer.rb
katello-4.8.2 app/mailers/katello/errata_mailer.rb
katello-4.9.0.rc2 app/mailers/katello/errata_mailer.rb
katello-4.9.0.rc1 app/mailers/katello/errata_mailer.rb
katello-4.8.1 app/mailers/katello/errata_mailer.rb
katello-4.8.0 app/mailers/katello/errata_mailer.rb
katello-4.8.0.rc2 app/mailers/katello/errata_mailer.rb
katello-4.8.0.rc1 app/mailers/katello/errata_mailer.rb