Sha256: 88f985854c5f181036ae547c4b875169985a5cf2d9e0bfc3ae2889eb462b4582

Contents?: true

Size: 1.66 KB

Versions: 1

Compression:

Stored size: 1.66 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.

module Katello
  module Authorization::System
    extend ActiveSupport::Concern

    include Authorizable
    include Katello::Authorization

    def readable?
      authorized?(:view_content_hosts)
    end

    def editable?
      authorized?(:edit_content_hosts)
    end

    def deletable?
      authorized?(:destroy_content_hosts)
    end

    module ClassMethods
      def readable_search_filters(_org)
        {:or => [
          {:terms => {:environment_id => KTEnvironment.readable.pluck(:id) }}
        ]
        }
      end

      def readable
        authorized(:view_content_hosts)
      end

      def readable?
        User.current.can?(:view_content_hosts)
      end

      def editable
        authorized(:edit_content_hosts)
      end

      def deletable
        authorized(:destroy_content_hosts)
      end

      def any_editable?
        authorized(:edit_content_hosts).count > 0
      end

      def all_editable?(content_view, environments)
        systems_query = System.where(:content_view_id => content_view, :environment_id => environments)
        systems_query.count == systems_query.editable.count
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 app/models/katello/authorization/system.rb