diff --git a/src/app/controllers/api/system_group_errata_controller.rb b/src/app/controllers/api/system_group_errata_controller.rb index 4411409458f..6f10582dfd0 100644 --- a/src/app/controllers/api/system_group_errata_controller.rb +++ b/src/app/controllers/api/system_group_errata_controller.rb @@ -9,6 +9,8 @@ # have received a copy of GPLv2 along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. +require 'util/errata' + class Api::SystemGroupErrataController < Api::ApiController respond_to :json @@ -53,7 +55,7 @@ def require_errata end end - include ErrataModule + include Katello::Errata def get_errata filter_type="All" filter_type = filter_type || "All" diff --git a/src/app/controllers/errata_module.rb b/src/app/controllers/errata_module.rb deleted file mode 100644 index 6c5c8c8a25e..00000000000 --- a/src/app/controllers/errata_module.rb +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright 2011 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 ErrataModule contains methods that are common for supporting errata in -# controllers such as SystemErrataController and SystemGroupErrataController. -module ErrataModule - 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{ |erratum| - if erratum.class.name == "Glue::Pulp::Errata" - if erratum.type == pulp_filter_type - filtered_list << erratum - end - else - if erratum["type"] == pulp_filter_type - filtered_list << erratum - 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 == "bug" - return Glue::Pulp::Errata::BUGZILLA - elsif filter_type == "enhancement" - return Glue::Pulp::Errata::ENHANCEMENT - elsif filter_type == "security" - return Glue::Pulp::Errata::SECURITY - end - end - - def filter_by_state errata_list, errata_state - if errata_state == "applied" - return [] - else - return errata_list - end - end - -end diff --git a/src/app/controllers/system_errata_controller.rb b/src/app/controllers/system_errata_controller.rb index f9ef9072787..04589b56342 100644 --- a/src/app/controllers/system_errata_controller.rb +++ b/src/app/controllers/system_errata_controller.rb @@ -10,6 +10,8 @@ # have received a copy of GPLv2 along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. +require 'util/errata' + class SystemErrataController < ApplicationController before_filter :find_system, :only =>[:install, :index, :items, :status] @@ -84,7 +86,7 @@ def status private include SortColumnList - include ErrataModule + include Katello::Errata def get_errata start, finish, filter_type="All", errata_state="outstanding" types = [Glue::Pulp::Errata::SECURITY, Glue::Pulp::Errata::ENHANCEMENT, Glue::Pulp::Errata::BUGZILLA] diff --git a/src/app/controllers/system_group_errata_controller.rb b/src/app/controllers/system_group_errata_controller.rb index 06f8d0b84ff..082f121dbef 100644 --- a/src/app/controllers/system_group_errata_controller.rb +++ b/src/app/controllers/system_group_errata_controller.rb @@ -10,6 +10,8 @@ # have received a copy of GPLv2 along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. +require 'util/errata' + class SystemGroupErrataController < ApplicationController helper SystemErrataHelper @@ -80,7 +82,7 @@ def status private include SortColumnList - include ErrataModule + include Katello::Errata def get_errata start, finish, filter_type="All", errata_state="outstanding" types = [Glue::Pulp::Errata::SECURITY, Glue::Pulp::Errata::ENHANCEMENT, Glue::Pulp::Errata::BUGZILLA] diff --git a/src/lib/util/errata.rb b/src/lib/util/errata.rb new file mode 100644 index 00000000000..1ff8c428ea2 --- /dev/null +++ b/src/lib/util/errata.rb @@ -0,0 +1,61 @@ +# +# Copyright 2011 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 SystemGroupErrataController) +module Katello + 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{ |erratum| + if erratum.class.name == "Glue::Pulp::Errata" + if erratum.type == pulp_filter_type + filtered_list << erratum + end + else + if erratum["type"] == pulp_filter_type + filtered_list << erratum + 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 == "bug" + return Glue::Pulp::Errata::BUGZILLA + elsif filter_type == "enhancement" + return Glue::Pulp::Errata::ENHANCEMENT + elsif filter_type == "security" + return Glue::Pulp::Errata::SECURITY + end + end + + def filter_by_state errata_list, errata_state + if errata_state == "applied" + return [] + else + return errata_list + end + end + + end +end \ No newline at end of file