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

#add_managing_role_search_filter, #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



32
33
34
35
36
# File 'app/search_builders/hyrax/dashboard/collections_search_builder.rb', line 32

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



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

def models
  Hyrax::ModelRegistry.admin_set_classes + Hyrax::ModelRegistry.collection_classes
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)


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

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)
  ]
  Hyrax::ModelRegistry.admin_set_rdf_representations.each do |has_model|
    clauses += ['-' + ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: has_model, creator: current_user_key)]
  end
  solr_parameters[:fq] ||= []
  solr_parameters[:fq] += ["(#{clauses.join(' OR ')})"]
end