Sha256: 3d54c26714b06c96507a0a1ca5b97fc36db03cebdfd041611c12a1310721652f

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 KB

Contents

#
# Copyright 2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

# The Errata module contains methods that are common for supporting errata
# in several controllers (e.g. SystemErrataController and HostCollectionErrataController)
module Katello
  module Util
    module Errata
      def filter_by_type(errata_list, filter_type)
        filtered_list = []

        if filter_type != "All"
          pulp_filter_type = get_pulp_filter_type(filter_type)

          errata_list.each do |erratum|
            if erratum.respond_to?(:type)
              if erratum.type == pulp_filter_type
                filtered_list << erratum
              end
            else
              if erratum["type"] == pulp_filter_type
                filtered_list << erratum
              end
            end
          end
        else
          filtered_list = errata_list
        end

        return filtered_list
      end

      def get_pulp_filter_type(type)
        filter_type = type.downcase
        if filter_type == "bugfix"
          return ::Katello::Erratum::BUGZILLA
        elsif filter_type == "enhancement"
          return ::Katello::Erratum::ENHANCEMENT
        elsif filter_type == "security"
          return ::Katello::Erratum::SECURITY
        end
      end

      def filter_by_state(errata_list, errata_state)
        if errata_state == "applied"
          return []
        else
          return errata_list
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 app/lib/katello/util/errata.rb