Sha256: 747ae883903047c393d545b251df6755733a49af3aedbe751399d81f237dfecc

Contents?: true

Size: 1008 Bytes

Versions: 36

Compression:

Stored size: 1008 Bytes

Contents

# Added to allow for the My controller to show only things I have edit access to
class Hyrax::My::CollectionsSearchBuilder < ::SearchBuilder
  include Hyrax::My::SearchBuilderBehavior
  include Hyrax::FilterByType

  self.default_processor_chain += [:show_only_collections_deposited_by_current_user]

  # adds a filter to the solr_parameters that filters the collections and admin sets
  # the current user has deposited
  # @param [Hash] solr_parameters
  def show_only_collections_deposited_by_current_user(solr_parameters)
    clauses = [
      ActiveFedora::SolrQueryBuilder.construct_query_for_rel(depositor: current_user_key),
      ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::AdminSet.to_s, creator: current_user_key)
    ]
    solr_parameters[:fq] ||= []
    solr_parameters[:fq] += ["(#{clauses.join(' OR ')})"]
  end

  # This overrides the models in FilterByType
  # @return [Array<Class>] a list of classes to include
  def models
    [::AdminSet, ::Collection]
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.9.5 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.9.4 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.9.3 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.9.2 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.9.1 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.9.0 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.8.0 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.7.2 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.7.1 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.7.0 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.6.0 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-3.0.0.pre.rc1 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-3.0.0.pre.beta3 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.5.1 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.5.0 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-3.0.0.pre.beta2 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.4.1 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-3.0.0.pre.beta1 app/search_builders/hyrax/my/collections_search_builder.rb
hyrax-2.4.0 app/search_builders/hyrax/my/collections_search_builder.rb