Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4176 from samvera/valk-index-visibility
Index Visibility when using the valkyrie indexer
- Loading branch information
Showing
8 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyrax | ||
## | ||
# Indexes `*_groups`/`*_users` style permissions. We depend on these | ||
# permissions being up-to-date in the index to support `Hyrax::Ability`. | ||
# | ||
# @example | ||
# class MyIndexer < Hyrax::ValkyrieIndexer | ||
# include Hyrax::PermissionIndexer | ||
# end | ||
module PermissionIndexer | ||
def to_solr | ||
super.tap do |index_document| | ||
config = Hydra.config.permissions | ||
permissions = Hyrax::PermissionManager.new(resource: resource) | ||
|
||
index_document[config.edit.group] = permissions.edit_groups.to_a | ||
index_document[config.edit.individual] = permissions.edit_users.to_a | ||
index_document[config.read.group] = permissions.read_groups.to_a | ||
index_document[config.read.individual] = permissions.read_users.to_a | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Hyrax | ||
## | ||
# Indexes visibility of the resource; Blacklight depends on visibility being | ||
# present in the index to determine visibility of results and object show | ||
# views. | ||
# | ||
# @example | ||
# class MyIndexer < Hyrax::ValkyrieIndexer | ||
# include Hyrax::VisibilityIndexer | ||
# end | ||
module VisibilityIndexer | ||
def to_solr | ||
super.tap do |index_document| | ||
index_document[:visibility_ssi] = visibility_reader.read | ||
end | ||
end | ||
|
||
private | ||
|
||
def visibility_reader | ||
Hyrax::VisibilityReader.new(resource: resource) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'hyrax/specs/shared_specs' | ||
|
||
RSpec.describe Hyrax::PermissionIndexer do | ||
let(:indexer_class) do | ||
Class.new(Hyrax::ValkyrieIndexer) do | ||
include Hyrax::PermissionIndexer | ||
end | ||
end | ||
|
||
it_behaves_like 'a permission indexer' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'hyrax/specs/shared_specs' | ||
|
||
RSpec.describe Hyrax::VisibilityIndexer do | ||
let(:indexer_class) do | ||
Class.new(Hyrax::ValkyrieIndexer) do | ||
include Hyrax::VisibilityIndexer | ||
end | ||
end | ||
|
||
it_behaves_like 'a visibility indexer' | ||
end |