hyrax 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dassie/config/initializers/hyrax.rb +11 -1
- data/.gitignore +3 -0
- data/.regen +1 -1
- data/.rubocop_fixme.yml +3 -1
- data/Dockerfile +2 -1
- data/app/actors/hyrax/actors/file_actor.rb +6 -4
- data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
- data/app/assets/javascripts/hyrax/analytics_events.js +8 -2
- data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
- data/app/controllers/concerns/hyrax/controller.rb +21 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -19
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +12 -19
- data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
- data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
- data/app/controllers/hyrax/citations_controller.rb +1 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +19 -10
- data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +1 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +9 -5
- data/app/helpers/hyrax/collections_helper.rb +14 -0
- data/app/helpers/hyrax/membership_helper.rb +1 -1
- data/app/helpers/hyrax/trophy_helper.rb +1 -1
- data/app/helpers/hyrax/url_helper.rb +1 -1
- data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
- data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
- data/app/indexers/hyrax/file_set_indexer.rb +1 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -1
- data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +6 -6
- data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
- data/app/inputs/controlled_vocabulary_input.rb +2 -0
- data/app/jobs/change_depositor_event_job.rb +47 -0
- data/app/jobs/characterize_job.rb +38 -2
- data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +2 -1
- data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
- data/app/jobs/inherit_permissions_job.rb +1 -1
- data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
- data/app/jobs/valkyrie_ingest_job.rb +84 -16
- data/app/models/admin_set.rb +2 -2
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/collection_behavior.rb +2 -2
- data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
- data/app/models/concerns/hyrax/solr_document/metadata.rb +1 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
- data/app/models/hyrax/administrative_set.rb +36 -1
- data/app/models/hyrax/collection_type.rb +2 -2
- data/app/models/hyrax/file_metadata.rb +5 -1
- data/app/models/hyrax/file_set.rb +42 -1
- data/app/models/hyrax/pcdm_collection.rb +56 -0
- data/app/models/hyrax/permission_template.rb +11 -5
- data/app/models/hyrax/work.rb +91 -0
- data/app/models/proxy_deposit_request.rb +1 -1
- data/app/presenters/hyrax/admin_set_presenter.rb +2 -2
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +2 -2
- data/app/presenters/hyrax/work_show_presenter.rb +7 -3
- data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +11 -4
- data/app/services/hyrax/access_control_list.rb +13 -0
- data/app/services/hyrax/admin_set_create_service.rb +21 -37
- data/app/services/hyrax/change_content_depositor_service.rb +2 -2
- data/app/services/hyrax/change_depositor_service.rb +70 -0
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +1 -1
- data/app/services/hyrax/collections/nested_collection_query_service.rb +23 -11
- data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
- data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
- data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
- data/app/services/hyrax/default_middleware_stack.rb +3 -0
- data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
- data/app/services/hyrax/file_set_type_service.rb +2 -5
- data/app/services/hyrax/listeners/file_metadata_listener.rb +20 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +23 -3
- data/app/services/hyrax/listeners/metadata_index_listener.rb +39 -0
- data/app/services/hyrax/listeners/proxy_deposit_listener.rb +14 -8
- data/app/services/hyrax/location_service.rb +33 -0
- data/app/services/hyrax/multiple_membership_checker.rb +44 -1
- data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
- data/app/services/hyrax/simple_schema_loader.rb +5 -1
- data/app/services/hyrax/solr_query_service.rb +12 -7
- data/app/services/hyrax/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/work_uploads_handler.rb +0 -10
- data/app/validators/hyrax/collection_membership_validator.rb +38 -0
- data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +4 -0
- data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_workflow.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/base/_form.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +21 -15
- data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +2 -2
- data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
- data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/my/collections/index.html.erb +3 -2
- data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
- data/app/views/hyrax/my/works/index.html.erb +4 -2
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/README.md +22 -1
- data/config/initializers/listeners.rb +0 -1
- data/config/locales/hyrax.de.yml +6 -5
- data/config/locales/hyrax.en.yml +30 -28
- data/config/locales/hyrax.es.yml +10 -9
- data/config/locales/hyrax.fr.yml +2 -1
- data/config/locales/hyrax.it.yml +3 -2
- data/config/locales/hyrax.pt-BR.yml +2 -1
- data/config/locales/hyrax.zh.yml +2 -1
- data/config/metadata/basic_metadata.yaml +2 -0
- data/config/metadata/core_metadata.yaml +1 -1
- data/docker-compose.yml +46 -42
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +2 -0
- data/lib/hyrax/configuration.rb +10 -0
- data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
- data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
- data/lib/hyrax/controlled_vocabularies.rb +1 -0
- data/lib/hyrax/publisher.rb +45 -0
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -4
- data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
- data/lib/hyrax/transactions/admin_set_create.rb +2 -1
- data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
- data/lib/hyrax/transactions/admin_set_update.rb +21 -0
- data/lib/hyrax/transactions/collection_destroy.rb +22 -0
- data/lib/hyrax/transactions/collection_update.rb +3 -2
- data/lib/hyrax/transactions/container.rb +87 -23
- data/lib/hyrax/transactions/create_work.rb +3 -0
- data/lib/hyrax/transactions/destroy_work.rb +3 -0
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
- data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
- data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
- data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
- data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/save.rb +24 -6
- data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
- data/lib/hyrax/transactions/steps/save_work.rb +3 -0
- data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
- data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
- data/lib/hyrax/transactions/update_work.rb +4 -3
- data/lib/hyrax/transactions/work_create.rb +1 -1
- data/lib/hyrax/transactions/work_destroy.rb +2 -1
- data/lib/hyrax/transactions/work_update.rb +19 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/wings/attribute_transformer.rb +5 -1
- data/lib/wings/setup.rb +3 -1
- data/lib/wings/valkyrie/query_service.rb +2 -1
- data/lib/wings/valkyrie/storage.rb +7 -1
- data/template.rb +1 -1
- metadata +24 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fa4543b3224a41244d522ea1eedff364bc5a611766952b7f75472c438b4fff1
|
4
|
+
data.tar.gz: 19c28428038b672908944c5ad30dd144eabc934e80ecfa5c1d080d6144e7df9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 697a6d11f891fe1a0c42997fb80d49ab94810779745c7472670b9c32bd09d49283ceddb5736d1d5652efc9d5ac21e9dffb416fa2e75c300954c5cb529034a82c
|
7
|
+
data.tar.gz: efe3443f9e7e285713ff9c53661f5202748fc0613c9282dc07d834e8802c052a3551d617460d2b1975493b9ab065b0d9c66e9bfd0561fe1aef996821093f6526
|
@@ -15,6 +15,8 @@ Hyrax.config do |config|
|
|
15
15
|
config.register_curation_concern :monograph
|
16
16
|
|
17
17
|
config.iiif_image_server = true
|
18
|
+
config.work_requires_files = false
|
19
|
+
config.citations = true
|
18
20
|
|
19
21
|
# Returns a URL that resolves to an image provided by a IIIF image server
|
20
22
|
config.iiif_image_url_builder = lambda do |file_id, base_url, size, format|
|
@@ -38,14 +40,22 @@ Hyrax.config do |config|
|
|
38
40
|
config.browse_everything = nil
|
39
41
|
end
|
40
42
|
|
43
|
+
# config.geonames_username = ''
|
44
|
+
|
41
45
|
##
|
42
46
|
# Set the system-wide virus scanner
|
43
47
|
config.virus_scanner = Hyrax::VirusScanner
|
44
48
|
|
45
49
|
##
|
46
|
-
# To index to the Valkyrie core, uncomment the following
|
50
|
+
# To index to the Valkyrie core, uncomment the following lines.
|
47
51
|
# config.query_index_from_valkyrie = true
|
48
52
|
# config.index_adapter = :solr_index
|
53
|
+
|
54
|
+
##
|
55
|
+
# NOTE: To Valkyrie works, use Monograph which is_a Hyrax::Work is_a Valkyrie::Resource
|
56
|
+
# To use Valkyrie models, uncomment the following lines.
|
57
|
+
# config.collection_model = 'Hyrax::PcdmCollection'
|
58
|
+
# config.admin_set_model = 'Hyrax::AdministrativeSet'
|
49
59
|
end
|
50
60
|
|
51
61
|
Date::DATE_FORMATS[:standard] = "%m/%d/%Y"
|
data/.gitignore
CHANGED
data/.regen
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
41
|
data/.rubocop_fixme.yml
CHANGED
@@ -63,6 +63,7 @@ RSpec/ExampleLength:
|
|
63
63
|
- 'spec/jobs/content_restored_version_event_job_spec.rb'
|
64
64
|
- 'spec/jobs/content_new_version_event_job_spec.rb'
|
65
65
|
- 'spec/jobs/content_depositor_change_event_job_spec.rb'
|
66
|
+
- 'spec/jobs/change_depositor_event_job_spec.rb'
|
66
67
|
- 'spec/jobs/content_deposit_event_job_spec.rb'
|
67
68
|
- 'spec/jobs/content_delete_event_job_spec.rb'
|
68
69
|
- 'spec/jobs/ingest_file_job_spec.rb'
|
@@ -100,7 +101,6 @@ RSpec/SubjectStub:
|
|
100
101
|
- 'spec/models/hyrax/operation_spec.rb'
|
101
102
|
- 'spec/controllers/hyrax/accepts_batches_controller_spec.rb'
|
102
103
|
- 'spec/indexers/hyrax/repository_reindexer_spec.rb'
|
103
|
-
- 'spec/jobs/content_depositor_change_event_job_spec.rb'
|
104
104
|
- 'spec/lib/hyrax/analytics_spec.rb'
|
105
105
|
- 'spec/models/job_io_wrapper_spec.rb'
|
106
106
|
- 'spec/search_builders/hyrax/abstract_type_relation_spec.rb'
|
@@ -114,6 +114,8 @@ RSpec/AnyInstance:
|
|
114
114
|
- 'spec/controllers/hyrax/batch_edits_controller_spec.rb'
|
115
115
|
- 'spec/controllers/hyrax/stats_controller_spec.rb'
|
116
116
|
- 'spec/controllers/hyrax/users_controller_spec.rb'
|
117
|
+
- 'spec/hyrax/transactions/steps/delete_access_control_spec.rb'
|
118
|
+
- 'spec/hyrax/transactions/steps/save_access_control_spec.rb'
|
117
119
|
- 'spec/jobs/content_restored_version_event_job_spec.rb'
|
118
120
|
- 'spec/jobs/file_set_attached_event_job_spec.rb'
|
119
121
|
- 'spec/jobs/hyrax/grant_edit_to_members_job_spec.rb'
|
data/Dockerfile
CHANGED
@@ -7,6 +7,7 @@ ARG EXTRA_APK_PACKAGES="git"
|
|
7
7
|
RUN apk --no-cache upgrade && \
|
8
8
|
apk --no-cache add build-base \
|
9
9
|
curl \
|
10
|
+
gcompat \
|
10
11
|
imagemagick \
|
11
12
|
tzdata \
|
12
13
|
nodejs \
|
@@ -57,7 +58,7 @@ USER app
|
|
57
58
|
|
58
59
|
RUN mkdir -p /app/fits && \
|
59
60
|
cd /app/fits && \
|
60
|
-
wget https://github.com/harvard-lts/fits/releases/download/1.5.
|
61
|
+
wget https://github.com/harvard-lts/fits/releases/download/1.5.1/fits-1.5.1.zip -O fits.zip && \
|
61
62
|
unzip fits.zip && \
|
62
63
|
rm fits.zip && \
|
63
64
|
chmod a+x /app/fits/fits.sh
|
@@ -76,6 +76,8 @@ module Hyrax
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def perform_ingest_file_through_valkyrie(io) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
79
|
+
Deprecation.warn "FileActor support for Valkyrie was experimental and " \
|
80
|
+
"is slated to be removed in favor of WorkUploadsHandler."
|
79
81
|
file =
|
80
82
|
begin
|
81
83
|
Hyrax.storage_adapter.upload(resource: file_set, file: io, original_filename: io.original_name, use: relation)
|
@@ -85,12 +87,12 @@ module Hyrax
|
|
85
87
|
end
|
86
88
|
file_metadata = Hyrax.custom_queries.find_file_metadata_by(id: file.id)
|
87
89
|
create_version(file_metadata, user)
|
88
|
-
|
89
|
-
file_set.file_ids << id
|
90
|
-
file_set.original_file_id = id
|
90
|
+
|
91
|
+
file_set.file_ids << file_metadata.id
|
92
|
+
file_set.original_file_id = file_metadata.id
|
91
93
|
Hyrax.persister.save(resource: file_set)
|
92
94
|
Hyrax.publisher.publish('object.metadata.updated', object: file_set, user: user)
|
93
|
-
CharacterizeJob.perform_later(file_set, id.to_s, pathhint(io))
|
95
|
+
CharacterizeJob.perform_later(file_set, file_metadata.id.to_s, pathhint(io))
|
94
96
|
file_metadata
|
95
97
|
end
|
96
98
|
|
@@ -1,17 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
module Actors
|
4
|
-
##
|
5
|
-
# @deprecated transfer requests are now carried out in response to published
|
6
|
-
# 'object.deposited' events.
|
7
|
-
#
|
8
4
|
# Notify the provided owner that their proxy wants to make a
|
9
5
|
# deposit on their behalf
|
10
6
|
class TransferRequestActor < AbstractActor
|
11
7
|
# @param [Hyrax::Actors::Environment] env
|
12
8
|
# @return [Boolean] true if create was successful
|
13
9
|
def create(env)
|
14
|
-
Deprecation.warn('Use Hyrax::Listeners::ProxyDepositListener instead.')
|
15
10
|
next_actor.create(env) && create_proxy_deposit_request(env)
|
16
11
|
end
|
17
12
|
|
@@ -20,8 +15,9 @@ module Hyrax
|
|
20
15
|
def create_proxy_deposit_request(env)
|
21
16
|
proxy = env.curation_concern.on_behalf_of
|
22
17
|
return true if proxy.blank?
|
23
|
-
|
24
|
-
|
18
|
+
work = env.curation_concern
|
19
|
+
user = ::User.find_by_user_key(proxy)
|
20
|
+
Hyrax::ChangeDepositorService.call(work, user, false)
|
25
21
|
true
|
26
22
|
end
|
27
23
|
end
|
@@ -8,7 +8,7 @@ class TrackingTags {
|
|
8
8
|
return _paq;
|
9
9
|
}
|
10
10
|
else {
|
11
|
-
return _gaq
|
11
|
+
return _gaq;
|
12
12
|
}
|
13
13
|
}
|
14
14
|
|
@@ -42,6 +42,9 @@ function trackAnalyticsEvents() {
|
|
42
42
|
|
43
43
|
function setupTracking() {
|
44
44
|
var provider = $('meta[name="analytics-provider"]').prop('content')
|
45
|
+
if (provider === undefined) {
|
46
|
+
return;
|
47
|
+
}
|
45
48
|
window.trackingTags = new TrackingTags(provider)
|
46
49
|
trackPageView()
|
47
50
|
trackAnalyticsEvents()
|
@@ -59,6 +62,9 @@ if (typeof Turbolinks !== 'undefined') {
|
|
59
62
|
|
60
63
|
$(document).on('click', '#file_download', function(e) {
|
61
64
|
var provider = $('meta[name="analytics-provider"]').prop('content')
|
65
|
+
if (provider === undefined) {
|
66
|
+
return;
|
67
|
+
}
|
62
68
|
window.trackingTags = new TrackingTags(provider)
|
63
69
|
window.trackingTags.analytics().push([trackingTags.trackEvent(), 'file-set', 'file-set-download', $(this).data('label')]);
|
64
70
|
window.trackingTags.analytics().push([trackingTags.trackEvent(), 'file-set-in-work', 'file-set-in-work-download', $(this).data('work-id')]);
|
@@ -66,4 +72,4 @@ $(document).on('click', '#file_download', function(e) {
|
|
66
72
|
window.trackingTags.analytics().push([trackingTags.trackEvent(), 'file-set-in-collection', 'file-set-in-collection-download', collection]);
|
67
73
|
window.trackingTags.analytics().push([trackingTags.trackEvent(), 'work-in-collection', 'work-in-collection-download', collection]);
|
68
74
|
});
|
69
|
-
});
|
75
|
+
});
|
@@ -40,11 +40,9 @@ export default class LinkedData {
|
|
40
40
|
// Called when Select2 is created to allow the user to initialize the
|
41
41
|
// selection based on the value of the element select2 is attached to.
|
42
42
|
// Essentially this is an id->object mapping function.
|
43
|
-
|
44
|
-
// TODO: Presently we're just showing a URI, but we should show the label.
|
45
43
|
var data = {
|
46
44
|
id: element.val(),
|
47
|
-
label: element.val()
|
45
|
+
label: element[0].dataset.label || element.val()
|
48
46
|
};
|
49
47
|
callback(data);
|
50
48
|
},
|
@@ -17,6 +17,9 @@ module Hyrax::Controller
|
|
17
17
|
helper_method :create_work_presenter
|
18
18
|
before_action :set_locale
|
19
19
|
before_action :check_read_only, except: [:show, :index]
|
20
|
+
|
21
|
+
class_attribute :search_service_class
|
22
|
+
self.search_service_class = Hyrax::SearchService
|
20
23
|
end
|
21
24
|
|
22
25
|
# Provide a place for Devise to send the user to after signing in
|
@@ -51,6 +54,24 @@ module Hyrax::Controller
|
|
51
54
|
blacklight_config.repository
|
52
55
|
end
|
53
56
|
|
57
|
+
# @note for Blacklight 6/7 compatibility
|
58
|
+
def search_results(*args)
|
59
|
+
return super if defined?(super) # use the upstream if present (e.g. in BL 6)
|
60
|
+
|
61
|
+
search_service(*args).search_results
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# @note for Blacklight 6/7 compatibility
|
66
|
+
def search_service(**search_params)
|
67
|
+
return super if defined?(super) && search_params.empty?
|
68
|
+
|
69
|
+
search_service_class.new(config: blacklight_config,
|
70
|
+
scope: self,
|
71
|
+
user_params: search_params,
|
72
|
+
search_builder_class: search_builder_class)
|
73
|
+
end
|
74
|
+
|
54
75
|
private
|
55
76
|
|
56
77
|
##
|
@@ -55,21 +55,12 @@ module Hyrax
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def create
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
after_create_response
|
58
|
+
case curation_concern
|
59
|
+
when ActiveFedora::Base
|
60
|
+
original_input_params_for_form = params[hash_key_for_curation_concern].deep_dup
|
61
|
+
actor.create(actor_environment) ? after_create_response : after_create_error(curation_concern.errors, original_input_params_for_form)
|
62
62
|
else
|
63
|
-
|
64
|
-
wants.html do
|
65
|
-
build_form
|
66
|
-
# Creating a form object that can re-render most of the
|
67
|
-
# submitted parameters
|
68
|
-
@form = Hyrax::Forms::FailedSubmissionFormWrapper.new(form: @form, input_params: original_input_params_for_form)
|
69
|
-
render 'new', status: :unprocessable_entity
|
70
|
-
end
|
71
|
-
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
|
72
|
-
end
|
63
|
+
create_valkyrie_work
|
73
64
|
end
|
74
65
|
end
|
75
66
|
|
@@ -101,16 +92,11 @@ module Hyrax
|
|
101
92
|
end
|
102
93
|
|
103
94
|
def update
|
104
|
-
|
105
|
-
|
95
|
+
case curation_concern
|
96
|
+
when ActiveFedora::Base
|
97
|
+
actor.update(actor_environment) ? after_update_response : after_update_error(curation_concern.errors)
|
106
98
|
else
|
107
|
-
|
108
|
-
wants.html do
|
109
|
-
build_form
|
110
|
-
render 'edit', status: :unprocessable_entity
|
111
|
-
end
|
112
|
-
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
|
113
|
-
end
|
99
|
+
update_valkyrie_work
|
114
100
|
end
|
115
101
|
end
|
116
102
|
|
@@ -176,13 +162,7 @@ module Hyrax
|
|
176
162
|
end
|
177
163
|
|
178
164
|
def admin_set_id_for_new
|
179
|
-
|
180
|
-
# however it isn't a required field for someone to submit via json.
|
181
|
-
# Set the default admin set if it exists; otherwise, set to first admin_set they have access to.
|
182
|
-
admin_sets = Hyrax::AdminSetService.new(self).search_results(:deposit)
|
183
|
-
return nil if admin_sets.blank? # shouldn't happen
|
184
|
-
return AdminSet::DEFAULT_ID if admin_sets.map(&:id).include?(AdminSet::DEFAULT_ID)
|
185
|
-
admin_sets.first.id
|
165
|
+
Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
186
166
|
end
|
187
167
|
|
188
168
|
def build_form
|
@@ -195,36 +175,45 @@ module Hyrax
|
|
195
175
|
|
196
176
|
##
|
197
177
|
# @return [#errors]
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
178
|
+
def create_valkyrie_work
|
179
|
+
form = build_form
|
180
|
+
return after_create_error(form_err_msg(form)) unless form.validate(params[hash_key_for_curation_concern])
|
181
|
+
|
182
|
+
result =
|
183
|
+
transactions['change_set.create_work']
|
184
|
+
.with_step_args(
|
185
|
+
'work_resource.add_to_parent' => { parent_id: params[:parent_id], user: current_user },
|
186
|
+
'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
|
187
|
+
'change_set.set_user_as_depositor' => { user: current_user },
|
188
|
+
'work_resource.change_depositor' => { user: ::User.find_by_user_key(form.on_behalf_of) }
|
189
|
+
)
|
190
|
+
.call(form)
|
191
|
+
@curation_concern = result.value_or { return after_create_error(transaction_err_msg(result)) }
|
192
|
+
after_create_response
|
213
193
|
end
|
214
194
|
|
215
|
-
def
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
195
|
+
def update_valkyrie_work
|
196
|
+
form = build_form
|
197
|
+
return after_update_error(form_err_msg(form)) unless form.validate(params[hash_key_for_curation_concern])
|
198
|
+
result =
|
199
|
+
transactions['change_set.update_work']
|
200
|
+
.with_step_args('work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
|
201
|
+
'work_resource.update_work_members' => { work_members_attributes: work_members_attributes })
|
202
|
+
.call(form)
|
203
|
+
@curation_concern = result.value_or { return after_update_error(transaction_err_msg(result)) }
|
204
|
+
after_update_response
|
205
|
+
end
|
221
206
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
207
|
+
def work_members_attributes
|
208
|
+
params[hash_key_for_curation_concern][:work_members_attributes]&.permit!&.to_h
|
209
|
+
end
|
210
|
+
|
211
|
+
def form_err_msg(form)
|
212
|
+
form.errors.messages.values.flatten.to_sentence
|
213
|
+
end
|
214
|
+
|
215
|
+
def transaction_err_msg(result)
|
216
|
+
result.failure.first
|
228
217
|
end
|
229
218
|
|
230
219
|
def presenter
|
@@ -383,6 +372,26 @@ module Hyrax
|
|
383
372
|
end
|
384
373
|
end
|
385
374
|
|
375
|
+
def after_create_error(errors, original_input_params_for_form = nil)
|
376
|
+
respond_to do |wants|
|
377
|
+
wants.html do
|
378
|
+
flash[:error] = errors.to_s
|
379
|
+
rebuild_form(original_input_params_for_form) if original_input_params_for_form.present?
|
380
|
+
render 'new', status: :unprocessable_entity
|
381
|
+
end
|
382
|
+
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
# Creating a form object that can re-render most of the submitted parameters.
|
387
|
+
# Required for ActiveFedora::Base objects only.
|
388
|
+
def rebuild_form(original_input_params_for_form)
|
389
|
+
build_form
|
390
|
+
@form = Hyrax::Forms::FailedSubmissionFormWrapper
|
391
|
+
.new(form: @form,
|
392
|
+
input_params: original_input_params_for_form)
|
393
|
+
end
|
394
|
+
|
386
395
|
def after_update_response
|
387
396
|
return redirect_to hyrax.confirm_access_permission_path(curation_concern) if permissions_changed? && concern_has_file_sets?
|
388
397
|
|
@@ -392,6 +401,17 @@ module Hyrax
|
|
392
401
|
end
|
393
402
|
end
|
394
403
|
|
404
|
+
def after_update_error(errors)
|
405
|
+
respond_to do |wants|
|
406
|
+
wants.html do
|
407
|
+
flash[:error] = errors.to_s
|
408
|
+
build_form unless @form.is_a? Hyrax::ChangeSet
|
409
|
+
render 'edit', status: :unprocessable_entity
|
410
|
+
end
|
411
|
+
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
395
415
|
def after_destroy_response(title)
|
396
416
|
respond_to do |wants|
|
397
417
|
wants.html { redirect_to hyrax.my_works_path, notice: "Deleted #{title}" }
|
@@ -432,7 +452,7 @@ module Hyrax
|
|
432
452
|
when ActiveFedora::Common
|
433
453
|
curation_concern.file_sets.present?
|
434
454
|
else
|
435
|
-
Hyrax.custom_queries.
|
455
|
+
Hyrax.custom_queries.find_child_file_set_ids(resource: curation_concern).any?
|
436
456
|
end
|
437
457
|
end
|
438
458
|
|
@@ -441,12 +461,16 @@ module Hyrax
|
|
441
461
|
end
|
442
462
|
|
443
463
|
def available_admin_sets
|
464
|
+
# only returns admin sets in which the user can deposit
|
444
465
|
admin_set_results = Hyrax::AdminSetService.new(self).search_results(:deposit)
|
466
|
+
|
445
467
|
# get all the templates at once, reducing query load
|
446
|
-
templates = PermissionTemplate.where(
|
468
|
+
templates = PermissionTemplate.where(source_id: admin_set_results.map(&:id)).to_a
|
447
469
|
|
448
470
|
admin_sets = admin_set_results.map do |admin_set_doc|
|
449
471
|
template = templates.find { |temp| temp.source_id == admin_set_doc.id.to_s }
|
472
|
+
|
473
|
+
# determine if sharing tab should be visible
|
450
474
|
sharing = can?(:manage, template) || !!template&.active_workflow&.allows_access_grant?
|
451
475
|
|
452
476
|
AdminSetSelectionPresenter::OptionsEntry
|
@@ -4,7 +4,8 @@ module Hyrax
|
|
4
4
|
include Hyrax::CollectionsControllerBehavior
|
5
5
|
|
6
6
|
before_action :authenticate_user!
|
7
|
-
load_and_authorize_resource
|
7
|
+
load_and_authorize_resource instance_name: :admin_set,
|
8
|
+
class: Hyrax.config.admin_set_model
|
8
9
|
|
9
10
|
# Catch permission errors
|
10
11
|
rescue_from Hydra::AccessDenied, CanCan::AccessDenied, with: :deny_adminset_access
|
@@ -61,28 +62,52 @@ module Hyrax
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def update
|
64
|
-
|
65
|
-
|
65
|
+
case @admin_set
|
66
|
+
when Valkyrie::Resource
|
67
|
+
valkyrie_update
|
66
68
|
else
|
67
|
-
|
68
|
-
render :edit
|
69
|
+
active_fedora_update
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
73
|
+
def after_create
|
74
|
+
Hyrax::SolrService.commit
|
75
|
+
redirect_to hyrax.edit_admin_admin_set_path(admin_set_id),
|
76
|
+
notice: I18n.t('new_admin_set',
|
77
|
+
scope: 'hyrax.admin.admin_sets.form.permission_update_notices',
|
78
|
+
name: @admin_set.title.first)
|
79
|
+
end
|
80
|
+
|
81
|
+
def after_create_error(err_msg: "")
|
82
|
+
msg = "Failed to create admin set: #{err_msg}"
|
83
|
+
setup_form
|
84
|
+
flash[:error] = msg
|
85
|
+
Hyrax.logger.error(msg)
|
86
|
+
render :new
|
87
|
+
end
|
88
|
+
|
72
89
|
def create
|
73
|
-
|
74
|
-
|
90
|
+
case @admin_set
|
91
|
+
when Valkyrie::Resource
|
92
|
+
valkyrie_create
|
75
93
|
else
|
76
|
-
|
77
|
-
render :new
|
94
|
+
active_fedora_create
|
78
95
|
end
|
79
96
|
end
|
80
97
|
|
81
98
|
def destroy
|
82
|
-
|
99
|
+
case @admin_set
|
100
|
+
when Valkyrie::Resource
|
101
|
+
transactions['admin_set_resource.destroy'].call(@admin_set).value_or do |failure|
|
102
|
+
redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: failure.first
|
103
|
+
end
|
83
104
|
after_delete_success
|
84
105
|
else
|
85
|
-
|
106
|
+
if @admin_set.destroy
|
107
|
+
after_delete_success
|
108
|
+
else
|
109
|
+
redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: @admin_set.errors.full_messages.to_sentence
|
110
|
+
end
|
86
111
|
end
|
87
112
|
end
|
88
113
|
|
@@ -98,12 +123,50 @@ module Hyrax
|
|
98
123
|
|
99
124
|
private
|
100
125
|
|
101
|
-
def
|
102
|
-
|
126
|
+
def valkyrie_update
|
127
|
+
@admin_set = form.validate(admin_set_params) && transactions['admin_set_resource.update'].call(form).value_or do |_failure|
|
128
|
+
setup_form # probably should do some real error handling here
|
129
|
+
render :edit
|
130
|
+
end
|
131
|
+
redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
|
132
|
+
end
|
133
|
+
|
134
|
+
def active_fedora_update
|
135
|
+
if @admin_set.update(admin_set_params)
|
136
|
+
redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
|
137
|
+
else
|
138
|
+
setup_form
|
139
|
+
render :edit
|
140
|
+
end
|
103
141
|
end
|
104
142
|
|
105
|
-
def
|
106
|
-
|
143
|
+
def update_referer
|
144
|
+
hyrax.edit_admin_admin_set_path(admin_set_id) + (params[:referer_anchor] || '')
|
145
|
+
end
|
146
|
+
|
147
|
+
def valkyrie_create
|
148
|
+
form.validate(admin_set_params) &&
|
149
|
+
@admin_set = transactions['change_set.create_admin_set']
|
150
|
+
.with_step_args(
|
151
|
+
'change_set.set_user_as_creator' => { user: current_user },
|
152
|
+
'admin_set_resource.apply_collection_type_permissions' => { user: current_user }
|
153
|
+
)
|
154
|
+
.call(form).value_or do |_failure|
|
155
|
+
setup_form # probably should do some real error handling here
|
156
|
+
render :edit
|
157
|
+
end
|
158
|
+
@admin_set = admin_set_create_service.call!(admin_set: @admin_set, creating_user: current_user)
|
159
|
+
after_create
|
160
|
+
rescue RuntimeError => err
|
161
|
+
after_create_error(err_msg: err.message)
|
162
|
+
end
|
163
|
+
|
164
|
+
def active_fedora_create
|
165
|
+
updated_admin_set = admin_set_create_service.call!(admin_set: admin_set_resource, creating_user: current_user)
|
166
|
+
@admin_set = Wings::ActiveFedoraConverter.convert(resource: updated_admin_set)
|
167
|
+
after_create
|
168
|
+
rescue RuntimeError => err
|
169
|
+
after_create_error(err_msg: err.message)
|
107
170
|
end
|
108
171
|
|
109
172
|
def setup_form
|
@@ -116,7 +179,13 @@ module Hyrax
|
|
116
179
|
|
117
180
|
# initialize the form object
|
118
181
|
def form
|
119
|
-
@form ||=
|
182
|
+
@form ||=
|
183
|
+
case @admin_set
|
184
|
+
when Valkyrie::Resource
|
185
|
+
Hyrax::Forms::ResourceForm.for(@admin_set)
|
186
|
+
else
|
187
|
+
form_class.new(@admin_set, current_ability, repository)
|
188
|
+
end
|
120
189
|
end
|
121
190
|
|
122
191
|
def action_breadcrumb
|
@@ -129,7 +198,11 @@ module Hyrax
|
|
129
198
|
end
|
130
199
|
|
131
200
|
def admin_set_params
|
132
|
-
|
201
|
+
if Hyrax.config.admin_set_class < ActiveFedora::Base
|
202
|
+
form_class.model_attributes(params[:admin_set])
|
203
|
+
else
|
204
|
+
params.permit(admin_set: {})[:admin_set]
|
205
|
+
end
|
133
206
|
end
|
134
207
|
|
135
208
|
def repository_class
|
@@ -137,13 +210,26 @@ module Hyrax
|
|
137
210
|
end
|
138
211
|
|
139
212
|
def after_delete_success
|
140
|
-
if request.referer
|
213
|
+
if request.referer&.include? "my/collections"
|
141
214
|
redirect_to hyrax.my_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
|
142
|
-
elsif request.referer
|
215
|
+
elsif request.referer&.include? "collections"
|
143
216
|
redirect_to hyrax.dashboard_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
|
144
217
|
else
|
145
218
|
redirect_to hyrax.my_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
|
146
219
|
end
|
147
220
|
end
|
221
|
+
|
222
|
+
def admin_set_id
|
223
|
+
@admin_set&.id&.to_s
|
224
|
+
end
|
225
|
+
|
226
|
+
def admin_set_resource
|
227
|
+
case @admin_set
|
228
|
+
when Valkyrie::Resource
|
229
|
+
@admin_set
|
230
|
+
else
|
231
|
+
@admin_set.valkyrie_resource
|
232
|
+
end
|
233
|
+
end
|
148
234
|
end
|
149
235
|
end
|