-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add metadata-only visibility to our models * add specs * first pass @ porting view labels from #701 * typo fixes and cleanup * 2 complex 4 rubo * helper specs * we need to enforce html_safe in the helper * some refactoring / make private things undiscoverable * ensure authenticated items are discoverable * fix + spec hyrax/permission_badge modification * improve SolrDocument#visibility * a little refactoring * regenerate thumbnails after clearing embargos/leases * remove embargo/lease info from catalog_controller index fields * cleanup catalog_helper_spec
- Loading branch information
1 parent
e412412
commit 0a51f39
Showing
30 changed files
with
620 additions
and
52 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
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 Spot | ||
module AbilityHelper | ||
# Select options for visibility. Overwriting the original method to add our metadata-only | ||
# visibility as an option. | ||
# | ||
# @return [Array<Array<String, String>>] | ||
def visibility_options(variant) | ||
options = [ | ||
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC, | ||
'metadata', | ||
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED, | ||
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE | ||
] | ||
|
||
case variant | ||
when :restrict | ||
options.delete_at(0) | ||
# options.reverse! | ||
when :loosen | ||
options.delete_at(2) | ||
end | ||
options.map { |value| [visibility_text(value), value] } | ||
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
class ClearExpiredEmbargoesAndLeasesJob < ApplicationJob | ||
def perform | ||
::Spot::EmbargoLeaseService.clear_all_expired | ||
::Spot::EmbargoLeaseService.clear_all_expired(regenerate_thumbnails: true) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
module Spot | ||
# Job that allows us to recreate thumbnails without having to run the entirety of | ||
# +CreateDerivativesJob+ which generates pyramidal tiffs, extracts full-text content, | ||
# basically a whole lot of work that we might not need to repeat. | ||
class RegenerateThumbnailJob < ApplicationJob | ||
def perform(work) | ||
return if work&.thumbnail_id.nil? | ||
file_set = FileSet.find(work.thumbnail_id) | ||
|
||
filename = Hyrax::DerivativePath.derivative_path_for_reference(file_set, 'thumbnail') | ||
Spot::Derivatives::ThumbnailService.new(file_set).create_derivatives(filename) | ||
|
||
file_set.reload | ||
file_set.update_index | ||
work.update_index | ||
|
||
true | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
module Spot | ||
# mixin to enable a 'metadata' visibility, intended to be interpreted as: | ||
# - the work's metadata is visible | ||
# - the work's files are only visible to admins | ||
module MetadataOnlyVisibility | ||
extend ActiveSupport::Concern | ||
|
||
# @return [void] | ||
# @see https://github.com/samvera/hydra-head/blob/v11.0.0/hydra-access-controls/app/models/concerns/hydra/access_controls/visibility.rb#L5-L18 | ||
def visibility=(value) | ||
return super unless value == 'metadata' | ||
|
||
# setup our discover/read groups | ||
metadata_only_visibility! | ||
|
||
# need to set this manually, as +super+ would be doing that work | ||
@visibility = value | ||
end | ||
|
||
# @return [String] | ||
# @see https://github.com/samvera/hydra-head/blob/v11.0.0/hydra-access-controls/app/models/concerns/hydra/access_controls/visibility.rb#L20-L28 | ||
def visibility | ||
return 'metadata' if !public? && discover_groups.include?(Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC) | ||
|
||
super | ||
end | ||
|
||
private | ||
|
||
def set_visibility_discover_groups | ||
set_discover_groups([Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC], discover_groups) | ||
end | ||
|
||
# Sets discover groups to +['public']+ and read groups to +['admin']+ only | ||
# | ||
# @return [void] | ||
def metadata_only_visibility! | ||
visibility_will_change! unless visibility == 'metadata' | ||
set_visibility_discover_groups | ||
set_read_groups([Ability.admin_group_name], read_groups) | ||
end | ||
|
||
# Be sure to remove the ['public'] from discover_groups if we're making this work private | ||
# | ||
# @return [void] | ||
def private_visibility! | ||
super | ||
set_discover_groups([], discover_groups) | ||
end | ||
|
||
# Ensure unauthenticated users are able to view metadata of authenticated items. | ||
def registered_visibility! | ||
super | ||
set_visibility_discover_groups | ||
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
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
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,8 @@ | ||
<div class="search-results-title-row"> | ||
<h4 class="search-result-title"><%= link_to(document.title_or_label, document) %></h4> | ||
<% if display_info_alert?(document) %> | ||
<div class="alert alert-warning" style="margin:0; padding:5px;"> | ||
<%= document_access_display_text(document) %> | ||
</div> | ||
<% end %> | ||
</div> |
Oops, something went wrong.