Class: Hyrax::Dashboard::CollectionsSearchBuilder

Inherits:
CollectionSearchBuilder show all
Includes:
ManagedSearchFilters
Defined in:
app/search_builders/hyrax/dashboard/collections_search_builder.rb

Instance Attribute Summary

Attributes inherited from CollectionSearchBuilder

#access

Instance Method Summary collapse

Methods included from ManagedSearchFilters

#apply_group_permissions, #discovery_permissions

Methods inherited from CollectionSearchBuilder

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

Methods included from FilterByType

#filter_models

Instance Method Details

#apply_collection_deposit_permissions(_permission_types, _ability = current_ability) ⇒ Array{String}

Include all admin sets and collections the user has deposit permission for.

Returns:

  • (Array{String})

    values are lucence syntax term queries suitable for :fq


29
30
31
32
33
# File 'app/search_builders/hyrax/dashboard/collections_search_builder.rb', line 29

def apply_collection_deposit_permissions(_permission_types, _ability = current_ability)
  collection_ids = collection_ids_for_deposit
  return [] if collection_ids.empty?
  ["{!terms f=id}#{collection_ids.join(',')}"]
end

#modelsObject

This overrides the models in FilterByType


10
11
12
# File 'app/search_builders/hyrax/dashboard/collections_search_builder.rb', line 10

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

#show_only_managed_collections_for_non_admins(solr_parameters) ⇒ Object

adds a filter to exclude collections and admin sets created by the current user if the current user is not an admin.

Parameters:

  • solr_parameters (Hash)

17
18
19
20
21
22
23
24
25
# File 'app/search_builders/hyrax/dashboard/collections_search_builder.rb', line 17

def show_only_managed_collections_for_non_admins(solr_parameters)
  return if current_ability.admin?
  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