hyrax 3.0.0.pre.rc4 → 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 +41 -8
- data/.dassie/Gemfile +10 -5
- data/.dassie/config/cable.yml +1 -1
- data/.dassie/config/environments/development.rb +2 -0
- data/.dassie/config/environments/production.rb +1 -1
- data/.dassie/config/initializers/hyrax.rb +5 -0
- data/.dassie/config/initializers/riiif.rb +22 -20
- data/.dassie/config/redis.yml +1 -0
- data/.dassie/config/role_map.yml +2 -0
- data/.dassie/db/seeds.rb +9 -1
- data/.dassie/package.json +3 -5
- data/.dockerignore +4 -0
- data/.env +1 -2
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +21 -1
- data/Dockerfile +46 -17
- 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 +89 -41
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/actors/hyrax/actors/file_actor.rb +4 -2
- data/app/actors/hyrax/actors/file_set_actor.rb +18 -11
- 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 +38 -8
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +0 -4
- 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 +14 -14
- 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 +12 -6
- 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 +31 -13
- 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 +16 -5
- data/app/helpers/hyrax/embargo_helper.rb +4 -0
- data/app/helpers/hyrax/file_set_helper.rb +25 -6
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +8 -0
- data/app/helpers/hyrax/lease_helper.rb +4 -0
- data/app/helpers/hyrax/url_helper.rb +4 -1
- 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_file_set_indexer.rb +118 -0
- data/app/indexers/hyrax/valkyrie_indexer.rb +10 -4
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +3 -1
- 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/embargo_expiry_job.rb +7 -5
- data/app/jobs/file_set_attached_event_job.rb +6 -1
- data/app/jobs/ingest_local_file_job.rb +18 -2
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/jobs/lease_expiry_job.rb +6 -4
- data/app/models/admin_set.rb +6 -25
- data/app/models/collection_branding_info.rb +25 -9
- data/app/models/concerns/hyrax/ability.rb +14 -1
- data/app/models/concerns/hyrax/collection_behavior.rb +17 -44
- data/app/models/concerns/hyrax/embargoable.rb +24 -0
- data/app/models/concerns/hyrax/file_set/characterization.rb +18 -12
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -46
- data/app/models/concerns/hyrax/suppressible.rb +5 -0
- data/app/models/concerns/hyrax/user.rb +9 -3
- data/app/models/concerns/hyrax/work_behavior.rb +1 -1
- data/app/models/hyrax/file_set.rb +7 -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/hyrax/work.rb +2 -0
- data/app/models/job_io_wrapper.rb +1 -1
- 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 +12 -8
- 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 +41 -20
- data/app/presenters/hyrax/file_set_presenter.rb +6 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +119 -0
- 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 +30 -5
- 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/collection_member_search_builder.rb +6 -1
- data/app/search_builders/hyrax/my/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/nested_collections_parent_search_builder.rb +1 -1
- data/app/search_builders/hyrax/single_collection_search_builder.rb +1 -1
- data/app/services/hyrax/access_control_list.rb +1 -1
- data/app/services/hyrax/adapters/nesting_index_adapter.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 +24 -1
- 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 +74 -41
- data/app/services/hyrax/embargo_manager.rb +1 -1
- data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
- data/app/services/hyrax/graph_exporter.rb +1 -1
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +26 -0
- data/app/services/hyrax/listeners/metadata_index_listener.rb +18 -1
- data/app/services/hyrax/listeners/object_lifecycle_listener.rb +1 -1
- data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +17 -0
- data/app/services/hyrax/listeners.rb +2 -0
- data/app/services/hyrax/multiple_membership_checker.rb +53 -29
- data/app/services/hyrax/persist_derivatives.rb +3 -1
- 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 +45 -8
- 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/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/versioning_service.rb +1 -1
- data/app/services/hyrax/visibility_intention.rb +20 -2
- data/app/services/hyrax/visibility_propagator.rb +30 -1
- data/app/services/hyrax/work_uploads_handler.rb +22 -4
- 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/admin/admin_sets/_show_document_list_row.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- 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_share.html.erb +1 -5
- data/app/views/hyrax/base/_form_thumbnail.html.erb +1 -1
- data/app/views/hyrax/base/_form_visibility_error.html.erb +2 -0
- data/app/views/hyrax/base/_guts4form.html.erb +3 -3
- data/app/views/hyrax/base/_representative_media.html.erb +1 -1
- data/app/views/hyrax/base/_show_actions.html.erb +2 -2
- data/app/views/hyrax/base/_work_button_row.html.erb +1 -1
- data/app/views/hyrax/base/_workflow_actions.html.erb +1 -1
- data/app/views/hyrax/batch_edits/edit.html.erb +2 -2
- data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
- data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/collections/_search_form.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +1 -1
- 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/_actions.html.erb +10 -0
- 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/app/views/hyrax/stats/file.html.erb +1 -1
- data/app/views/hyrax/stats/work.html.erb +1 -1
- data/app/views/hyrax/uploads/_js_templates.html.erb +4 -4
- data/app/views/hyrax/uploads/_js_templates_versioning.html.erb +4 -4
- data/app/views/hyrax/users/_contributions.html.erb +1 -1
- data/app/views/hyrax/users/_profile_tabs.html.erb +2 -2
- data/app/views/hyrax/users/_search_form.html.erb +1 -1
- data/app/views/hyrax/users/_user.html.erb +1 -1
- data/app/views/hyrax/users/_user_info.html.erb +9 -9
- data/bin/db-migrate-seed.sh +6 -2
- data/bin/hyrax-entrypoint.sh +0 -14
- data/bin/solrcloud-assign-configset.sh +35 -0
- data/bin/solrcloud-upload-configset.sh +42 -0
- data/chart/hyrax/Chart.yaml +12 -8
- data/chart/hyrax/README.md +94 -11
- data/chart/hyrax/templates/NOTES.txt +1 -1
- data/chart/hyrax/templates/_helpers.tpl +98 -0
- data/chart/hyrax/templates/branding-pvc.yaml +14 -0
- data/chart/hyrax/templates/configmap-env.yaml +21 -11
- data/chart/hyrax/templates/cron-embargo.yaml +24 -0
- data/chart/hyrax/templates/cron-lease.yaml +24 -0
- data/chart/hyrax/templates/deployment-worker.yaml +129 -0
- data/chart/hyrax/templates/deployment.yaml +125 -4
- data/chart/hyrax/templates/derivatives-pvc.yaml +14 -0
- data/chart/hyrax/templates/ingress.yaml +13 -4
- data/chart/hyrax/templates/secrets.yaml +12 -2
- data/chart/hyrax/templates/uploads-pvc.yaml +14 -0
- data/chart/hyrax/values.yaml +186 -2
- data/config/brakeman.ignore +2 -2
- data/config/features.rb +47 -43
- data/config/initializers/listeners.rb +4 -0
- data/config/initializers/valkryrie_storage.rb +7 -0
- 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 +39 -8
- data/documentation/developing-your-hyrax-based-app.md +4 -4
- data/documentation/legacyREADME.md +3 -3
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +5 -0
- data/lib/generators/hyrax/templates/config/initializers/riiif.rb +22 -20
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/configuration.rb +28 -0
- data/lib/hyrax/engine.rb +3 -1
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/resource_name.rb +1 -0
- data/lib/hyrax/specs/capybara.rb +5 -3
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/container.rb +32 -1
- 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/delete_resource.rb +38 -0
- data/lib/hyrax/transactions/steps/destroy_work.rb +1 -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/transactions/work_destroy.rb +20 -0
- data/lib/hyrax/valkyrie_can_can_adapter.rb +3 -0
- data/lib/hyrax/valkyrie_simple_path_generator.rb +20 -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/embargo_lease.rake +27 -0
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/active_fedora_converter/default_work.rb +19 -0
- data/lib/wings/attribute_transformer.rb +29 -19
- data/lib/wings/converter_value_mapper.rb +2 -2
- data/lib/wings/model_transformer.rb +21 -20
- data/lib/wings/orm_converter.rb +42 -23
- data/lib/wings/setup.rb +2 -0
- data/lib/wings/valkyrie/persister.rb +8 -5
- data/lib/wings/valkyrie/query_service.rb +96 -41
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/lib/wings.rb +0 -21
- data/template.rb +1 -1
- metadata +41 -21
- data/chart/fcrepo/.gitignore +0 -2
- data/chart/fcrepo/.helmignore +0 -23
- data/chart/fcrepo/Chart.yaml +0 -11
- data/chart/fcrepo/README.md +0 -50
- data/chart/fcrepo/templates/NOTES.txt +0 -21
- data/chart/fcrepo/templates/_helpers.tpl +0 -68
- data/chart/fcrepo/templates/configmap-env.yaml +0 -19
- data/chart/fcrepo/templates/deployment.yaml +0 -109
- data/chart/fcrepo/templates/ingress.yaml +0 -41
- data/chart/fcrepo/templates/pvc.yaml +0 -20
- data/chart/fcrepo/templates/secret.yaml +0 -12
- data/chart/fcrepo/templates/service.yaml +0 -15
- data/chart/fcrepo/templates/serviceaccount.yaml +0 -12
- data/chart/fcrepo/templates/tests/test-connection.yaml +0 -15
- data/chart/fcrepo/values.yaml +0 -79
- data/chart/hyrax/templates/fcrepo-secret.yaml +0 -13
@@ -18,7 +18,7 @@ module Hyrax
|
|
18
18
|
|
19
19
|
self.model_class = ::Collection
|
20
20
|
|
21
|
-
self.membership_service_class = Collections::
|
21
|
+
self.membership_service_class = Collections::CollectionMemberSearchService
|
22
22
|
|
23
23
|
delegate :blacklight_config, to: Hyrax::CollectionsController
|
24
24
|
|
@@ -80,18 +80,20 @@ module Hyrax
|
|
80
80
|
def banner_info
|
81
81
|
@banner_info ||= begin
|
82
82
|
# Find Banner filename
|
83
|
-
banner_info = CollectionBrandingInfo.where(collection_id: id
|
83
|
+
banner_info = CollectionBrandingInfo.where(collection_id: id, role: "banner")
|
84
84
|
banner_file = File.split(banner_info.first.local_path).last unless banner_info.empty?
|
85
|
+
alttext = banner_info.first.alt_text unless banner_info.empty?
|
85
86
|
file_location = banner_info.first.local_path unless banner_info.empty?
|
86
87
|
relative_path = "/" + banner_info.first.local_path.split("/")[-4..-1].join("/") unless banner_info.empty?
|
87
|
-
{ file: banner_file, full_path: file_location, relative_path: relative_path }
|
88
|
+
{ file: banner_file, full_path: file_location, relative_path: relative_path, alttext: alttext }
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
92
|
def logo_info
|
92
93
|
@logo_info ||= begin
|
93
94
|
# Find Logo filename, alttext, linktext
|
94
|
-
logos_info = CollectionBrandingInfo.where(collection_id: id
|
95
|
+
logos_info = CollectionBrandingInfo.where(collection_id: id, role: "logo")
|
96
|
+
|
95
97
|
logos_info.map do |logo_info|
|
96
98
|
logo_file = File.split(logo_info.local_path).last
|
97
99
|
relative_path = "/" + logo_info.local_path.split("/")[-4..-1].join("/")
|
@@ -121,6 +123,11 @@ module Hyrax
|
|
121
123
|
collection_member_service.available_member_subcollections.documents
|
122
124
|
end
|
123
125
|
|
126
|
+
##
|
127
|
+
# @deprecated this implementation requires an extra db round trip, had a
|
128
|
+
# buggy cacheing mechanism, and was largely duplicative of other code.
|
129
|
+
# all versions of this code are replaced by
|
130
|
+
# {CollectionsHelper#available_parent_collections_data}.
|
124
131
|
def available_parent_collections(scope:)
|
125
132
|
return @available_parents if @available_parents.present?
|
126
133
|
|
@@ -128,8 +135,7 @@ module Hyrax
|
|
128
135
|
colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
|
129
136
|
@available_parents = colls.map do |col|
|
130
137
|
{ "id" => col.id, "title_first" => col.title.first }
|
131
|
-
end
|
132
|
-
@available_parents.to_json
|
138
|
+
end.to_json
|
133
139
|
end
|
134
140
|
|
135
141
|
private
|
@@ -32,18 +32,40 @@ module Hyrax
|
|
32
32
|
|
33
33
|
def save
|
34
34
|
return false unless valid?
|
35
|
-
persistence_service.persist_nested_collection_for(parent: parent, child: child)
|
35
|
+
persistence_service.persist_nested_collection_for(parent: parent, child: child, user: context.current_user)
|
36
36
|
end
|
37
37
|
|
38
|
+
##
|
39
|
+
# @deprecated this method is unused by hyrax, and is effectively a
|
40
|
+
# delegation to `Hyrax::Collections::NestedCollectionQueryService`.
|
41
|
+
# if you want to be sure to use nested indexing to generate this list,
|
42
|
+
# use the query service directly.
|
43
|
+
#
|
38
44
|
# For the given parent, what are all of the available collections that
|
39
45
|
# can be added as sub-collection of the parent.
|
40
46
|
def available_child_collections
|
47
|
+
Deprecation.warn "#{self.class}#available_child_collections " \
|
48
|
+
"is deprecated. the helper of the same name or " \
|
49
|
+
"Hyrax::Collections::NestedCollectionQueryService " \
|
50
|
+
"instead."
|
51
|
+
|
41
52
|
query_service.available_child_collections(parent: parent, scope: context)
|
42
53
|
end
|
43
54
|
|
55
|
+
##
|
56
|
+
# @deprecated this method is unused by hyrax, and is effectively a
|
57
|
+
# delegation to `Hyrax::Collections::NestedCollectionQueryService`.
|
58
|
+
# if you want to be sure to use nested indexing to generate this list,
|
59
|
+
# use the query service directly.
|
60
|
+
#
|
44
61
|
# For the given child, what are all of the available collections to
|
45
62
|
# which the child can be added as a sub-collection.
|
46
63
|
def available_parent_collections
|
64
|
+
Deprecation.warn "#{self.class}#available_parent_collections " \
|
65
|
+
"is deprecated. the helper of the same name or " \
|
66
|
+
"Hyrax::Collections::NestedCollectionQueryService " \
|
67
|
+
"instead."
|
68
|
+
|
47
69
|
query_service.available_parent_collections(child: child, scope: context)
|
48
70
|
end
|
49
71
|
|
@@ -61,7 +83,7 @@ module Hyrax
|
|
61
83
|
|
62
84
|
def remove
|
63
85
|
if context.can? :edit, parent
|
64
|
-
persistence_service.remove_nested_relationship_for(parent: parent, child: child)
|
86
|
+
persistence_service.remove_nested_relationship_for(parent: parent, child: child, user: context.current_user)
|
65
87
|
else
|
66
88
|
errors.add(:parent, :cannot_remove_relationship)
|
67
89
|
false
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Hyrax
|
4
|
+
module Forms
|
5
|
+
##
|
6
|
+
# @api public
|
7
|
+
class FileSetForm < Hyrax::ChangeSet
|
8
|
+
include Hyrax::FormFields(:core_metadata)
|
9
|
+
|
10
|
+
class << self
|
11
|
+
##
|
12
|
+
# @return [Array<Symbol>] list of required field names as symbols
|
13
|
+
def required_fields
|
14
|
+
definitions
|
15
|
+
.select { |_, definition| definition[:required] }
|
16
|
+
.keys.map(&:to_sym)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
property :creator, required: true
|
21
|
+
property :license, required: true
|
22
|
+
|
23
|
+
property :based_near
|
24
|
+
property :contributor
|
25
|
+
property :date_created
|
26
|
+
property :description
|
27
|
+
property :identifier
|
28
|
+
property :keyword
|
29
|
+
property :language
|
30
|
+
property :publisher
|
31
|
+
property :related_url
|
32
|
+
property :subject
|
33
|
+
|
34
|
+
property :permissions, virtual: true
|
35
|
+
property :visibility, default: VisibilityIntention::PRIVATE
|
36
|
+
|
37
|
+
# virtual properties for embargo/lease;
|
38
|
+
property :embargo_release_date, virtual: true
|
39
|
+
property :visibility_after_embargo, virtual: true
|
40
|
+
property :visibility_during_embargo, virtual: true
|
41
|
+
property :lease_expiration_date, virtual: true
|
42
|
+
property :visibility_after_lease, virtual: true
|
43
|
+
property :visibility_during_lease, virtual: true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Forms
|
4
|
+
##
|
5
|
+
# Nested form for permissions.
|
6
|
+
#
|
7
|
+
# @note due to historical oddities with Hydra::AccessControls and Hydra
|
8
|
+
# Editor, Hyrax's views rely on `agent_name` and `access` as field
|
9
|
+
# names. we provide these as virtual fields and prepopulate these from
|
10
|
+
# `Hyrax::Permission`.
|
11
|
+
class Permission < Hyrax::ChangeSet
|
12
|
+
property :agent_name, virtual: true, prepopulator: ->(_opts) { self.agent_name = model.agent }
|
13
|
+
property :access, virtual: true, prepopulator: ->(_opts) { self.access = model.mode }
|
14
|
+
|
15
|
+
##
|
16
|
+
# @note support a {#to_hash} method for compatibility with
|
17
|
+
# {Hydra::AccessControl::Permissions}
|
18
|
+
def to_hash
|
19
|
+
{ name: agent_name, access: access }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -12,7 +12,13 @@ module Hyrax
|
|
12
12
|
# @return [#to_s] the primary key of the associated admin_set or collection
|
13
13
|
# def source_id (because you might come looking for this method)
|
14
14
|
delegate :id, to: :source_model, prefix: :source
|
15
|
-
|
15
|
+
|
16
|
+
##
|
17
|
+
# @deprecated use PermissionTemplate#reset_access_controls instead.
|
18
|
+
def reset_access_controls!
|
19
|
+
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
|
20
|
+
source_model.reset_access_controls!
|
21
|
+
end
|
16
22
|
|
17
23
|
# Stores which radio button under release "Varies" option is selected
|
18
24
|
attr_accessor :release_varies
|
@@ -67,7 +73,7 @@ module Hyrax
|
|
67
73
|
# Copy this access to the permissions of the Admin Set or Collection and to
|
68
74
|
# the WorkflowResponsibilities of the active workflow if this is an Admin Set
|
69
75
|
def update_access(remove_agent: false)
|
70
|
-
reset_access_controls!
|
76
|
+
source_model.reset_access_controls!
|
71
77
|
update_workflow_responsibilities(remove_agent: remove_agent) if source_model.is_a?(AdminSet)
|
72
78
|
end
|
73
79
|
|
@@ -32,15 +32,17 @@ module Hyrax
|
|
32
32
|
# This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
|
33
33
|
class ResourceForm < Hyrax::ChangeSet
|
34
34
|
##
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
35
|
+
# @api private
|
36
|
+
InWorksPopulator = lambda do |_options|
|
37
|
+
self.in_works_ids =
|
38
|
+
if persisted?
|
39
|
+
Hyrax.query_service
|
40
|
+
.find_inverse_references_by(resource: model, property: :member_ids)
|
41
|
+
.select(&:work?)
|
42
|
+
.map(&:id)
|
43
|
+
else
|
44
|
+
[]
|
45
|
+
end
|
44
46
|
end
|
45
47
|
|
46
48
|
##
|
@@ -77,7 +79,12 @@ module Hyrax
|
|
77
79
|
property :date_uploaded, readable: false
|
78
80
|
property :agreement_accepted, virtual: true, default: false, prepopulator: ->(_opts) { self.agreement_accepted = !model.new_record }
|
79
81
|
|
80
|
-
collection
|
82
|
+
collection(:permissions,
|
83
|
+
virtual: true,
|
84
|
+
default: [],
|
85
|
+
form: Hyrax::Forms::Permission,
|
86
|
+
populator: :permission_populator,
|
87
|
+
prepopulator: ->(_opts) { self.permissions = Hyrax::AccessControl.for(resource: model).permissions })
|
81
88
|
|
82
89
|
# virtual properties for embargo/lease;
|
83
90
|
property :embargo_release_date, virtual: true, prepopulator: ->(_opts) { self.embargo_release_date = model.embargo&.embargo_release_date }
|
@@ -90,6 +97,7 @@ module Hyrax
|
|
90
97
|
|
91
98
|
# pcdm relationships
|
92
99
|
property :admin_set_id, prepopulator: ->(_opts) { self.admin_set_id = AdminSet::DEFAULT_ID }
|
100
|
+
property :in_works_ids, virtual: true, prepopulator: InWorksPopulator
|
93
101
|
property :member_ids, default: [], type: Valkyrie::Types::Array
|
94
102
|
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
95
103
|
|
@@ -116,10 +124,15 @@ module Hyrax
|
|
116
124
|
# @example
|
117
125
|
# monograph = Monograph.new
|
118
126
|
# change_set = Hyrax::Forms::ResourceForm.for(monograph)
|
119
|
-
def for(
|
120
|
-
"#{
|
127
|
+
def for(resource)
|
128
|
+
"#{resource.class.name}Form".constantize.new(resource)
|
121
129
|
rescue NameError => _err
|
122
|
-
|
130
|
+
case resource
|
131
|
+
when Hyrax::FileSet
|
132
|
+
Hyrax::Forms::FileSetForm.new(resource)
|
133
|
+
else
|
134
|
+
Hyrax::Forms::ResourceForm(resource.class).new(resource)
|
135
|
+
end
|
123
136
|
end
|
124
137
|
|
125
138
|
##
|
@@ -186,6 +199,11 @@ module Hyrax
|
|
186
199
|
|
187
200
|
private
|
188
201
|
|
202
|
+
# https://trailblazer.to/2.1/docs/reform.html#reform-populators-populator-collections
|
203
|
+
def permission_populator(collection:, index:, **)
|
204
|
+
Hyrax::Forms::Permission.new(collection[index])
|
205
|
+
end
|
206
|
+
|
189
207
|
def _form_field_definitions
|
190
208
|
self.class.definitions
|
191
209
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# rubocop:disable Metrics/ClassLength
|
3
2
|
module Hyrax
|
4
3
|
module Forms
|
5
4
|
# @abstract
|
6
|
-
class WorkForm
|
5
|
+
class WorkForm # rubocop:disable Metrics/ClassLength
|
7
6
|
include HydraEditor::Form
|
8
7
|
include HydraEditor::Form::Permissions
|
9
8
|
attr_accessor :current_ability
|
@@ -176,6 +175,10 @@ module Hyrax
|
|
176
175
|
based_near_attributes: [:id, :_destroy],
|
177
176
|
member_of_collections_attributes: [:id, :_destroy],
|
178
177
|
work_members_attributes: [:id, :_destroy]
|
178
|
+
},
|
179
|
+
{
|
180
|
+
file_set: [:visibility, :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
|
181
|
+
:visibility_during_lease, :lease_expiration_date, :visibility_after_lease, :uploaded_file_id]
|
179
182
|
}
|
180
183
|
]
|
181
184
|
end
|
@@ -1,6 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
|
-
module CollectionsHelper
|
3
|
+
module CollectionsHelper # rubocop:disable Metrics/ModuleLength
|
4
|
+
##
|
5
|
+
# @since 3.1.0
|
6
|
+
# @return [Array<SolrDocument>]
|
7
|
+
def available_child_collections(collection:)
|
8
|
+
Hyrax::Collections::NestedCollectionQueryService
|
9
|
+
.available_child_collections(parent: collection, scope: controller, limit_to_id: nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
##
|
13
|
+
# @since 3.1.0
|
14
|
+
#
|
15
|
+
# @note provides data for handleAddToCollection javascript
|
16
|
+
#
|
17
|
+
# @return [String] JSON document containing id/title pairs for eligible
|
18
|
+
# parent collections to be displayed in an "Add to Collection" dropdown
|
19
|
+
def available_parent_collections_data(collection:)
|
20
|
+
Hyrax::Collections::NestedCollectionQueryService
|
21
|
+
.available_parent_collections(child: collection, scope: controller, limit_to_id: nil)
|
22
|
+
.map do |result|
|
23
|
+
{ "id" => result.id, "title_first" => result.title.first }
|
24
|
+
end.to_json
|
25
|
+
end
|
26
|
+
|
4
27
|
##
|
5
28
|
# @since 3.0.0
|
6
29
|
# @return [#to_s]
|
@@ -97,6 +120,69 @@ module Hyrax
|
|
97
120
|
single_item_action_form_fields(form, document, 'remove')
|
98
121
|
end
|
99
122
|
|
123
|
+
##
|
124
|
+
# @param collection [Object]
|
125
|
+
def collection_type_label_for(collection:)
|
126
|
+
case collection
|
127
|
+
when Valkyrie::Resource
|
128
|
+
CollectionType
|
129
|
+
.find_by_gid!(collection.collection_type_gid)
|
130
|
+
.title
|
131
|
+
else
|
132
|
+
collection.collection_type.title
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
##
|
137
|
+
# @param collection [Object]
|
138
|
+
#
|
139
|
+
# @return [Boolean]
|
140
|
+
def collection_brandable?(collection:)
|
141
|
+
case collection
|
142
|
+
when Valkyrie::Resource
|
143
|
+
CollectionType
|
144
|
+
.find_by_gid!(collection.collection_type_gid)
|
145
|
+
.brandable?
|
146
|
+
else
|
147
|
+
collection.try(:brandable?)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# @param collection [Object]
|
153
|
+
#
|
154
|
+
# @return [Boolean]
|
155
|
+
def collection_discoverable?(collection:)
|
156
|
+
case collection
|
157
|
+
when Valkyrie::Resource
|
158
|
+
CollectionType
|
159
|
+
.find_by_gid!(collection.collection_type_gid)
|
160
|
+
.discoverable?
|
161
|
+
else
|
162
|
+
collection.try(:discoverable?)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
##
|
167
|
+
# @param collection [Object]
|
168
|
+
#
|
169
|
+
# @return [Boolean]
|
170
|
+
def collection_sharable?(collection:)
|
171
|
+
case collection
|
172
|
+
when Valkyrie::Resource
|
173
|
+
CollectionType
|
174
|
+
.find_by_gid!(collection.collection_type_gid)
|
175
|
+
.sharable?
|
176
|
+
else
|
177
|
+
collection.try(:sharable?)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
##
|
182
|
+
# @note this helper is primarily intended for use with blacklight facet
|
183
|
+
# fields. it assumes we index a `collection_type_gid` and the helper
|
184
|
+
# can be passed as as a `helper_method:` to `add_facet_field`.
|
185
|
+
#
|
100
186
|
# @param collection_type_gid [String] The gid of the CollectionType to be looked up
|
101
187
|
# @return [String] The CollectionType's title if found, else the gid
|
102
188
|
def collection_type_label(collection_type_gid)
|
@@ -112,4 +198,4 @@ module Hyrax
|
|
112
198
|
render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action
|
113
199
|
end
|
114
200
|
end
|
115
|
-
end
|
201
|
+
end # rubocop:enable Metrics/ModuleLength
|
@@ -7,25 +7,36 @@ module Hyrax
|
|
7
7
|
|
8
8
|
# @param user [User]
|
9
9
|
# @param where [Hash] applied as the where clause when querying the Hyrax::WorkRelation
|
10
|
-
#
|
10
|
+
# @return [Integer] number of works matching the where that the user deposited
|
11
11
|
# @see Hyrax::WorkRelation
|
12
12
|
def number_of_works(user = current_user, where: { generic_type_sim: "Work" })
|
13
|
-
|
14
|
-
|
13
|
+
field_pairs = field_pairs(user)
|
14
|
+
field_pairs.merge!(where)
|
15
|
+
Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs).count
|
15
16
|
rescue RSolr::Error::ConnectionRefused
|
16
17
|
'n/a'
|
17
18
|
end
|
18
19
|
|
20
|
+
# @param user [User]
|
21
|
+
# @return [Integer] number of FileSets the user deposited
|
19
22
|
def number_of_files(user = current_user)
|
20
|
-
::
|
23
|
+
Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
|
21
24
|
rescue RSolr::Error::ConnectionRefused
|
22
25
|
'n/a'
|
23
26
|
end
|
24
27
|
|
28
|
+
# @param user [User]
|
29
|
+
# @return [Integer] number of Collections the user created
|
25
30
|
def number_of_collections(user = current_user)
|
26
|
-
::
|
31
|
+
Hyrax::SolrQueryService.new.with_field_pairs(field_pairs: field_pairs(user)).count
|
27
32
|
rescue RSolr::Error::ConnectionRefused
|
28
33
|
'n/a'
|
29
34
|
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def field_pairs(user)
|
39
|
+
{ DepositSearchBuilder.depositor_field => user.user_key }
|
40
|
+
end
|
30
41
|
end
|
31
42
|
end
|