Sha256: 463924ffae6dc11d72800497d4afb963240fb6eaf89879c14dbaeebdbc1f109b

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 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.where(:product_id => Katello::Product.authorized(:view_products)).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)
        where("#{self.table_name}.id in (?) or #{self.table_name}.id in (?) or #{self.table_name}.id in (?)", in_products, in_content_views, in_versions)
      end

      def deletable
        where(:product_id => Katello::Product.authorized(:destroy_products))
      end

      def syncable
        where(:product_id => Katello::Product.authorized(:sync_products))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katello-3.7.1.1 app/models/katello/authorization/repository.rb
katello-3.7.1 app/models/katello/authorization/repository.rb
katello-3.7.0 app/models/katello/authorization/repository.rb
katello-3.8.0.rc1 app/models/katello/authorization/repository.rb
katello-3.7.0.rc2 app/models/katello/authorization/repository.rb
katello-3.7.0.rc1 app/models/katello/authorization/repository.rb
katello-3.5.2 app/models/katello/authorization/repository.rb