hyrax 3.0.2 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +22 -0
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dockerignore +3 -0
- data/.env +0 -1
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +1 -1
- data/Dockerfile +12 -6
- data/Gemfile +21 -27
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +20 -8
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +13 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +12 -10
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +3 -1
- data/app/forms/hyrax/forms/collection_form.rb +7 -3
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +24 -2
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/permission.rb +23 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +8 -2
- data/app/forms/hyrax/forms/resource_form.rb +10 -17
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/helpers/hyrax/batch_edits_helper.rb +3 -1
- data/app/helpers/hyrax/collections_helper.rb +88 -2
- data/app/helpers/hyrax/dashboard_helper_behavior.rb +3 -7
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/work_form_helper.rb +53 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +18 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
- data/app/inputs/controlled_vocabulary_input.rb +2 -5
- data/app/jobs/attach_files_to_work_job.rb +19 -10
- data/app/jobs/attach_files_to_work_with_ordered_members_job.rb +6 -5
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/models/admin_set.rb +6 -25
- data/app/models/concerns/hyrax/ability.rb +3 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -52
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/hyrax/file_set.rb +6 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission_template.rb +98 -12
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +42 -0
- data/app/presenters/hyrax/admin_set_options_presenter.rb +2 -10
- data/app/presenters/hyrax/admin_set_presenter.rb +5 -1
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +31 -6
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/stats_usage_presenter.rb +2 -1
- data/app/presenters/hyrax/trophy_presenter.rb +33 -4
- data/app/presenters/hyrax/user_profile_presenter.rb +11 -1
- data/app/presenters/hyrax/version_list_presenter.rb +19 -0
- data/app/presenters/hyrax/version_presenter.rb +3 -2
- data/app/presenters/hyrax/work_show_presenter.rb +25 -4
- data/app/presenters/hyrax/work_usage.rb +5 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/admin_set_search_builder.rb +1 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +3 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +112 -27
- data/app/services/hyrax/collections/migration_service.rb +4 -2
- data/app/services/hyrax/collections/nested_collection_persistence_service.rb +12 -13
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -0
- data/app/services/hyrax/collections/permissions_create_service.rb +6 -4
- data/app/services/hyrax/contextual_path.rb +23 -0
- data/app/services/hyrax/custom_queries/find_file_metadata.rb +7 -5
- data/app/services/hyrax/custom_queries/navigators/parent_collections_navigator.rb +46 -0
- data/app/services/hyrax/edit_permissions_service.rb +27 -20
- data/app/services/hyrax/find_objects_via_solr_service.rb +11 -7
- data/app/services/hyrax/multiple_membership_checker.rb +51 -31
- data/app/services/hyrax/resource_status.rb +7 -0
- data/app/services/hyrax/search_service.rb +4 -2
- data/app/services/hyrax/solr_query_builder_service.rb +29 -6
- data/app/services/hyrax/solr_query_service.rb +224 -0
- data/app/services/hyrax/solr_service.rb +8 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/work_uploads_handler.rb +17 -2
- data/app/services/hyrax/workflow/actionable_objects.rb +70 -0
- data/app/services/hyrax/workflow/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- data/app/views/hyrax/base/_form_relationships.html.erb +1 -2
- data/app/views/hyrax/base/_form_rendering.html.erb +1 -1
- data/app/views/hyrax/base/_form_representative.html.erb +1 -1
- data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_guts4form.html.erb +2 -2
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/edit.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/new.html.erb +4 -2
- data/app/views/hyrax/dashboard/collections/show.html.erb +1 -1
- data/app/views/hyrax/file_sets/edit.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_default.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/file_sets/show.html.erb +1 -1
- data/app/views/hyrax/my/_admin_set_action_menu.html.erb +0 -11
- data/app/views/hyrax/my/_collection_action_menu.html.erb +1 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_add_subcollection.html.erb +3 -5
- data/bin/solrcloud-assign-configset.sh +8 -5
- data/bin/solrcloud-upload-configset.sh +4 -2
- data/chart/hyrax/Chart.yaml +3 -3
- data/chart/hyrax/README.md +47 -1
- data/chart/hyrax/templates/_helpers.tpl +1 -1
- data/chart/hyrax/templates/configmap-env.yaml +1 -3
- data/chart/hyrax/templates/deployment-worker.yaml +6 -3
- data/chart/hyrax/templates/deployment.yaml +8 -3
- data/chart/hyrax/values.yaml +12 -0
- data/config/brakeman.ignore +2 -2
- data/config/locales/hyrax.de.yml +1 -1
- data/config/locales/hyrax.en.yml +1 -1
- data/config/locales/hyrax.es.yml +1 -1
- data/config/locales/hyrax.fr.yml +1 -1
- data/config/locales/hyrax.it.yml +1 -1
- data/config/locales/hyrax.pt-BR.yml +1 -1
- data/config/locales/hyrax.zh.yml +1 -1
- data/docker-compose.yml +1 -0
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +8 -0
- data/lib/hyrax/engine.rb +1 -0
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/specs/capybara.rb +3 -1
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +21 -0
- data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -0
- data/lib/hyrax/transactions/work_create.rb +2 -1
- data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/hyrax.rb +9 -0
- data/lib/tasks/collection_type_global_id.rake +1 -1
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/orm_converter.rb +18 -2
- data/lib/wings/setup.rb +1 -0
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/template.rb +1 -1
- metadata +17 -2
@@ -15,14 +15,17 @@ module Hyrax
|
|
15
15
|
class_attribute :presenter_class,
|
16
16
|
:form_class,
|
17
17
|
:single_item_search_builder_class,
|
18
|
-
:membership_service_class
|
18
|
+
:membership_service_class,
|
19
|
+
:parent_collection_query_service
|
19
20
|
|
20
21
|
self.presenter_class = Hyrax::CollectionPresenter
|
21
22
|
|
22
23
|
# The search builder to find the collection
|
23
24
|
self.single_item_search_builder_class = SingleCollectionSearchBuilder
|
24
25
|
# The search builder to find the collections' members
|
25
|
-
self.membership_service_class = Collections::
|
26
|
+
self.membership_service_class = Collections::CollectionMemberSearchService
|
27
|
+
# A search service to use in finding parent collections
|
28
|
+
self.parent_collection_query_service = Collections::NestedCollectionQueryService
|
26
29
|
end
|
27
30
|
|
28
31
|
def show
|
@@ -74,9 +77,9 @@ module Hyrax
|
|
74
77
|
end
|
75
78
|
|
76
79
|
def query_collection_members
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
load_member_works
|
81
|
+
load_member_subcollections if collection.collection_type.nestable?
|
82
|
+
load_parent_collections if collection.collection_type.nestable? && action_name == 'show'
|
80
83
|
end
|
81
84
|
|
82
85
|
# Instantiate the membership query service
|
@@ -89,12 +92,20 @@ module Hyrax
|
|
89
92
|
@member_docs = @response.documents
|
90
93
|
@members_count = @response.total
|
91
94
|
end
|
95
|
+
alias load_member_works member_works
|
92
96
|
|
93
|
-
|
97
|
+
##
|
98
|
+
# Handles paged loading for parent collections.
|
99
|
+
#
|
100
|
+
# @param the query service to use when searching for the parent collections.
|
101
|
+
# uses the class attribute +parent_collection_query_service+ by default.
|
102
|
+
def parent_collections(query_service: self.class.parent_collection_query_service)
|
94
103
|
page = params[:parent_collection_page].to_i
|
95
|
-
|
96
|
-
|
104
|
+
collection.parent_collections = query_service.parent_collections(
|
105
|
+
child: collection_object, scope: self, page: page
|
106
|
+
)
|
97
107
|
end
|
108
|
+
alias load_parent_collections parent_collections
|
98
109
|
|
99
110
|
def collection_object
|
100
111
|
action_name == 'show' ? Collection.find(collection.id) : collection
|
@@ -106,6 +117,7 @@ module Hyrax
|
|
106
117
|
@subcollection_docs = results.documents
|
107
118
|
@subcollection_count = @presenter.subcollection_count = results.total
|
108
119
|
end
|
120
|
+
alias load_member_subcollections member_subcollections
|
109
121
|
|
110
122
|
# You can override this method if you need to provide additional inputs to the search
|
111
123
|
# builder. For example:
|
@@ -24,23 +24,35 @@ module Hyrax
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# Updates a batch of embargos
|
27
|
+
# rubocop:disable Metrics/AbcSize
|
28
|
+
# rubocop:disable Metrics/MethodLength
|
29
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
27
30
|
def update
|
28
31
|
filter_docs_with_edit_access!
|
29
32
|
copy_visibility = []
|
30
33
|
copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] } if params[:embargoes]
|
31
|
-
|
32
|
-
|
33
|
-
Hyrax
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
resources = Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: Hyrax.config.use_valkyrie?)
|
35
|
+
resources.each do |resource|
|
36
|
+
if Hyrax.config.use_valkyrie?
|
37
|
+
EmbargoManager.new(resource: resource).release!
|
38
|
+
Hyrax::AccessControlList(resource).save
|
39
|
+
Hyrax::VisibilityPropagator.for(source: resource).propagate if copy_visibility.include?(resource.id)
|
40
|
+
else
|
41
|
+
Hyrax::Actors::EmbargoActor.new(resource).destroy
|
42
|
+
# if the concern is a FileSet, set its visibility and visibility propagation
|
43
|
+
if resource.file_set?
|
44
|
+
resource.visibility = resource.to_solr["visibility_after_embargo_ssim"]
|
45
|
+
resource.save!
|
46
|
+
elsif copy_visibility.include?(resource.id)
|
47
|
+
Hyrax::VisibilityPropagator.for(source: resource).propagate
|
48
|
+
end
|
40
49
|
end
|
41
50
|
end
|
42
51
|
redirect_to embargoes_path, notice: t('.embargo_deactivated')
|
43
52
|
end
|
53
|
+
# rubocop:enable Metrics/AbcSize
|
54
|
+
# rubocop:enable Metrics/MethodLength
|
55
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
44
56
|
|
45
57
|
# This allows us to use the unauthorized template in curation_concerns/base
|
46
58
|
def self.local_prefixes
|
@@ -23,18 +23,27 @@ module Hyrax
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/AbcSize
|
27
|
+
# rubocop:disable Metrics/MethodLength
|
26
28
|
def update
|
27
29
|
filter_docs_with_edit_access!
|
28
30
|
copy_visibility = []
|
29
31
|
copy_visibility = params[:leases].values.map { |h| h[:copy_visibility] } if params[:leases]
|
30
|
-
|
31
|
-
|
32
|
-
Hyrax
|
33
|
-
|
34
|
-
|
32
|
+
resources = Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: Hyrax.config.use_valkyrie?)
|
33
|
+
resources.each do |resource|
|
34
|
+
if Hyrax.config.use_valkyrie?
|
35
|
+
LeaseManager.new(resource: resource).release!
|
36
|
+
Hyrax::AccessControlList(resource).save
|
37
|
+
else
|
38
|
+
Hyrax::Actors::LeaseActor.new(resource).destroy
|
39
|
+
end
|
40
|
+
Hyrax::VisibilityPropagator.for(source: resource).propagate if
|
41
|
+
copy_visibility.include?(resource.id)
|
35
42
|
end
|
36
43
|
redirect_to leases_path
|
37
44
|
end
|
45
|
+
# rubocop:enable Metrics/AbcSize
|
46
|
+
# rubocop:enable Metrics/MethodLength
|
38
47
|
|
39
48
|
# This allows us to use the unauthorized template in curation_concerns/base
|
40
49
|
def self.local_prefixes
|
@@ -47,6 +47,7 @@ module Hyrax
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def new
|
50
|
+
@admin_set_options = available_admin_sets
|
50
51
|
# TODO: move these lines to the work form builder in Hyrax
|
51
52
|
curation_concern.depositor = current_user.user_key
|
52
53
|
curation_concern.admin_set_id = admin_set_id_for_new
|
@@ -95,6 +96,7 @@ module Hyrax
|
|
95
96
|
# rubocop:enable Metrics/AbcSize
|
96
97
|
|
97
98
|
def edit
|
99
|
+
@admin_set_options = available_admin_sets
|
98
100
|
build_form
|
99
101
|
end
|
100
102
|
|
@@ -203,7 +205,8 @@ module Hyrax
|
|
203
205
|
@curation_concern =
|
204
206
|
form.validate(params[hash_key_for_curation_concern]) &&
|
205
207
|
transactions['change_set.create_work']
|
206
|
-
.with_step_args('work_resource.
|
208
|
+
.with_step_args('work_resource.add_to_parent' => { parent_id: params[:parent_id], user: current_user },
|
209
|
+
'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
|
207
210
|
'change_set.set_user_as_depositor' => { user: current_user })
|
208
211
|
.call(form).value!
|
209
212
|
end
|
@@ -219,7 +222,7 @@ module Hyrax
|
|
219
222
|
@curation_concern =
|
220
223
|
form.validate(params[hash_key_for_curation_concern]) &&
|
221
224
|
transactions['change_set.update_work']
|
222
|
-
.with_step_args('work_resource.add_file_sets' => { uploaded_files: uploaded_files })
|
225
|
+
.with_step_args('work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] })
|
223
226
|
.call(form).value!
|
224
227
|
end
|
225
228
|
end
|
@@ -255,7 +258,7 @@ module Hyrax
|
|
255
258
|
|
256
259
|
# @deprecated
|
257
260
|
def curation_concern_from_search_results
|
258
|
-
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. "
|
261
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
259
262
|
"Instead, use '#search_result_document'.")
|
260
263
|
search_params = params.deep_dup
|
261
264
|
search_params.delete :page
|
@@ -436,5 +439,21 @@ module Hyrax
|
|
436
439
|
def uploaded_files
|
437
440
|
UploadedFile.find(params.fetch(:uploaded_files, []))
|
438
441
|
end
|
442
|
+
|
443
|
+
def available_admin_sets
|
444
|
+
admin_set_results = Hyrax::AdminSetService.new(self).search_results(:deposit)
|
445
|
+
# get all the templates at once, reducing query load
|
446
|
+
templates = PermissionTemplate.where(id: admin_set_results.map(&:id)).to_a
|
447
|
+
|
448
|
+
admin_sets = admin_set_results.map do |admin_set_doc|
|
449
|
+
template = templates.find { |temp| temp.source_id == admin_set_doc.id.to_s }
|
450
|
+
sharing = can?(:manage, template) || !!template&.active_workflow&.allows_access_grant?
|
451
|
+
|
452
|
+
AdminSetSelectionPresenter::OptionsEntry
|
453
|
+
.new(admin_set: admin_set_doc, permission_template: template, permit_sharing: sharing)
|
454
|
+
end
|
455
|
+
|
456
|
+
AdminSetSelectionPresenter.new(admin_sets: admin_sets)
|
457
|
+
end
|
439
458
|
end
|
440
459
|
end
|
@@ -15,8 +15,9 @@ module Hyrax
|
|
15
15
|
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
|
16
16
|
add_breadcrumb t(:'hyrax.admin.sidebar.tasks'), '#'
|
17
17
|
add_breadcrumb t(:'hyrax.admin.sidebar.workflow_review'), request.path
|
18
|
-
|
19
|
-
@
|
18
|
+
|
19
|
+
@status_list = actionable_objects.reject(&:published?)
|
20
|
+
@published_list = actionable_objects.select(&:published?)
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -24,5 +25,10 @@ module Hyrax
|
|
24
25
|
def ensure_authorized!
|
25
26
|
authorize! :review, :submissions
|
26
27
|
end
|
28
|
+
|
29
|
+
def actionable_objects
|
30
|
+
@actionable_objects ||=
|
31
|
+
Hyrax::Workflow::ActionableObjects.new(user: current_user)
|
32
|
+
end
|
27
33
|
end
|
28
34
|
end
|
@@ -21,21 +21,25 @@ module Hyrax
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def update_members
|
24
|
+
def update_members # rubocop:disable Metrics/MethodLength
|
25
25
|
err_msg = validate
|
26
26
|
after_update_error(err_msg) if err_msg.present?
|
27
27
|
return if err_msg.present?
|
28
28
|
|
29
29
|
collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
elsif messages.present?
|
35
|
-
flash[:error] = messages.uniq.join(', ')
|
36
|
-
after_update
|
37
|
-
else
|
30
|
+
begin
|
31
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: collection.id,
|
32
|
+
new_member_ids: batch_ids,
|
33
|
+
user: current_user)
|
38
34
|
after_update
|
35
|
+
rescue Hyrax::SingleMembershipError => err
|
36
|
+
messages = JSON.parse(err.message)
|
37
|
+
if messages.size == batch_ids.size
|
38
|
+
after_update_error(messages.uniq.join(', '))
|
39
|
+
elsif messages.present?
|
40
|
+
flash[:error] = messages.uniq.join(', ')
|
41
|
+
after_update
|
42
|
+
end
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -41,7 +41,7 @@ module Hyrax
|
|
41
41
|
# The search builder to find the collection
|
42
42
|
self.single_item_search_builder_class = SingleCollectionSearchBuilder
|
43
43
|
# The search builder to find the collections' members
|
44
|
-
self.membership_service_class = Collections::
|
44
|
+
self.membership_service_class = Collections::CollectionMemberSearchService
|
45
45
|
|
46
46
|
load_and_authorize_resource except: [:index, :create], instance_name: :collection
|
47
47
|
|
@@ -112,10 +112,10 @@ module Hyrax
|
|
112
112
|
@collection.collection_type_gid = params[:collection_type_gid].presence || default_collection_type.to_global_id
|
113
113
|
@collection.attributes = collection_params.except(:members, :parent_id, :collection_type_gid)
|
114
114
|
@collection.apply_depositor_metadata(current_user.user_key)
|
115
|
-
add_members_to_collection unless batch.empty?
|
116
115
|
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
|
117
116
|
if @collection.save
|
118
117
|
after_create
|
118
|
+
add_members_to_collection unless batch.empty?
|
119
119
|
else
|
120
120
|
after_create_error
|
121
121
|
end
|
@@ -202,8 +202,10 @@ module Hyrax
|
|
202
202
|
end
|
203
203
|
|
204
204
|
def link_parent_collection(parent_id)
|
205
|
-
|
206
|
-
Hyrax::Collections::
|
205
|
+
child = collection.respond_to?(:valkyrie_resource) ? collection.valkyrie_resource : collection
|
206
|
+
Hyrax::Collections::CollectionMemberService.add_member(collection_id: parent_id,
|
207
|
+
new_member: child,
|
208
|
+
user: current_user)
|
207
209
|
end
|
208
210
|
|
209
211
|
def uploaded_files(uploaded_file_ids)
|
@@ -379,15 +381,15 @@ module Hyrax
|
|
379
381
|
|
380
382
|
def add_members_to_collection(collection = nil)
|
381
383
|
collection ||= @collection
|
382
|
-
collection.
|
384
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: collection.id,
|
385
|
+
new_member_ids: batch,
|
386
|
+
user: current_user)
|
383
387
|
end
|
384
388
|
|
385
389
|
def remove_members_from_collection
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
work.save!
|
390
|
-
end
|
390
|
+
Hyrax::Collections::CollectionMemberService.remove_members_by_ids(collection_id: @collection.id,
|
391
|
+
member_ids: batch,
|
392
|
+
user: current_user)
|
391
393
|
end
|
392
394
|
|
393
395
|
def move_members_between_collections
|
@@ -44,8 +44,7 @@ module Hyrax
|
|
44
44
|
|
45
45
|
# GET /concern/parent/:parent_id/file_sets/:id
|
46
46
|
def show
|
47
|
-
presenter
|
48
|
-
guard_for_workflow_restriction_on!(parent: presenter.parent)
|
47
|
+
guard_for_workflow_restriction_on!(parent: parent(file_set: presenter))
|
49
48
|
respond_to do |wants|
|
50
49
|
wants.html
|
51
50
|
wants.json
|
@@ -55,16 +54,17 @@ module Hyrax
|
|
55
54
|
|
56
55
|
# DELETE /concern/file_sets/:id
|
57
56
|
def destroy
|
58
|
-
parent = curation_concern.parent
|
59
57
|
guard_for_workflow_restriction_on!(parent: parent)
|
60
|
-
|
61
|
-
|
58
|
+
|
59
|
+
delete(file_set: curation_concern)
|
60
|
+
redirect_to [main_app, parent],
|
61
|
+
notice: view_context.t('hyrax.file_sets.asset_deleted_flash.message')
|
62
62
|
end
|
63
63
|
|
64
64
|
# PATCH /concern/file_sets/:id
|
65
65
|
def update
|
66
|
-
parent = curation_concern.parent
|
67
66
|
guard_for_workflow_restriction_on!(parent: parent)
|
67
|
+
|
68
68
|
if attempt_update
|
69
69
|
after_update_response
|
70
70
|
else
|
@@ -86,10 +86,47 @@ module Hyrax
|
|
86
86
|
|
87
87
|
private
|
88
88
|
|
89
|
-
|
89
|
+
##
|
90
|
+
# @api public
|
91
|
+
def delete(file_set:)
|
92
|
+
case file_set
|
93
|
+
when Valkyrie::Resource
|
94
|
+
transactions['file_set.destroy']
|
95
|
+
.with_step_args('file_set.remove_from_work' => { user: current_user },
|
96
|
+
'file_set.delete' => { user: current_user })
|
97
|
+
.call(curation_concern)
|
98
|
+
.value!
|
99
|
+
else
|
100
|
+
actor.destroy
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
##
|
105
|
+
# @api public
|
106
|
+
#
|
107
|
+
# @note this is provided so that implementing application can override this
|
108
|
+
# behavior and map params to different attributes
|
90
109
|
def update_metadata
|
91
|
-
|
92
|
-
|
110
|
+
case file_set
|
111
|
+
when Hyrax::Resource
|
112
|
+
change_set = Hyrax::Forms::ResourceForm.for(file_set)
|
113
|
+
|
114
|
+
change_set.validate(attributes) &&
|
115
|
+
transactions['change_set.apply'].call(change_set).value_or { false }
|
116
|
+
else
|
117
|
+
file_attributes = form_class.model_attributes(attributes)
|
118
|
+
actor.update_metadata(file_attributes)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def parent(file_set: curation_concern)
|
123
|
+
@parent ||=
|
124
|
+
case file_set
|
125
|
+
when Hyrax::Resource
|
126
|
+
Hyrax.query_service.find_parents(resource: file_set).first
|
127
|
+
else
|
128
|
+
file_set.parent
|
129
|
+
end
|
93
130
|
end
|
94
131
|
|
95
132
|
def attempt_update
|
@@ -152,10 +189,9 @@ module Hyrax
|
|
152
189
|
end
|
153
190
|
|
154
191
|
def initialize_edit_form
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
@version_list = Hyrax::VersionListPresenter.new(original ? original.versions.all : [])
|
192
|
+
guard_for_workflow_restriction_on!(parent: parent)
|
193
|
+
|
194
|
+
@version_list = Hyrax::VersionListPresenter.for(file_set: @file_set)
|
159
195
|
@groups = current_user.groups
|
160
196
|
end
|
161
197
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
class PermissionsController < ApplicationController
|
4
|
+
load_resource class: ActiveFedora::Base, instance_name: :curation_concern
|
5
|
+
|
6
|
+
attr_reader :curation_concern
|
4
7
|
helper_method :curation_concern
|
5
8
|
|
6
9
|
def confirm
|
@@ -28,9 +31,5 @@ module Hyrax
|
|
28
31
|
InheritPermissionsJob.perform_later(curation_concern)
|
29
32
|
redirect_to [main_app, curation_concern], notice: I18n.t("hyrax.upload.change_access_flash_message")
|
30
33
|
end
|
31
|
-
|
32
|
-
def curation_concern
|
33
|
-
@curation_concern ||= Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: params[:id], use_valkyrie: false)
|
34
|
-
end
|
35
34
|
end
|
36
35
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
class WorkflowActionsController < ApplicationController
|
4
|
+
DEFAULT_FORM_CLASS = Hyrax::Forms::WorkflowActionForm
|
5
|
+
|
4
6
|
before_action :authenticate_user!
|
5
7
|
|
6
8
|
def update
|
@@ -21,7 +23,7 @@ module Hyrax
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def workflow_action_form
|
24
|
-
@workflow_action_form ||=
|
26
|
+
@workflow_action_form ||= DEFAULT_FORM_CLASS.new(
|
25
27
|
current_ability: current_ability,
|
26
28
|
work: curation_concern,
|
27
29
|
attributes: workflow_action_params
|