Class: Hyrax::My::CollectionsSearchBuilder

Inherits:
SearchBuilder
  • Object
show all
Includes:
FilterByType, SearchBuilderBehavior
Defined in:
app/search_builders/hyrax/my/collections_search_builder.rb

Overview

Added to allow for the My controller to show only things I have edit access to

Instance Method Summary collapse

Methods included from FilterByType

#filter_models

Methods included from SearchBuilderBehavior

#discovery_permissions

Instance Method Details

#modelsArray<Class>

This overrides the models in FilterByType

Returns:

  • (Array<Class>)

    a list of classes to include



22
23
24
# File 'app/search_builders/hyrax/my/collections_search_builder.rb', line 22

def models
  [::AdminSet, ::Collection]
end

#show_only_collections_deposited_by_current_user(solr_parameters) ⇒ Object

adds a filter to the solr_parameters that filters the collections and admin sets the current user has deposited

Parameters:

  • solr_parameters (Hash)


11
12
13
14
15
16
17
18
# File 'app/search_builders/hyrax/my/collections_search_builder.rb', line 11

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