Sha256: 084491292b199427834dc75feb5f07f2d28d6ae16db80a08e5b5c603bd5fc80f

Contents?: true

Size: 1.43 KB

Versions: 131

Compression:

Stored size: 1.43 KB

Contents

module Katello
  module Authorization
    module Product
      extend ActiveSupport::Concern

      include Authorizable

      def readable?
        authorized?(:view_products)
      end

      def syncable?
        authorized?(:sync_products)
      end

      def editable?
        authorized?(:edit_products)
      end

      def deletable?
        promoted_repos = repositories.select { |repo| repo.promoted? }
        authorized?(:destroy_products) && promoted_repos.empty?
      end

      module ClassMethods
        def readable
          authorized(:view_products)
        end

        def editable
          authorized(:edit_products)
        end

        def deletable
          authorized(:destroy_products)
        end

        def syncable
          authorized(:sync_products)
        end

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

        def readable_repositories(repo_ids = nil)
          query = Katello::Repository.all

          if repo_ids
            query = query.where(:id => repo_ids)
          end

          query.joins(:content_view_version)
               .where("#{::Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.default.pluck(:id))
               .in_product(::Katello::Product.readable)
        end

        def syncable?
          ::User.current.can?(:sync_products)
        end
      end # ClassMethods
    end # Product
  end # Authorization
end # Katello

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
katello-4.3.0.rc3 app/models/katello/authorization/product.rb
katello-4.3.0.rc2.1 app/models/katello/authorization/product.rb
katello-4.3.0.rc2 app/models/katello/authorization/product.rb
katello-4.3.0.rc1 app/models/katello/authorization/product.rb
katello-4.2.1 app/models/katello/authorization/product.rb
katello-4.2.0.1 app/models/katello/authorization/product.rb
katello-4.2.0.1.rc3 app/models/katello/authorization/product.rb
katello-4.2.0.1.rc2 app/models/katello/authorization/product.rb
katello-4.2.0.rc2 app/models/katello/authorization/product.rb
katello-4.2.0.rc1 app/models/katello/authorization/product.rb
katello-3.16.2 app/models/katello/authorization/product.rb
katello-3.16.1.2 app/models/katello/authorization/product.rb
katello-3.16.1.1 app/models/katello/authorization/product.rb
katello-3.16.1 app/models/katello/authorization/product.rb
katello-3.17.0.rc1 app/models/katello/authorization/product.rb
katello-3.16.0 app/models/katello/authorization/product.rb
katello-3.16.0.rc5.1 app/models/katello/authorization/product.rb
katello-3.16.0.rc5 app/models/katello/authorization/product.rb
katello-3.16.0.rc4.1 app/models/katello/authorization/product.rb
katello-3.15.3.1 app/models/katello/authorization/product.rb