Class: Hyrax::My::CollectionsSearchBuilder

Inherits:
CollectionSearchBuilder 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 Attribute Summary

Attributes inherited from CollectionSearchBuilder

#access

Instance Method Summary collapse

Methods included from FilterByType

#filter_models

Methods included from SearchBuilderBehavior

#discovery_permissions

Methods inherited from CollectionSearchBuilder

#add_sorting_to_solr, #discovery_permissions, #gated_discovery_filters, #sort_field, #with_access

Instance Method Details

#modelsArray<Class>

This overrides the models in FilterByType

Returns:

  • (Array<Class>)

    a list of classes to include


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

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)

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

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