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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1dfd66c313400a16a149d5bdb7a2495164c18bce86b9bd8f079970b68e328cf
|
|
4
|
+
data.tar.gz: 66c678a483a9f2822712dea5f8448e55d9019dbdc47605b9a03177d0465ab775
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8309e7eb25d84767fd2395e04326df0c1f925bef0a2618818b0430327ac623f0f4078abbd45b5a966ccb6ccbc4c6bc233823e7d1b00d08b5e977771c97be4306
|
|
7
|
+
data.tar.gz: dd759280930d7cbc3448b3fafbfae5bbb631f9eb8fb93a9dca2e9ee73b3226f71d5b453ec29a40ac087dacf076059b752e8e72b2b9e35c5efab1b54743a1e958
|
data/.circleci/config.yml
CHANGED
|
@@ -189,21 +189,21 @@ workflows:
|
|
|
189
189
|
hyrax_valkyrie: "true"
|
|
190
190
|
requires:
|
|
191
191
|
- build
|
|
192
|
-
ruby2-7-
|
|
192
|
+
ruby2-7-4:
|
|
193
193
|
jobs:
|
|
194
194
|
- bundle:
|
|
195
|
-
ruby_version: "2.7.
|
|
195
|
+
ruby_version: "2.7.4"
|
|
196
196
|
rails_version: "5.2.6"
|
|
197
197
|
bundler_version: "2.1.4"
|
|
198
198
|
- build:
|
|
199
|
-
ruby_version: "2.7.
|
|
199
|
+
ruby_version: "2.7.4"
|
|
200
200
|
rails_version: "5.2.6"
|
|
201
201
|
bundler_version: "2.1.4"
|
|
202
202
|
requires:
|
|
203
203
|
- bundle
|
|
204
204
|
- test:
|
|
205
|
-
name: "ruby2-7-
|
|
206
|
-
ruby_version: "2.7.
|
|
205
|
+
name: "ruby2-7-4"
|
|
206
|
+
ruby_version: "2.7.4"
|
|
207
207
|
bundler_version: "2.1.4"
|
|
208
208
|
requires:
|
|
209
209
|
- build
|
data/.dassie/Gemfile
CHANGED
|
@@ -5,6 +5,8 @@ class CatalogController < ApplicationController
|
|
|
5
5
|
|
|
6
6
|
# This filter applies the hydra access controls
|
|
7
7
|
before_action :enforce_show_permissions, only: :show
|
|
8
|
+
# Allow all search options when in read-only mode
|
|
9
|
+
skip_before_action :check_read_only
|
|
8
10
|
|
|
9
11
|
def self.uploaded_field
|
|
10
12
|
"system_create_dtsi"
|
|
@@ -28,6 +30,10 @@ class CatalogController < ApplicationController
|
|
|
28
30
|
config.view.gallery.partials = [:index_header, :index]
|
|
29
31
|
config.view.slideshow.partials = [:index]
|
|
30
32
|
|
|
33
|
+
# Because too many times on Samvera tech people raise a problem regarding a failed query to SOLR.
|
|
34
|
+
# Often, it's because they inadvertently exceeded the character limit of a GET request.
|
|
35
|
+
config.http_method = :post
|
|
36
|
+
|
|
31
37
|
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
|
|
32
38
|
config.default_solr_params = {
|
|
33
39
|
qt: "search",
|
data/Dockerfile
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
ARG RUBY_VERSION=2.7.
|
|
2
|
-
|
|
3
|
-
FROM ruby:$RUBY_VERSION-alpine3.12 as hyrax-base
|
|
1
|
+
ARG RUBY_VERSION=2.7.4
|
|
2
|
+
FROM ruby:$RUBY_VERSION-alpine3.14 as hyrax-base
|
|
4
3
|
|
|
5
4
|
ARG DATABASE_APK_PACKAGE="postgresql-dev"
|
|
6
5
|
ARG EXTRA_APK_PACKAGES="git"
|
|
@@ -37,7 +37,7 @@ module Hyrax
|
|
|
37
37
|
# @return [Boolean] true if destroy was successful
|
|
38
38
|
def destroy(env)
|
|
39
39
|
env.curation_concern.in_collection_ids.each do |id|
|
|
40
|
-
destination_collection =
|
|
40
|
+
destination_collection = Hyrax.config.collection_class.find(id)
|
|
41
41
|
destination_collection.members.delete(env.curation_concern)
|
|
42
42
|
destination_collection.update_index
|
|
43
43
|
end
|
|
@@ -69,7 +69,7 @@ module Hyrax
|
|
|
69
69
|
# Adds the item to the ordered members so that it displays in the items
|
|
70
70
|
# along side the FileSets on the show page
|
|
71
71
|
def add(env, id)
|
|
72
|
-
collection =
|
|
72
|
+
collection = Hyrax.config.collection_class.find(id)
|
|
73
73
|
collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
|
|
74
74
|
|
|
75
75
|
return unless env.current_ability.can?(:deposit, collection)
|
|
@@ -78,7 +78,7 @@ module Hyrax
|
|
|
78
78
|
|
|
79
79
|
# Remove the object from the members set and the ordered members list
|
|
80
80
|
def remove(curation_concern, id)
|
|
81
|
-
collection =
|
|
81
|
+
collection = Hyrax.config.collection_class.find(id)
|
|
82
82
|
curation_concern.member_of_collections.delete(collection)
|
|
83
83
|
end
|
|
84
84
|
|
|
@@ -107,7 +107,7 @@ module Hyrax
|
|
|
107
107
|
collection_id = attributes_collection.first.second['id']
|
|
108
108
|
|
|
109
109
|
# Do not apply permissions to work if collection type is configured not to
|
|
110
|
-
collection =
|
|
110
|
+
collection = Hyrax.config.collection_class.find(collection_id)
|
|
111
111
|
return unless collection.share_applies_to_new_works?
|
|
112
112
|
|
|
113
113
|
# Save the collection id in env for use in apply_permission_template_actor
|
|
@@ -165,6 +165,8 @@ module Hyrax
|
|
|
165
165
|
elsif file_set.import_url.present?
|
|
166
166
|
# This path is taken when file is a Tempfile (e.g. from ImportUrlJob)
|
|
167
167
|
File.basename(Addressable::URI.unencode(file.file_url))
|
|
168
|
+
elsif file.respond_to?(:original_filename) # e.g. Rack::Test::UploadedFile
|
|
169
|
+
file.original_filename
|
|
168
170
|
else
|
|
169
171
|
File.basename(file)
|
|
170
172
|
end
|
|
@@ -29,7 +29,7 @@ module Hyrax
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def show
|
|
32
|
-
@curation_concern
|
|
32
|
+
@curation_concern = @collection # we must populate curation_concern
|
|
33
33
|
presenter
|
|
34
34
|
query_collection_members
|
|
35
35
|
end
|
|
@@ -101,14 +101,22 @@ module Hyrax
|
|
|
101
101
|
# uses the class attribute +parent_collection_query_service+ by default.
|
|
102
102
|
def parent_collections(query_service: self.class.parent_collection_query_service)
|
|
103
103
|
page = params[:parent_collection_page].to_i
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
|
|
105
|
+
collection.parent_collections =
|
|
106
|
+
query_service.parent_collections(child: collection_object,
|
|
107
|
+
scope: self,
|
|
108
|
+
page: page)
|
|
107
109
|
end
|
|
108
110
|
alias load_parent_collections parent_collections
|
|
109
111
|
|
|
112
|
+
##
|
|
113
|
+
# @note this is here because, though we want to load and authorize the real
|
|
114
|
+
# collection for show views, for apparently historical reasons,
|
|
115
|
+
# {#collection} is overridden to access `@presenter`. this should probably
|
|
116
|
+
# be deprecated and callers encouraged to use `@collection` but the scope
|
|
117
|
+
# and impact of that change needs more evaluation.
|
|
110
118
|
def collection_object
|
|
111
|
-
action_name == 'show' ?
|
|
119
|
+
action_name == 'show' ? @collection : collection
|
|
112
120
|
end
|
|
113
121
|
|
|
114
122
|
def member_subcollections
|
|
@@ -16,6 +16,7 @@ module Hyrax::Controller
|
|
|
16
16
|
include Hydra::Controller::ControllerBehavior
|
|
17
17
|
helper_method :create_work_presenter
|
|
18
18
|
before_action :set_locale
|
|
19
|
+
before_action :check_read_only, except: [:show, :index]
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
# Provide a place for Devise to send the user to after signing in
|
|
@@ -34,12 +35,14 @@ module Hyrax::Controller
|
|
|
34
35
|
# @api public
|
|
35
36
|
#
|
|
36
37
|
# @return [#[]] a resolver for Hyrax's Transactions; this *should* be a
|
|
37
|
-
# thread-safe Dry::Container, but callers to this method should strictly
|
|
38
|
-
# use
|
|
38
|
+
# thread-safe {Dry::Container}, but callers to this method should strictly
|
|
39
|
+
# use +#[]+ for access.
|
|
39
40
|
#
|
|
40
41
|
# @example
|
|
41
42
|
# transactions['change_set.create_work'].call(my_form)
|
|
42
43
|
#
|
|
44
|
+
# @see Hyrax::Transactions::Container
|
|
45
|
+
# @see Hyrax::Transactions::Transaction
|
|
43
46
|
# @see https://dry-rb.org/gems/dry-container
|
|
44
47
|
def transactions
|
|
45
48
|
Hyrax::Transactions::Container
|
|
@@ -88,4 +91,12 @@ module Hyrax::Controller
|
|
|
88
91
|
wants.json { render_json_response(response_type: :unauthorized, message: json_message) }
|
|
89
92
|
end
|
|
90
93
|
end
|
|
94
|
+
|
|
95
|
+
# Redirect all deposit and edit requests with warning message when in read only mode
|
|
96
|
+
def check_read_only
|
|
97
|
+
return unless Flipflop.read_only?
|
|
98
|
+
# Allows feature to be turned off
|
|
99
|
+
return if self.class.to_s == Hyrax::Admin::StrategiesController.to_s
|
|
100
|
+
redirect_to root_path, flash: { error: t('hyrax.read_only') }
|
|
101
|
+
end
|
|
91
102
|
end
|
|
@@ -4,9 +4,7 @@ module Hyrax
|
|
|
4
4
|
include Hyrax::CollectionsControllerBehavior
|
|
5
5
|
|
|
6
6
|
before_action :authenticate_user!
|
|
7
|
-
before_action :ensure_manager!, except: [:show]
|
|
8
7
|
load_and_authorize_resource
|
|
9
|
-
before_action :ensure_viewer!, only: [:show]
|
|
10
8
|
|
|
11
9
|
# Catch permission errors
|
|
12
10
|
rescue_from Hydra::AccessDenied, CanCan::AccessDenied, with: :deny_adminset_access
|
|
@@ -43,10 +41,8 @@ module Hyrax
|
|
|
43
41
|
end
|
|
44
42
|
|
|
45
43
|
def index
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
add_breadcrumb t(:'hyrax.admin.sidebar.admin_sets'), hyrax.admin_admin_sets_path
|
|
49
|
-
@admin_sets = Hyrax::AdminSetService.new(self).search_results(:edit)
|
|
44
|
+
# admin sets are listed with collections
|
|
45
|
+
redirect_to hyrax.my_collections_url
|
|
50
46
|
end
|
|
51
47
|
|
|
52
48
|
def new
|
|
@@ -106,19 +102,6 @@ module Hyrax
|
|
|
106
102
|
hyrax.edit_admin_admin_set_path(@admin_set) + (params[:referer_anchor] || '')
|
|
107
103
|
end
|
|
108
104
|
|
|
109
|
-
def ensure_manager!
|
|
110
|
-
# TODO: Review for possible removal. Doesn't appear to apply anymore.
|
|
111
|
-
# Even though the user can view this admin set, they may not be able to view
|
|
112
|
-
# it on the admin page.
|
|
113
|
-
authorize! :manage_any, AdminSet
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
def ensure_viewer!
|
|
117
|
-
# Even though the user can view this admin set, they may not be able to view
|
|
118
|
-
# it on the admin page if access is granted as a public or registered user only.
|
|
119
|
-
authorize! :view_admin_show, @admin_set
|
|
120
|
-
end
|
|
121
|
-
|
|
122
105
|
def create_admin_set
|
|
123
106
|
admin_set_create_service.call(admin_set: @admin_set, creating_user: current_user)
|
|
124
107
|
end
|
|
@@ -35,7 +35,7 @@ module Hyrax
|
|
|
35
35
|
redirect_to hyrax.edit_admin_admin_set_path(source_id,
|
|
36
36
|
anchor: 'participants'),
|
|
37
37
|
notice: translate('participants', scope: 'hyrax.admin.admin_sets.form.permission_update_notices')
|
|
38
|
-
|
|
38
|
+
else
|
|
39
39
|
redirect_to hyrax.edit_dashboard_collection_path(source_id,
|
|
40
40
|
anchor: 'sharing'),
|
|
41
41
|
notice: translate('sharing', scope: 'hyrax.dashboard.collections.form.permission_update_notices')
|
|
@@ -47,7 +47,7 @@ module Hyrax
|
|
|
47
47
|
redirect_to hyrax.edit_admin_admin_set_path(source_id,
|
|
48
48
|
anchor: 'participants'),
|
|
49
49
|
alert: @permission_template_access.errors.full_messages.to_sentence
|
|
50
|
-
|
|
50
|
+
else
|
|
51
51
|
redirect_to hyrax.edit_dashboard_collection_path(source_id,
|
|
52
52
|
anchor: 'sharing'),
|
|
53
53
|
alert: @permission_template_access.errors.full_messages.to_sentence
|
|
@@ -56,6 +56,9 @@ module Hyrax
|
|
|
56
56
|
|
|
57
57
|
delegate :source_id, to: :permission_template
|
|
58
58
|
|
|
59
|
+
##
|
|
60
|
+
# @todo can we avoid querying solr to deciede where to redirect? we
|
|
61
|
+
# otherwise don't need this data at all.
|
|
59
62
|
def source
|
|
60
63
|
@source ||= ::SolrDocument.find(source_id)
|
|
61
64
|
end
|
|
@@ -4,7 +4,9 @@ module Hyrax
|
|
|
4
4
|
include CollectionsControllerBehavior
|
|
5
5
|
include BreadcrumbsForCollections
|
|
6
6
|
with_themed_layout :decide_layout
|
|
7
|
-
load_and_authorize_resource except: [:index, :
|
|
7
|
+
load_and_authorize_resource except: [:index, :create],
|
|
8
|
+
instance_name: :collection,
|
|
9
|
+
class: Hyrax.config.collection_model
|
|
8
10
|
|
|
9
11
|
# Renders a JSON response with a list of files in this collection
|
|
10
12
|
# This is used by the edit form to populate the thumbnail_id dropdown
|
|
@@ -7,6 +7,10 @@ module Hyrax
|
|
|
7
7
|
|
|
8
8
|
include Hyrax::Collections::AcceptsBatches
|
|
9
9
|
|
|
10
|
+
load_resource only: :update_members,
|
|
11
|
+
instance_name: :collection,
|
|
12
|
+
class: Hyrax.config.collection_model
|
|
13
|
+
|
|
10
14
|
def after_update
|
|
11
15
|
respond_to do |format|
|
|
12
16
|
format.html { redirect_to success_return_path, notice: t('hyrax.dashboard.my.action.collection_update_success') }
|
|
@@ -26,9 +30,9 @@ module Hyrax
|
|
|
26
30
|
after_update_error(err_msg) if err_msg.present?
|
|
27
31
|
return if err_msg.present?
|
|
28
32
|
|
|
29
|
-
collection.reindex_extent
|
|
33
|
+
@collection.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX)
|
|
30
34
|
begin
|
|
31
|
-
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id:
|
|
35
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: collection_id,
|
|
32
36
|
new_member_ids: batch_ids,
|
|
33
37
|
user: current_user)
|
|
34
38
|
after_update
|
|
@@ -46,9 +50,12 @@ module Hyrax
|
|
|
46
50
|
private
|
|
47
51
|
|
|
48
52
|
def validate
|
|
49
|
-
return t('hyrax.dashboard.my.action.members_no_access') if
|
|
50
|
-
|
|
51
|
-
return t('hyrax.dashboard.my.action.
|
|
53
|
+
return t('hyrax.dashboard.my.action.members_no_access') if
|
|
54
|
+
batch_ids.blank?
|
|
55
|
+
return t('hyrax.dashboard.my.action.collection_deny_add_members') unless
|
|
56
|
+
current_ability.can?(:deposit, @collection)
|
|
57
|
+
return t('hyrax.dashboard.my.action.add_to_collection_only') unless
|
|
58
|
+
member_action == "add" # should never happen
|
|
52
59
|
end
|
|
53
60
|
|
|
54
61
|
def success_return_path
|
|
@@ -63,10 +70,6 @@ module Hyrax
|
|
|
63
70
|
params[:id]
|
|
64
71
|
end
|
|
65
72
|
|
|
66
|
-
def collection
|
|
67
|
-
@collection ||= ::Collection.find(collection_id)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
73
|
def batch_ids
|
|
71
74
|
params[:batch_document_ids]
|
|
72
75
|
end
|
|
@@ -43,7 +43,12 @@ module Hyrax
|
|
|
43
43
|
# The search builder to find the collections' members
|
|
44
44
|
self.membership_service_class = Collections::CollectionMemberSearchService
|
|
45
45
|
|
|
46
|
-
load_and_authorize_resource except: [:index
|
|
46
|
+
load_and_authorize_resource except: [:index],
|
|
47
|
+
instance_name: :collection,
|
|
48
|
+
class: Hyrax.config.collection_model
|
|
49
|
+
|
|
50
|
+
skip_load_resource only: :create if
|
|
51
|
+
Hyrax.config.collection_class < ActiveFedora::Base
|
|
47
52
|
|
|
48
53
|
def deny_collection_access(exception)
|
|
49
54
|
if exception.action == :edit
|
|
@@ -63,14 +68,14 @@ module Hyrax
|
|
|
63
68
|
@collection.collection_type_gid = CollectionType.find(collection_type_id).to_global_id
|
|
64
69
|
add_breadcrumb t(:'hyrax.controls.home'), root_path
|
|
65
70
|
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
|
|
66
|
-
add_breadcrumb t('.header', type_title:
|
|
67
|
-
@collection.apply_depositor_metadata
|
|
71
|
+
add_breadcrumb t('.header', type_title: collection_type.title), request.path
|
|
72
|
+
@collection.try(:apply_depositor_metadata, current_user.user_key)
|
|
68
73
|
form
|
|
69
74
|
end
|
|
70
75
|
|
|
71
76
|
def show
|
|
72
77
|
# @todo: remove this unused assignment in 4.0.0
|
|
73
|
-
@banner_file = presenter.banner_file if
|
|
78
|
+
@banner_file = presenter.banner_file if collection_type.brandable?
|
|
74
79
|
|
|
75
80
|
presenter
|
|
76
81
|
query_collection_members
|
|
@@ -102,10 +107,11 @@ module Hyrax
|
|
|
102
107
|
end
|
|
103
108
|
|
|
104
109
|
def create
|
|
110
|
+
return valkyrie_create if @collection.is_a?(Valkyrie::Resource)
|
|
105
111
|
# Manual load and authorize necessary because Cancan will pass in all
|
|
106
112
|
# form attributes. When `permissions_attributes` are present the
|
|
107
113
|
# collection is saved without a value for `has_model.`
|
|
108
|
-
@collection =
|
|
114
|
+
@collection = Hyrax.config.collection_class.new
|
|
109
115
|
authorize! :create, @collection
|
|
110
116
|
# Coming from the UI, a collection type gid should always be present. Coming from the API, if a collection type gid is not specified,
|
|
111
117
|
# use the default collection type (provides backward compatibility with versions < Hyrax 2.1.0)
|
|
@@ -143,6 +149,9 @@ module Hyrax
|
|
|
143
149
|
end
|
|
144
150
|
|
|
145
151
|
process_member_changes
|
|
152
|
+
|
|
153
|
+
return valkyrie_update if @collection.is_a?(Valkyrie::Resource)
|
|
154
|
+
|
|
146
155
|
@collection.visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE unless @collection.discoverable?
|
|
147
156
|
# we don't have to reindex the full graph when updating collection
|
|
148
157
|
@collection.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
|
|
@@ -175,11 +184,20 @@ module Hyrax
|
|
|
175
184
|
end
|
|
176
185
|
|
|
177
186
|
def destroy
|
|
178
|
-
|
|
187
|
+
case @collection
|
|
188
|
+
when Valkyrie::Resource
|
|
189
|
+
Hyrax.persister.delete(resource: @collection)
|
|
179
190
|
after_destroy(params[:id])
|
|
180
191
|
else
|
|
181
|
-
|
|
192
|
+
if @collection.destroy
|
|
193
|
+
after_destroy(params[:id])
|
|
194
|
+
else
|
|
195
|
+
after_destroy_error(params[:id])
|
|
196
|
+
end
|
|
182
197
|
end
|
|
198
|
+
rescue StandardError => err
|
|
199
|
+
Rails.logger.error(err)
|
|
200
|
+
after_destroy_error(params[:id])
|
|
183
201
|
end
|
|
184
202
|
|
|
185
203
|
def collection
|
|
@@ -197,10 +215,36 @@ module Hyrax
|
|
|
197
215
|
|
|
198
216
|
private
|
|
199
217
|
|
|
218
|
+
def valkyrie_create
|
|
219
|
+
form.validate(collection_params) &&
|
|
220
|
+
@collection = transactions['change_set.create_collection']
|
|
221
|
+
.with_step_args(
|
|
222
|
+
'change_set.set_user_as_depositor' => { user: current_user },
|
|
223
|
+
'collection_resource.apply_collection_type_permissions' => { user: current_user }
|
|
224
|
+
)
|
|
225
|
+
.call(form)
|
|
226
|
+
.value_or { return after_create_error }
|
|
227
|
+
|
|
228
|
+
add_members_to_collection unless batch.empty?
|
|
229
|
+
@collection
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def valkyrie_update
|
|
233
|
+
form.validate(collection_params) &&
|
|
234
|
+
@collection = transactions['change_set.update_collection']
|
|
235
|
+
.call(form)
|
|
236
|
+
.value_or { return after_update_error }
|
|
237
|
+
after_update
|
|
238
|
+
end
|
|
239
|
+
|
|
200
240
|
def default_collection_type
|
|
201
241
|
Hyrax::CollectionType.find_or_create_default_collection_type
|
|
202
242
|
end
|
|
203
243
|
|
|
244
|
+
def collection_type
|
|
245
|
+
@collection_type ||= CollectionType.find_by_gid!(collection.collection_type_gid)
|
|
246
|
+
end
|
|
247
|
+
|
|
204
248
|
def link_parent_collection(parent_id)
|
|
205
249
|
child = collection.respond_to?(:valkyrie_resource) ? collection.valkyrie_resource : collection
|
|
206
250
|
Hyrax::Collections::CollectionMemberService.add_member(collection_id: parent_id,
|
|
@@ -341,8 +385,14 @@ module Hyrax
|
|
|
341
385
|
deprecation_deprecate :single_item_search_builder
|
|
342
386
|
|
|
343
387
|
def collection_params
|
|
344
|
-
|
|
345
|
-
|
|
388
|
+
if Hyrax.config.collection_class < ActiveFedora::Base
|
|
389
|
+
@participants = extract_old_style_permission_attributes(params[:collection])
|
|
390
|
+
form_class.model_attributes(params[:collection])
|
|
391
|
+
else
|
|
392
|
+
params.permit(collection: {})[:collection]
|
|
393
|
+
.merge(params.permit(:collection_type_gid))
|
|
394
|
+
.merge(member_of_collection_ids: Array(params[:parent_id]))
|
|
395
|
+
end
|
|
346
396
|
end
|
|
347
397
|
|
|
348
398
|
def extract_old_style_permission_attributes(attributes)
|
|
@@ -379,28 +429,36 @@ module Hyrax
|
|
|
379
429
|
end
|
|
380
430
|
end
|
|
381
431
|
|
|
382
|
-
def add_members_to_collection(collection = nil)
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
432
|
+
def add_members_to_collection(collection = nil, collection_id: nil)
|
|
433
|
+
collection_id ||= (collection.try(:id) || @collection.id)
|
|
434
|
+
|
|
435
|
+
Hyrax::Collections::CollectionMemberService
|
|
436
|
+
.add_members_by_ids(collection_id: collection_id,
|
|
437
|
+
new_member_ids: batch,
|
|
438
|
+
user: current_user)
|
|
387
439
|
end
|
|
388
440
|
|
|
389
441
|
def remove_members_from_collection
|
|
390
|
-
Hyrax::Collections::CollectionMemberService
|
|
391
|
-
|
|
392
|
-
|
|
442
|
+
Hyrax::Collections::CollectionMemberService
|
|
443
|
+
.remove_members_by_ids(collection_id: @collection.id,
|
|
444
|
+
member_ids: batch,
|
|
445
|
+
user: current_user)
|
|
393
446
|
end
|
|
394
447
|
|
|
395
448
|
def move_members_between_collections
|
|
396
|
-
destination_collection = ::Collection.find(params[:destination_collection_id])
|
|
397
449
|
remove_members_from_collection
|
|
398
|
-
add_members_to_collection(
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
450
|
+
add_members_to_collection(collection_id: params[:destination_collection_id])
|
|
451
|
+
|
|
452
|
+
destination_title =
|
|
453
|
+
Hyrax.query_service.find_by(id: params[:destination_collection_id]).title.first ||
|
|
454
|
+
params[:destination_collection_id]
|
|
455
|
+
flash[:notice] = "Successfully moved #{batch.count} files to #{destination_title} Collection."
|
|
456
|
+
rescue StandardError => err
|
|
457
|
+
Rails.logger.error(err)
|
|
458
|
+
destination_title =
|
|
459
|
+
Hyrax.query_service.find_by(id: params[:destination_collection_id]).title.first ||
|
|
460
|
+
destination_id
|
|
461
|
+
flash[:error] = "An error occured. Files were not moved to #{destination_title} Collection."
|
|
404
462
|
end
|
|
405
463
|
|
|
406
464
|
# Include 'catalog' and 'hyrax/base' in the search path for views, while prefering
|
|
@@ -420,7 +478,13 @@ module Hyrax
|
|
|
420
478
|
end
|
|
421
479
|
|
|
422
480
|
def form
|
|
423
|
-
@form ||=
|
|
481
|
+
@form ||=
|
|
482
|
+
case @collection
|
|
483
|
+
when Valkyrie::Resource
|
|
484
|
+
Hyrax::Forms::ResourceForm.for(@collection)
|
|
485
|
+
else
|
|
486
|
+
form_class.new(@collection, current_ability, repository)
|
|
487
|
+
end
|
|
424
488
|
end
|
|
425
489
|
|
|
426
490
|
def set_default_permissions
|
|
@@ -430,8 +494,8 @@ module Hyrax
|
|
|
430
494
|
|
|
431
495
|
def query_collection_members
|
|
432
496
|
member_works
|
|
433
|
-
member_subcollections if
|
|
434
|
-
parent_collections if
|
|
497
|
+
member_subcollections if collection_type.nestable?
|
|
498
|
+
parent_collections if collection_type.nestable? && action_name == 'show'
|
|
435
499
|
end
|
|
436
500
|
|
|
437
501
|
# Instantiate the membership query service
|
|
@@ -459,7 +523,7 @@ module Hyrax
|
|
|
459
523
|
end
|
|
460
524
|
|
|
461
525
|
def collection_object
|
|
462
|
-
|
|
526
|
+
@collection
|
|
463
527
|
end
|
|
464
528
|
|
|
465
529
|
# You can override this method if you need to provide additional
|