Module: Spotlight::AccessControlsEnforcementSearchBuilder

Extended by:
ActiveSupport::Concern
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



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

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



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

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

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