Sha256: 01f926cf73c21d694917f4c866979af8dfb39af3e3a8463fab8d55ba0fc53b1e

Contents?: true

Size: 1.03 KB

Versions: 36

Compression:

Stored size: 1.03 KB

Contents

module Hyrax
  module SearchFilters
    extend ActiveSupport::Concern
    include Hyrax::FilterByType
    include FilterSuppressed

    # TODO: move this to Hydra::AccessControlsEnforcement
    # @param access [String] what access level to set. Either 'read' or 'edit'
    # @return [SearchBuilder]
    def with_access(access)
      @discovery_permissions = Array.wrap(access)
      self
    end

    # Override Hydra::AccessControlsEnforcement (or Hydra::PolicyAwareAccessControlsEnforcement)
    # Allows admin users to see everything (don't apply any gated_discovery_filters for those users)
    def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
      return [] if ability.admin?
      super
    end

    private

      # TODO: could this be moved to Blacklight::AccessControls::Enforcement?
      def current_user_key
        current_user.user_key
      end

      # TODO: could this be moved to Blacklight::AccessControls::Enforcement?
      def current_user
        scope.current_user
      end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.3.3 app/search_builders/hyrax/search_filters.rb
hyrax-2.3.2 app/search_builders/hyrax/search_filters.rb
hyrax-2.3.1 app/search_builders/hyrax/search_filters.rb
hyrax-2.3.0 app/search_builders/hyrax/search_filters.rb
hyrax-2.2.4 app/search_builders/hyrax/search_filters.rb
hyrax-2.2.3 app/search_builders/hyrax/search_filters.rb
hyrax-2.2.2 app/search_builders/hyrax/search_filters.rb
hyrax-2.2.1 app/search_builders/hyrax/search_filters.rb
hyrax-2.2.0 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0.rc4 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0.rc3 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0.rc2 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0.rc1 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0.beta2 app/search_builders/hyrax/search_filters.rb
hyrax-2.1.0.beta1 app/search_builders/hyrax/search_filters.rb