Sha256: 396ec82bc02b3cf9c4cf57b53e82a74e23f472462456dde190a52676d12fda9f

Contents?: true

Size: 1.61 KB

Versions: 26

Compression:

Stored size: 1.61 KB

Contents

module Katello
  module Authorization::Repository
    extend ActiveSupport::Concern

    delegate :editable?, to: :product

    def deletable?
      product.editable? && !promoted?
    end

    def redhat_deletable?
      !self.promoted? && self.product.editable?
    end

    def readable?
      self.class.readable.where("#{self.class.table_name}.id" => self.id).any?
    end

    delegate :syncable?, to: :product

    module ClassMethods
      def readable
        in_products = Repository.in_product(Katello::Product.authorized(:view_products)).select(:id)
        in_environments = Repository.where(:environment_id => Katello::KTEnvironment.authorized(:view_lifecycle_environments)).select(:id)
        in_content_views = Repository.joins(:content_view_repositories).where("#{ContentViewRepository.table_name}.content_view_id" => Katello::ContentView.readable).select(:id)
        in_versions = Repository.joins(:content_view_version).where("#{Katello::ContentViewVersion.table_name}.content_view_id" => Katello::ContentView.readable).select(:id)
        joins(:root).where("#{Repository.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions, in_environments)
      end

      def exportable
        in_product(Katello::Product.exportable)
      end

      def deletable
        in_product(Katello::Product.authorized(:destroy_products))
      end

      def syncable
        in_product(Katello::Product.authorized(:sync_products))
      end

      def editable
        in_product(Katello::Product.editable)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
katello-3.18.5 app/models/katello/authorization/repository.rb
katello-3.18.4 app/models/katello/authorization/repository.rb
katello-3.18.3.1 app/models/katello/authorization/repository.rb
katello-4.0.1.1 app/models/katello/authorization/repository.rb
katello-3.18.3 app/models/katello/authorization/repository.rb
katello-4.0.1 app/models/katello/authorization/repository.rb
katello-4.0.0 app/models/katello/authorization/repository.rb
katello-4.0.0.rc3.1 app/models/katello/authorization/repository.rb
katello-4.0.0.rc3 app/models/katello/authorization/repository.rb
katello-3.18.2.1 app/models/katello/authorization/repository.rb
katello-3.18.2 app/models/katello/authorization/repository.rb
katello-3.17.3 app/models/katello/authorization/repository.rb
katello-4.0.0.rc2 app/models/katello/authorization/repository.rb
katello-3.18.1.1 app/models/katello/authorization/repository.rb
katello-3.17.2 app/models/katello/authorization/repository.rb
katello-4.0.0.rc1 app/models/katello/authorization/repository.rb
katello-3.18.1 app/models/katello/authorization/repository.rb
katello-3.18.0 app/models/katello/authorization/repository.rb
katello-3.17.1 app/models/katello/authorization/repository.rb
katello-3.18.0.rc2.1 app/models/katello/authorization/repository.rb