Module: Spotlight::AccessControlsEnforcementSearchBuilder

Extended by:
ActiveSupport::Concern
Included in:
SearchBuilder
Defined in:
app/models/concerns/spotlight/access_controls_enforcement_search_builder.rb

Overview

Enforce exhibit visibility for index queries

Instance Method Summary collapse

Instance Method Details

#apply_exhibit_resources_filter(solr_params) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'app/models/concerns/spotlight/access_controls_enforcement_search_builder.rb', line 20

def apply_exhibit_resources_filter(solr_params)
  return unless current_exhibit

  current_exhibit.solr_data.each do |facet_field, values|
    Array(values).each do |value|
      solr_params.append_filter_query send(:facet_value_to_fq_string, facet_field, value)
    end
  end
end

#apply_permissive_visibility_filter(solr_params) ⇒ Object

Adds a filter that excludes resources that have been marked as not-visible



13
14
15
16
17
18
# File 'app/models/concerns/spotlight/access_controls_enforcement_search_builder.rb', line 13

def apply_permissive_visibility_filter(solr_params)
  return unless current_exhibit
  return if !blacklight_params[:public] && scope&.context&.key?(:current_ability) && scope.context[:current_ability].can?(:curate, current_exhibit)

  solr_params.append_filter_query "-#{blacklight_config.document_model.visibility_field(current_exhibit)}:false"
end