hyrax 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +5 -5
- data/.dassie/Gemfile +1 -1
- data/.dassie/app/controllers/catalog_controller.rb +6 -0
- data/Dockerfile +2 -3
- data/app/actors/hyrax/actors/base_actor.rb +1 -1
- data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -3
- data/app/actors/hyrax/actors/file_set_actor.rb +2 -0
- data/app/assets/stylesheets/hyrax/_styles.scss +5 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +13 -5
- data/app/controllers/concerns/hyrax/controller.rb +13 -2
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -19
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +5 -2
- data/app/controllers/hyrax/collections_controller.rb +3 -1
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +12 -9
- data/app/controllers/hyrax/dashboard/collections_controller.rb +92 -28
- data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +75 -39
- data/app/controllers/hyrax/my_controller.rb +4 -4
- data/app/controllers/hyrax/workflow_actions_controller.rb +8 -5
- data/app/forms/hyrax/forms/administrative_set_form.rb +62 -0
- data/app/forms/hyrax/forms/collection_form.rb +2 -2
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +14 -4
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +64 -0
- data/app/forms/hyrax/forms/resource_form.rb +15 -10
- data/app/forms/hyrax/forms/workflow_action_form.rb +4 -0
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +9 -0
- data/app/indexers/hyrax/administrative_set_indexer.rb +6 -6
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +2 -0
- data/app/models/admin_set.rb +16 -5
- data/app/models/concerns/hyrax/ability/admin_set_ability.rb +31 -7
- data/app/models/concerns/hyrax/ability/collection_ability.rb +35 -20
- data/app/models/concerns/hyrax/ability/collection_type_ability.rb +1 -1
- data/app/models/concerns/hyrax/ability.rb +2 -2
- data/app/models/concerns/hyrax/solr_document_behavior.rb +2 -2
- data/app/models/hyrax/administrative_set.rb +7 -1
- data/app/models/hyrax/permission.rb +1 -1
- data/app/models/hyrax/permission_template.rb +19 -5
- data/app/models/hyrax/work.rb +1 -0
- data/app/models/hyrax/workflow_action_info.rb +16 -0
- data/app/models/sipity/comment.rb +17 -0
- data/app/models/sipity.rb +11 -2
- data/app/presenters/hyrax/admin_set_presenter.rb +8 -3
- data/app/presenters/hyrax/collection_presenter.rb +3 -3
- data/app/presenters/hyrax/work_show_presenter.rb +2 -1
- data/app/search_builders/hyrax/abstract_type_relation.rb +4 -2
- data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +1 -1
- data/app/search_builders/hyrax/exposed_models_relation.rb +1 -1
- data/app/search_builders/hyrax/filter_by_type.rb +1 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +1 -1
- data/app/services/hyrax/admin_set_create_service.rb +136 -54
- data/app/services/hyrax/collection_types/permissions_service.rb +1 -1
- data/app/services/hyrax/collections/collection_member_service.rb +12 -2
- data/app/services/hyrax/collections/permissions_create_service.rb +81 -79
- data/app/services/hyrax/collections/permissions_service.rb +1 -1
- data/app/services/hyrax/curation_concern.rb +24 -2
- data/app/services/hyrax/default_middleware_stack.rb +11 -0
- data/app/services/hyrax/ensure_well_formed_admin_set_service.rb +3 -3
- data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +1 -0
- data/app/services/hyrax/listeners/metadata_index_listener.rb +25 -9
- data/app/services/hyrax/permission_manager.rb +4 -4
- data/app/services/hyrax/solr_service.rb +1 -1
- data/app/services/hyrax/statistics/collections/over_time.rb +2 -1
- data/app/services/hyrax/workflow/abstract_notification.rb +2 -2
- data/app/services/hyrax/workflow/action_taken_service.rb +16 -4
- data/app/services/hyrax/workflow/activate_object.rb +5 -4
- data/app/services/hyrax/workflow/changes_required_notification.rb +5 -4
- data/app/services/hyrax/workflow/deactivate_object.rb +7 -5
- data/app/services/hyrax/workflow/deposited_notification.rb +8 -4
- data/app/services/hyrax/workflow/grant_edit_to_depositor.rb +7 -3
- data/app/services/hyrax/workflow/grant_read_to_depositor.rb +10 -3
- data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +8 -2
- data/app/services/hyrax/workflow/workflow_action_service.rb +4 -1
- data/app/views/hyrax/admin/admin_sets/_form.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_sort_and_per_page.html.erb +1 -1
- data/app/views/hyrax/homepage/index.html.erb +1 -1
- data/app/views/hyrax/my/collections/_modal_collection_types_to_create.html.erb +1 -1
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -0
- data/app/views/layouts/hyrax.html.erb +1 -0
- data/app/views/shared/_read_only.html.erb +5 -0
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/templates/deployment.yaml +6 -0
- data/config/features.rb +3 -0
- data/config/initializers/1_healthz.rb +1 -0
- data/config/initializers/listeners.rb +2 -1
- data/config/locales/hyrax.en.yml +1 -0
- data/db/seeds.rb +1 -1
- data/documentation/developing-your-hyrax-based-app.md +1 -1
- data/documentation/legacyREADME.md +1 -1
- data/hyrax.gemspec +1 -1
- data/lib/generators/hyrax/templates/catalog_controller.rb +3 -1
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +10 -0
- data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +1 -1
- data/lib/generators/hyrax/work_resource/templates/indexer_spec.rb.erb +1 -0
- data/lib/hyrax/collection_name.rb +6 -2
- data/lib/hyrax/configuration.rb +28 -0
- data/lib/hyrax/form_fields.rb +1 -0
- data/lib/hyrax/publisher.rb +12 -0
- data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
- data/lib/hyrax/resource_sync/resource_list_writer.rb +2 -2
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +2 -0
- data/lib/hyrax/specs/shared_specs/indexers.rb +6 -0
- data/lib/hyrax/transactions/collection_create.rb +25 -0
- data/lib/hyrax/transactions/collection_update.rb +20 -0
- data/lib/hyrax/transactions/container.rb +26 -0
- data/lib/hyrax/transactions/steps/add_to_collections.rb +13 -1
- data/lib/hyrax/transactions/steps/apply_collection_type_permissions.rb +29 -0
- data/lib/hyrax/transactions/steps/save.rb +18 -6
- data/lib/hyrax/transactions/steps/set_collection_type_gid.rb +35 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/tasks/default_admin_set.rake +12 -11
- data/template.rb +1 -1
- metadata +16 -9
|
@@ -1,100 +1,136 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
module Hyrax
|
|
3
3
|
module Dashboard
|
|
4
|
+
##
|
|
5
|
+
# @api public
|
|
4
6
|
class NestCollectionsController < ApplicationController
|
|
5
7
|
include Blacklight::Base
|
|
8
|
+
|
|
6
9
|
class_attribute :form_class, :new_collection_form_class
|
|
7
10
|
self.form_class = Hyrax::Forms::Dashboard::NestCollectionForm
|
|
8
11
|
self.new_collection_form_class = Hyrax::Forms::CollectionForm
|
|
9
12
|
|
|
10
13
|
# Add this collection as a subcollection within another existing collection
|
|
11
14
|
def create_relationship_within
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
authorize! :read, form_params[:child_id]
|
|
16
|
+
|
|
17
|
+
if form.save
|
|
18
|
+
notice = I18n.t('create_within', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
|
|
19
|
+
redirect_to redirect_path(item: form.child), notice: notice
|
|
16
20
|
else
|
|
17
|
-
redirect_to redirect_path(item:
|
|
21
|
+
redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }
|
|
18
22
|
end
|
|
19
23
|
end
|
|
20
24
|
|
|
21
25
|
# create and link a NEW subcollection under this collection, with this collection as parent
|
|
22
26
|
def create_collection_under
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
authorize! :deposit, form_params[:parent_id]
|
|
28
|
+
|
|
29
|
+
if form.validate_add
|
|
30
|
+
redirect_to new_dashboard_collection_path(collection_type_id: parent_type_id_for(form), parent_id: form.parent)
|
|
26
31
|
else
|
|
27
|
-
redirect_to redirect_path(item:
|
|
32
|
+
redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }
|
|
28
33
|
end
|
|
29
34
|
end
|
|
30
35
|
|
|
31
36
|
# link this collection as parent by adding existing collection as subcollection under this one
|
|
32
37
|
def create_relationship_under
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
authorize! :read, form_params[:parent_id]
|
|
39
|
+
|
|
40
|
+
if form.save
|
|
41
|
+
notice = I18n.t('create_under', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
|
|
42
|
+
redirect_to redirect_path(item: form.parent), notice: notice
|
|
37
43
|
else
|
|
38
|
-
redirect_to redirect_path(item:
|
|
44
|
+
redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }
|
|
39
45
|
end
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
# remove a parent collection relationship from this collection
|
|
43
49
|
def remove_relationship_above
|
|
44
|
-
|
|
45
|
-
if
|
|
46
|
-
notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title:
|
|
47
|
-
redirect_to redirect_path(item:
|
|
50
|
+
authorize! :edit, form_params[:parent_id]
|
|
51
|
+
if form.remove
|
|
52
|
+
notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
|
|
53
|
+
redirect_to redirect_path(item: form.child), notice: notice
|
|
48
54
|
else
|
|
49
|
-
redirect_to redirect_path(item:
|
|
55
|
+
redirect_to redirect_path(item: form.child), flash: { error: form.errors.full_messages }
|
|
50
56
|
end
|
|
51
57
|
end
|
|
52
58
|
|
|
53
59
|
# remove a subcollection relationship from this collection
|
|
54
60
|
def remove_relationship_under
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
authorize! :edit, form_params[:parent_id]
|
|
62
|
+
|
|
63
|
+
if form.remove
|
|
64
|
+
notice = I18n.t('removed_relationship', scope: 'hyrax.dashboard.nest_collections_form', child_title: form.child.title.first, parent_title: form.parent.title.first)
|
|
65
|
+
redirect_to redirect_path(item: form.parent), notice: notice
|
|
59
66
|
else
|
|
60
|
-
redirect_to redirect_path(item:
|
|
67
|
+
redirect_to redirect_path(item: form.parent), flash: { error: form.errors.full_messages }
|
|
61
68
|
end
|
|
62
69
|
end
|
|
63
70
|
|
|
64
71
|
private
|
|
65
72
|
|
|
73
|
+
##
|
|
74
|
+
# @deprecated
|
|
66
75
|
def build_within_form
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
parent = params.key?(:parent_id) ? ::Collection.find(params[:parent_id]) : nil
|
|
70
|
-
form_class.new(child: child, parent: parent, context: self)
|
|
76
|
+
authorize! :read, form_params[:child_id]
|
|
77
|
+
form_class.new(context: self, **form_params.to_h.symbolize_keys)
|
|
71
78
|
end
|
|
79
|
+
deprecation_deprecate :build_within_form
|
|
72
80
|
|
|
81
|
+
##
|
|
82
|
+
# @deprecated
|
|
73
83
|
def build_under_form
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
child = params.key?(:child_id) ? ::Collection.find(params[:child_id]) : nil
|
|
77
|
-
form_class.new(child: child, parent: parent, context: self)
|
|
84
|
+
authorize! :read, form_params[:parent_id]
|
|
85
|
+
form_class.new(context: self, **form_params.to_h.symbolize_keys)
|
|
78
86
|
end
|
|
87
|
+
deprecation_deprecate :build_under_form
|
|
79
88
|
|
|
89
|
+
##
|
|
90
|
+
# @deprecated
|
|
80
91
|
def build_create_collection_form
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
form_class.new(child: nil, parent: parent, context: self)
|
|
92
|
+
authorize! :deposit, form_params[:parent_id]
|
|
93
|
+
form_class.new(context: self, **form_params.to_h.symbolize_keys)
|
|
84
94
|
end
|
|
95
|
+
deprecation_deprecate :build_create_collection_form
|
|
85
96
|
|
|
97
|
+
##
|
|
98
|
+
# @deprecated
|
|
86
99
|
def build_remove_form
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
authorize! :edit, parent
|
|
90
|
-
form_class.new(child: child, parent: parent, context: self)
|
|
100
|
+
authorize! :edit, form_params[:parent_id]
|
|
101
|
+
form_class.new(context: self, **form_params.to_h.symbolize_keys)
|
|
91
102
|
end
|
|
103
|
+
deprecation_deprecate :build_create_collection_form
|
|
92
104
|
|
|
105
|
+
##
|
|
106
|
+
# @api public
|
|
107
|
+
# @since 3.2.0
|
|
108
|
+
def form
|
|
109
|
+
@form ||=
|
|
110
|
+
form_class.new(context: self, **form_params.to_h.symbolize_keys)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# @api public
|
|
115
|
+
# @since 3.2.0
|
|
116
|
+
def form_params
|
|
117
|
+
params.slice(:child_id, :parent_id).permit!
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
##
|
|
121
|
+
# @api public
|
|
122
|
+
#
|
|
93
123
|
# determine appropriate redirect location depending on specified source
|
|
94
124
|
def redirect_path(item:)
|
|
95
125
|
return my_collections_path if params[:source] == 'my'
|
|
96
126
|
dashboard_collection_path(item)
|
|
97
127
|
end
|
|
128
|
+
|
|
129
|
+
##
|
|
130
|
+
# @api private
|
|
131
|
+
def parent_type_id_for(form)
|
|
132
|
+
URI::GID.parse(form.parent.collection_type_gid).model_id
|
|
133
|
+
end
|
|
98
134
|
end
|
|
99
135
|
end
|
|
100
136
|
end
|
|
@@ -27,7 +27,9 @@ module Hyrax
|
|
|
27
27
|
configure_facets
|
|
28
28
|
|
|
29
29
|
before_action :authenticate_user!
|
|
30
|
-
load_and_authorize_resource only: :show,
|
|
30
|
+
load_and_authorize_resource only: :show,
|
|
31
|
+
instance_name: :collection,
|
|
32
|
+
class: Hyrax.config.collection_model
|
|
31
33
|
|
|
32
34
|
# include the render_check_all view helper method
|
|
33
35
|
helper Hyrax::BatchEditsHelper
|
|
@@ -36,9 +38,7 @@ module Hyrax
|
|
|
36
38
|
|
|
37
39
|
def index
|
|
38
40
|
@user = current_user
|
|
39
|
-
|
|
40
|
-
(@response, @document_list) = query_solr
|
|
41
|
-
end
|
|
41
|
+
(@response, @document_list) = search_service.search_results
|
|
42
42
|
prepare_instance_variables_for_batch_control_display
|
|
43
43
|
|
|
44
44
|
respond_to do |format|
|
|
@@ -3,6 +3,13 @@ module Hyrax
|
|
|
3
3
|
class WorkflowActionsController < ApplicationController
|
|
4
4
|
DEFAULT_FORM_CLASS = Hyrax::Forms::WorkflowActionForm
|
|
5
5
|
|
|
6
|
+
##
|
|
7
|
+
# @!attribute [r] curation_concern
|
|
8
|
+
# @api private
|
|
9
|
+
# @return [Hyrax::Resource]
|
|
10
|
+
attr_reader :curation_concern
|
|
11
|
+
|
|
12
|
+
load_resource class: Hyrax::Resource, instance_name: :curation_concern
|
|
6
13
|
before_action :authenticate_user!
|
|
7
14
|
|
|
8
15
|
def update
|
|
@@ -11,17 +18,13 @@ module Hyrax
|
|
|
11
18
|
else
|
|
12
19
|
respond_to do |wants|
|
|
13
20
|
wants.html { render 'hyrax/base/unauthorized', status: :unauthorized }
|
|
14
|
-
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors:
|
|
21
|
+
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: workflow_action_form.errors }) }
|
|
15
22
|
end
|
|
16
23
|
end
|
|
17
24
|
end
|
|
18
25
|
|
|
19
26
|
private
|
|
20
27
|
|
|
21
|
-
def curation_concern
|
|
22
|
-
@curation_concern ||= Hyrax.query_service.find_by_alternate_identifier(alternate_identifier: params[:id], use_valkyrie: false)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
28
|
def workflow_action_form
|
|
26
29
|
@workflow_action_form ||= DEFAULT_FORM_CLASS.new(
|
|
27
30
|
current_ability: current_ability,
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hyrax
|
|
4
|
+
module Forms
|
|
5
|
+
##
|
|
6
|
+
# @api public
|
|
7
|
+
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
|
|
8
|
+
class AdministrativeSetForm < Valkyrie::ChangeSet
|
|
9
|
+
property :title, required: true, primary: true
|
|
10
|
+
property :description, primary: true
|
|
11
|
+
|
|
12
|
+
property :human_readable_type, writable: false
|
|
13
|
+
property :date_modified, readable: false
|
|
14
|
+
property :date_uploaded, readable: false
|
|
15
|
+
|
|
16
|
+
property :depositor
|
|
17
|
+
|
|
18
|
+
class << self
|
|
19
|
+
def model_class
|
|
20
|
+
Hyrax::AdministrativeSet
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# @return [Array<Symbol>] list of required field names as symbols
|
|
25
|
+
def required_fields
|
|
26
|
+
definitions
|
|
27
|
+
.select { |_, definition| definition[:required] }
|
|
28
|
+
.keys.map(&:to_sym)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
##
|
|
33
|
+
# @return [Array<Symbol>] terms for display 'above-the-fold', or in the most
|
|
34
|
+
# prominent form real estate
|
|
35
|
+
def primary_terms
|
|
36
|
+
_form_field_definitions
|
|
37
|
+
.select { |_, definition| definition[:primary] }
|
|
38
|
+
.keys.map(&:to_sym)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# @return [Array<Symbol>] terms for display 'below-the-fold'
|
|
43
|
+
def secondary_terms
|
|
44
|
+
_form_field_definitions
|
|
45
|
+
.select { |_, definition| definition[:display] && !definition[:primary] }
|
|
46
|
+
.keys.map(&:to_sym)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# @return [Boolean] whether there are terms to display 'below-the-fold'
|
|
51
|
+
def display_additional_fields?
|
|
52
|
+
secondary_terms.any?
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def _form_field_definitions
|
|
58
|
+
self.class.definitions
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -16,7 +16,7 @@ module Hyrax
|
|
|
16
16
|
# Required for search builder (FIXME)
|
|
17
17
|
alias collection model
|
|
18
18
|
|
|
19
|
-
self.model_class =
|
|
19
|
+
self.model_class = Hyrax.config.collection_class
|
|
20
20
|
|
|
21
21
|
self.membership_service_class = Collections::CollectionMemberSearchService
|
|
22
22
|
|
|
@@ -131,7 +131,7 @@ module Hyrax
|
|
|
131
131
|
def available_parent_collections(scope:)
|
|
132
132
|
return @available_parents if @available_parents.present?
|
|
133
133
|
|
|
134
|
-
collection =
|
|
134
|
+
collection = model_class.find(id)
|
|
135
135
|
colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
|
|
136
136
|
@available_parents = colls.map do |col|
|
|
137
137
|
{ "id" => col.id, "title_first" => col.title.first }
|
|
@@ -10,18 +10,28 @@ module Hyrax
|
|
|
10
10
|
self.default_query_service = Hyrax::Collections::NestedCollectionQueryService
|
|
11
11
|
self.default_persistence_service = Hyrax::Collections::NestedCollectionPersistenceService
|
|
12
12
|
|
|
13
|
+
##
|
|
13
14
|
# @param parent [::Collection, NilClass]
|
|
14
15
|
# @param child [::Collection, NilClass]
|
|
16
|
+
# @param parent_id [String, nil]
|
|
17
|
+
# @param child_id [String, nil]
|
|
15
18
|
# @param context [#can?,#repository,#blacklight_config]
|
|
16
19
|
# @param query_service [Hyrax::Collections::NestedCollectionQueryService]
|
|
17
20
|
# @param persistence_service [Hyrax::Collections::NestedCollectionPersistenceService] responsible for persisting the parent/child relationship
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
# rubocop:disable Metrics/ParameterLists
|
|
22
|
+
def initialize(parent: nil,
|
|
23
|
+
child: nil,
|
|
24
|
+
parent_id: nil,
|
|
25
|
+
child_id: nil,
|
|
26
|
+
context:,
|
|
27
|
+
query_service: default_query_service,
|
|
28
|
+
persistence_service: default_persistence_service)
|
|
29
|
+
self.parent = parent || (parent_id.present? && Hyrax.config.collection_class.find(parent_id))
|
|
30
|
+
self.child = child || (child_id.present? && Hyrax.config.collection_class.find(child_id))
|
|
21
31
|
self.context = context
|
|
22
32
|
self.query_service = query_service
|
|
23
33
|
self.persistence_service = persistence_service
|
|
24
|
-
end
|
|
34
|
+
end # rubocop:enable Metrics/ParameterLists
|
|
25
35
|
|
|
26
36
|
attr_accessor :parent, :child
|
|
27
37
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hyrax
|
|
4
|
+
module Forms
|
|
5
|
+
##
|
|
6
|
+
# @api public
|
|
7
|
+
# @see https://github.com/samvera/valkyrie/wiki/ChangeSets-and-Dirty-Tracking
|
|
8
|
+
class PcdmCollectionForm < Valkyrie::ChangeSet # rubocop:disable Metrics/ClassLength
|
|
9
|
+
property :title, required: true, primary: true
|
|
10
|
+
|
|
11
|
+
property :human_readable_type, writable: false
|
|
12
|
+
property :date_modified, readable: false
|
|
13
|
+
property :date_uploaded, readable: false
|
|
14
|
+
|
|
15
|
+
property :depositor, required: true
|
|
16
|
+
property :collection_type_gid, required: true
|
|
17
|
+
|
|
18
|
+
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
|
19
|
+
|
|
20
|
+
class << self
|
|
21
|
+
def model_class
|
|
22
|
+
Hyrax::PcdmCollection
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
##
|
|
26
|
+
# @return [Array<Symbol>] list of required field names as symbols
|
|
27
|
+
def required_fields
|
|
28
|
+
definitions
|
|
29
|
+
.select { |_, definition| definition[:required] }
|
|
30
|
+
.keys.map(&:to_sym)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# @return [Array<Symbol>] terms for display 'above-the-fold', or in the most
|
|
36
|
+
# prominent form real estate
|
|
37
|
+
def primary_terms
|
|
38
|
+
_form_field_definitions
|
|
39
|
+
.select { |_, definition| definition[:primary] }
|
|
40
|
+
.keys.map(&:to_sym)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
##
|
|
44
|
+
# @return [Array<Symbol>] terms for display 'below-the-fold'
|
|
45
|
+
def secondary_terms
|
|
46
|
+
_form_field_definitions
|
|
47
|
+
.select { |_, definition| definition[:display] && !definition[:primary] }
|
|
48
|
+
.keys.map(&:to_sym)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# @return [Boolean] whether there are terms to display 'below-the-fold'
|
|
53
|
+
def display_additional_fields?
|
|
54
|
+
secondary_terms.any?
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def _form_field_definitions
|
|
60
|
+
self.class.definitions
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -30,7 +30,7 @@ module Hyrax
|
|
|
30
30
|
# @api public
|
|
31
31
|
#
|
|
32
32
|
# This form wraps `Hyrax::ChangeSet` in the `HydraEditor::Form` interface.
|
|
33
|
-
class ResourceForm < Hyrax::ChangeSet
|
|
33
|
+
class ResourceForm < Hyrax::ChangeSet # rubocop:disable Metrics/ClassLength
|
|
34
34
|
##
|
|
35
35
|
# @api private
|
|
36
36
|
InWorksPopulator = lambda do |_options|
|
|
@@ -53,16 +53,15 @@ module Hyrax
|
|
|
53
53
|
# we want to move away from application side lock validation and rely
|
|
54
54
|
# on the adapter/database features instead.
|
|
55
55
|
LockKeyPopulator = lambda do |_options|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if Hyrax.config.disable_wings || !Hyrax.metadata_adapter.is_a?(Wings::Valkyrie::MetadataAdapter)
|
|
57
|
+
Hyrax.logger.info "trying to prepopulate a lock token for " \
|
|
58
|
+
"#{self.class.inspect}, but optimistic locking isn't " \
|
|
59
|
+
"supported for the configured adapter: #{Hyrax.metadata_adapter.class}"
|
|
60
|
+
self.version = ''
|
|
61
|
+
else
|
|
62
|
+
self.version =
|
|
59
63
|
model.persisted? ? Wings::ActiveFedoraConverter.convert(resource: model).etag : ''
|
|
60
|
-
|
|
61
|
-
Hyrax.logger.info 'trying to prepopulate a lock token for ' \
|
|
62
|
-
"#{self.class.inspect}, but optimistic locking isn't " \
|
|
63
|
-
"supported for the configured adapter: #{Hyrax.metadata_adapter.class}"
|
|
64
|
-
''
|
|
65
|
-
end
|
|
64
|
+
end
|
|
66
65
|
end
|
|
67
66
|
|
|
68
67
|
class_attribute :model_class
|
|
@@ -101,6 +100,10 @@ module Hyrax
|
|
|
101
100
|
property :member_ids, default: [], type: Valkyrie::Types::Array
|
|
102
101
|
property :member_of_collection_ids, default: [], type: Valkyrie::Types::Array
|
|
103
102
|
|
|
103
|
+
property :representative_id, type: Valkyrie::Types::String
|
|
104
|
+
property :thumbnail_id, type: Valkyrie::Types::String
|
|
105
|
+
property :rendering_ids, default: [], type: Valkyrie::Types::Array
|
|
106
|
+
|
|
104
107
|
# provide a lock token for optimistic locking; we name this `version` for
|
|
105
108
|
# backwards compatibility
|
|
106
109
|
#
|
|
@@ -130,6 +133,8 @@ module Hyrax
|
|
|
130
133
|
case resource
|
|
131
134
|
when Hyrax::FileSet
|
|
132
135
|
Hyrax::Forms::FileSetForm.new(resource)
|
|
136
|
+
when Hyrax::PcdmCollection
|
|
137
|
+
Hyrax::Forms::PcdmCollectionForm.new(resource)
|
|
133
138
|
else
|
|
134
139
|
Hyrax::Forms::ResourceForm(resource.class).new(resource)
|
|
135
140
|
end
|
|
@@ -17,6 +17,10 @@ module Hyrax
|
|
|
17
17
|
include ActiveModel::Validations
|
|
18
18
|
extend ActiveModel::Translation
|
|
19
19
|
|
|
20
|
+
##
|
|
21
|
+
# @param current_ability [::Ability]
|
|
22
|
+
# @param work [ActiveFedora::Base, Valkyrie::Resource]
|
|
23
|
+
# @param attributes [Hash{Symbol => String}]
|
|
20
24
|
def initialize(current_ability:, work:, attributes: {})
|
|
21
25
|
@current_ability = current_ability
|
|
22
26
|
@work = work
|
|
@@ -296,6 +296,15 @@ module Hyrax
|
|
|
296
296
|
solr_field.first
|
|
297
297
|
end
|
|
298
298
|
|
|
299
|
+
##
|
|
300
|
+
# @param [Object] an object that might have a thumbnail
|
|
301
|
+
#
|
|
302
|
+
# @return [String] a label for the object's thumbnail
|
|
303
|
+
def thumbnail_label_for(object:)
|
|
304
|
+
object.try(:thumbnail_title).presence ||
|
|
305
|
+
""
|
|
306
|
+
end
|
|
307
|
+
|
|
299
308
|
private
|
|
300
309
|
|
|
301
310
|
def user_agent
|
|
@@ -4,14 +4,14 @@ module Hyrax
|
|
|
4
4
|
##
|
|
5
5
|
# Indexes Hyrax::AdministrativeSet objects
|
|
6
6
|
class AdministrativeSetIndexer < Hyrax::ValkyrieIndexer
|
|
7
|
+
include Hyrax::Indexer(:core_metadata)
|
|
8
|
+
|
|
7
9
|
def to_solr # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
8
10
|
super.tap do |solr_doc|
|
|
9
|
-
solr_doc[
|
|
10
|
-
solr_doc[
|
|
11
|
-
solr_doc[
|
|
12
|
-
solr_doc[
|
|
13
|
-
solr_doc['title_tesim'] = resource.title
|
|
14
|
-
solr_doc['title_sim'] = resource.title
|
|
11
|
+
solr_doc[:generic_type_si] = 'Admin Set'
|
|
12
|
+
solr_doc[:alternative_title_tesim] = resource.alternative_title
|
|
13
|
+
solr_doc[:creator_ssim] = resource.creator
|
|
14
|
+
solr_doc[:description_tesim] = resource.description
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -15,6 +15,8 @@ module Hyrax
|
|
|
15
15
|
index_document[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s)
|
|
16
16
|
index_document[:generic_type_sim] = ['Collection']
|
|
17
17
|
index_document[:thumbnail_path_ss] = Hyrax::CollectionThumbnailPathService.call(resource)
|
|
18
|
+
index_document[:depositor_ssim] = [resource.depositor]
|
|
19
|
+
index_document[:depositor_tesim] = [resource.depositor]
|
|
18
20
|
end
|
|
19
21
|
end
|
|
20
22
|
end
|
data/app/models/admin_set.rb
CHANGED
|
@@ -21,9 +21,10 @@ class AdminSet < ActiveFedora::Base
|
|
|
21
21
|
include Hyrax::Noid
|
|
22
22
|
include Hyrax::HumanReadableType
|
|
23
23
|
include Hyrax::HasRepresentative
|
|
24
|
+
include Hyrax::Permissions
|
|
24
25
|
|
|
25
|
-
DEFAULT_ID =
|
|
26
|
-
DEFAULT_TITLE =
|
|
26
|
+
DEFAULT_ID = Hyrax::AdminSetCreateService::DEFAULT_ID
|
|
27
|
+
DEFAULT_TITLE = Hyrax::AdminSetCreateService::DEFAULT_TITLE
|
|
27
28
|
DEFAULT_WORKFLOW_NAME = Hyrax.config.default_active_workflow_name
|
|
28
29
|
|
|
29
30
|
validates_with Hyrax::HasOneTitleValidator
|
|
@@ -42,17 +43,27 @@ class AdminSet < ActiveFedora::Base
|
|
|
42
43
|
after_destroy :destroy_permission_template
|
|
43
44
|
|
|
44
45
|
def self.default_set?(id)
|
|
45
|
-
|
|
46
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
|
47
|
+
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
|
|
48
|
+
Hyrax::AdminSetCreateService.default_admin_set?(id: id)
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
def default_set?
|
|
52
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
|
53
|
+
"Instead, use 'Hyrax::AdminSetCreateService.default_admin_set?(id:)'.")
|
|
49
54
|
self.class.default_set?(id)
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
# Creates the default AdminSet and an associated PermissionTemplate with workflow
|
|
53
58
|
def self.find_or_create_default_admin_set_id
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
|
60
|
+
"Instead, use 'Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id'.")
|
|
61
|
+
Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def collection_type_gid
|
|
65
|
+
# allow AdminSet to behave more like a regular Collection
|
|
66
|
+
Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id
|
|
56
67
|
end
|
|
57
68
|
|
|
58
69
|
def to_s
|
|
@@ -2,28 +2,52 @@
|
|
|
2
2
|
module Hyrax
|
|
3
3
|
module Ability
|
|
4
4
|
module AdminSetAbility
|
|
5
|
-
def admin_set_abilities # rubocop:disable Metrics/MethodLength
|
|
5
|
+
def admin_set_abilities # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
|
6
6
|
if admin?
|
|
7
|
-
can :manage, AdminSet
|
|
7
|
+
can :manage, [AdminSet, Hyrax::AdministrativeSet]
|
|
8
8
|
can :manage_any, AdminSet
|
|
9
|
+
can :manage_any, Hyrax::AdministrativeSet
|
|
9
10
|
can :create_any, AdminSet
|
|
11
|
+
can :create_any, Hyrax::AdministrativeSet
|
|
10
12
|
can :view_admin_show_any, AdminSet
|
|
13
|
+
can :view_admin_show_any, Hyrax::AdministrativeSet
|
|
11
14
|
else
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
if Hyrax::Collections::PermissionsService.can_manage_any_admin_set?(ability: self)
|
|
16
|
+
can :manage_any, AdminSet
|
|
17
|
+
can :manage_any, Hyrax::AdministrativeSet
|
|
18
|
+
end
|
|
19
|
+
if Hyrax::CollectionTypes::PermissionsService.can_create_admin_set_collection_type?(ability: self)
|
|
20
|
+
can :create, [AdminSet, Hyrax::AdministrativeSet]
|
|
21
|
+
can :create_any, AdminSet
|
|
22
|
+
can :create_any, Hyrax::AdministrativeSet
|
|
23
|
+
end
|
|
24
|
+
if Hyrax::Collections::PermissionsService.can_view_admin_show_for_any_admin_set?(ability: self)
|
|
25
|
+
can :view_admin_show_any, AdminSet
|
|
26
|
+
can :view_admin_show_any, Hyrax::AdministrativeSet
|
|
27
|
+
end
|
|
28
|
+
# [:edit, :update, :destroy] for AdminSet is controlled by Hydra::Ability #edit_permissions
|
|
29
|
+
can [:edit, :update, :destroy], Hyrax::AdministrativeSet do |admin_set| # for test by solr_doc, see solr_document_ability.rb
|
|
17
30
|
test_edit(admin_set.id)
|
|
18
31
|
end
|
|
19
32
|
|
|
20
33
|
can :deposit, AdminSet do |admin_set| # for test by solr_doc, see collection_ability.rb
|
|
21
34
|
Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection_id: admin_set.id)
|
|
22
35
|
end
|
|
36
|
+
can :deposit, Hyrax::AdministrativeSet do |admin_set| # for test by solr_doc, see collection_ability.rb
|
|
37
|
+
Hyrax::Collections::PermissionsService.can_deposit_in_collection?(ability: self, collection_id: admin_set.id)
|
|
38
|
+
end
|
|
23
39
|
|
|
24
40
|
can :view_admin_show, AdminSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
|
|
25
41
|
Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection_id: admin_set.id)
|
|
26
42
|
end
|
|
43
|
+
can :view_admin_show, Hyrax::AdministrativeSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
|
|
44
|
+
Hyrax::Collections::PermissionsService.can_view_admin_show_for_collection?(ability: self, collection_id: admin_set.id)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# [:read] for AdminSet is controlled by Hydra::Ability #read_permissions
|
|
48
|
+
can :read, Hyrax::AdministrativeSet do |admin_set| # admin show page # for test by solr_doc, see collection_ability.rb
|
|
49
|
+
test_read(admin_set.id)
|
|
50
|
+
end
|
|
27
51
|
end
|
|
28
52
|
|
|
29
53
|
# TODO: I'm not sure why this is checked with AdminSet abilities. It was before the refactor and since I'm not sure what the connection is, I left it here.
|