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
@@ -12,7 +12,11 @@ module Hyrax
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def total_viewable_items
|
15
|
-
|
15
|
+
field_pairs = { "isPartOf_ssim" => id.to_s }
|
16
|
+
SolrQueryService.new
|
17
|
+
.with_field_pairs(field_pairs: field_pairs)
|
18
|
+
.accessible_by(ability: current_ability)
|
19
|
+
.count
|
16
20
|
end
|
17
21
|
|
18
22
|
# AdminSet cannot be deleted if default set or non-empty
|
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
##
|
4
|
+
# @api public
|
5
|
+
# @since 3.1.0
|
6
|
+
#
|
7
|
+
# Presents select options for admin sets.
|
8
|
+
#
|
9
|
+
# Each entry in the {#select_options} return value provides a label for
|
10
|
+
# display, an id to serve as the value, and a data hash which is used as HTML5
|
11
|
+
# data entries. The data entries can be used as hooks for Javascript
|
12
|
+
# to control input validation taking into account the Admin Set and
|
13
|
+
# `PermissionTemplate` rules (`visibility_component.es6` does this, for
|
14
|
+
# example).
|
15
|
+
#
|
16
|
+
# @note this supersedes the older +Hyrax::AdminSetOptionsPresenter+, which
|
17
|
+
# actied more like a "service" sending database queries to Solr and
|
18
|
+
# ActiveRecord. this version seeks only to present the input data and
|
19
|
+
# relies on its caller to pass in the right data.
|
20
|
+
class AdminSetSelectionPresenter
|
21
|
+
##
|
22
|
+
# @param [Array<#id>]
|
23
|
+
def initialize(admin_sets:)
|
24
|
+
@admin_sets = admin_sets
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# @return [Array<Array<String, String, Hash>>] an array suitable for a form
|
29
|
+
# input `collection:` parameter. it should contain a label, an id, and a
|
30
|
+
# hash of HTML5 data attributes.
|
31
|
+
def select_options
|
32
|
+
@admin_sets.map do |admin_set|
|
33
|
+
case admin_set
|
34
|
+
when OptionsEntry
|
35
|
+
admin_set.result
|
36
|
+
else
|
37
|
+
OptionsEntry.new(admin_set: admin_set).result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# @api public
|
44
|
+
class OptionsEntry
|
45
|
+
##
|
46
|
+
# @!attribute [rw] admin_set
|
47
|
+
# @return [AdministrativeSet, SolrDocument]
|
48
|
+
# @!attribute [rw] permission_template
|
49
|
+
# @return [PermissionTemplate]
|
50
|
+
# @!attribute [rw] permit_sharing
|
51
|
+
# @return [Boolean]
|
52
|
+
attr_accessor :admin_set, :permission_template, :permit_sharing
|
53
|
+
|
54
|
+
##
|
55
|
+
# @param [AdministrativeSet, SolrDocument] admin_set
|
56
|
+
# @param [PermissionTemplate] permission_template
|
57
|
+
# @param [Boolean] permit_sharing
|
58
|
+
def initialize(admin_set:, permission_template: nil, permit_sharing: false)
|
59
|
+
@admin_set = admin_set
|
60
|
+
@permission_template = permission_template
|
61
|
+
@permit_sharing = permit_sharing
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# @return [Array<String, String, Hash>]
|
66
|
+
def result
|
67
|
+
[label, id, data]
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# @return [String]
|
72
|
+
def label
|
73
|
+
Array(admin_set.title).first || admin_set.to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# @return [String]
|
78
|
+
def id
|
79
|
+
admin_set.id.to_s
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# @return [Hash{String => Object}]
|
84
|
+
def data
|
85
|
+
{}.tap do |data|
|
86
|
+
data['data-sharing'] = permit_sharing
|
87
|
+
|
88
|
+
if permission_template
|
89
|
+
data.merge!(data_for(permission_template))
|
90
|
+
else
|
91
|
+
data['data-release-no-delay'] = true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
##
|
99
|
+
# @api private
|
100
|
+
def data_for(template)
|
101
|
+
{}.tap do |data|
|
102
|
+
if template.release_no_delay?
|
103
|
+
data['data-release-no-delay'] = true
|
104
|
+
elsif template.release_date.present?
|
105
|
+
data['data-release-date'] = template.release_date
|
106
|
+
end
|
107
|
+
|
108
|
+
data['data-release-before-date'] = true if
|
109
|
+
template.release_before_date?
|
110
|
+
data['data-visibility'] = template.visibility if
|
111
|
+
template.visibility.present?
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -28,6 +28,7 @@ module Hyrax
|
|
28
28
|
:to_s, to: :solr_document
|
29
29
|
|
30
30
|
delegate(*Hyrax::CollectionType.settings_attributes, to: :collection_type, prefix: :collection_type_is)
|
31
|
+
alias nestable? collection_type_is_nestable?
|
31
32
|
|
32
33
|
def collection_type
|
33
34
|
@collection_type ||= Hyrax::CollectionType.find_by_gid!(collection_type_gid)
|
@@ -77,19 +78,36 @@ module Hyrax
|
|
77
78
|
end
|
78
79
|
|
79
80
|
def total_items
|
80
|
-
|
81
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
82
|
+
SolrQueryService.new
|
83
|
+
.with_field_pairs(field_pairs: field_pairs)
|
84
|
+
.count
|
81
85
|
end
|
82
86
|
|
83
87
|
def total_viewable_items
|
84
|
-
|
88
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
89
|
+
SolrQueryService.new
|
90
|
+
.with_field_pairs(field_pairs: field_pairs)
|
91
|
+
.accessible_by(ability: current_ability)
|
92
|
+
.count
|
85
93
|
end
|
86
94
|
|
87
95
|
def total_viewable_works
|
88
|
-
|
96
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
97
|
+
SolrQueryService.new
|
98
|
+
.with_field_pairs(field_pairs: field_pairs)
|
99
|
+
.with_generic_type(generic_type: "Work")
|
100
|
+
.accessible_by(ability: current_ability)
|
101
|
+
.count
|
89
102
|
end
|
90
103
|
|
91
104
|
def total_viewable_collections
|
92
|
-
|
105
|
+
field_pairs = { "member_of_collection_ids_ssim" => id.to_s }
|
106
|
+
SolrQueryService.new
|
107
|
+
.with_field_pairs(field_pairs: field_pairs)
|
108
|
+
.with_generic_type(generic_type: "Collection")
|
109
|
+
.accessible_by(ability: current_ability)
|
110
|
+
.count
|
93
111
|
end
|
94
112
|
|
95
113
|
def collection_type_badge
|
@@ -119,25 +137,21 @@ module Hyrax
|
|
119
137
|
Hyrax::Engine.routes.url_helpers.dashboard_collection_path(id, locale: I18n.locale)
|
120
138
|
end
|
121
139
|
|
140
|
+
##
|
141
|
+
# @return [#to_s, nil] a download path for the banner file
|
122
142
|
def banner_file
|
123
|
-
|
124
|
-
|
125
|
-
"/" + ci[0].local_path.split("/")[-4..-1].join("/") unless ci.empty?
|
143
|
+
banner = CollectionBrandingInfo.find_by(collection_id: id, role: "banner")
|
144
|
+
"/" + banner.local_path.split("/")[-4..-1].join("/") if banner
|
126
145
|
end
|
127
146
|
|
128
147
|
def logo_record
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
file_location = "/" + coll_info.local_path.split("/")[-4..-1].join("/") unless logo_file.empty?
|
136
|
-
alttext = coll_info.alt_text
|
137
|
-
linkurl = coll_info.target_url
|
138
|
-
logo_info << { file: logo_file, file_location: file_location, alttext: alttext, linkurl: linkurl }
|
148
|
+
CollectionBrandingInfo.where(collection_id: id, role: "logo")
|
149
|
+
.select(:local_path, :alt_text, :target_url).map do |logo|
|
150
|
+
{ alttext: logo.alt_text,
|
151
|
+
file: File.split(logo.local_path).last,
|
152
|
+
file_location: "/#{logo.local_path.split('/')[-4..-1].join('/')}",
|
153
|
+
linkurl: logo.target_url }
|
139
154
|
end
|
140
|
-
logo_info
|
141
155
|
end
|
142
156
|
|
143
157
|
# A presenter for selecting a work type to create
|
@@ -158,14 +172,21 @@ module Hyrax
|
|
158
172
|
create_work_presenter.first_model
|
159
173
|
end
|
160
174
|
|
175
|
+
##
|
176
|
+
# @deprecated this implementation requires an extra db round trip, had a
|
177
|
+
# buggy cacheing mechanism, and was largely duplicative of other code.
|
178
|
+
# all versions of this code are replaced by
|
179
|
+
# {CollectionsHelper#available_parent_collections_data}.
|
161
180
|
def available_parent_collections(scope:)
|
181
|
+
Deprecation.warn("#{self.class}#available_parent_collections is " \
|
182
|
+
"deprecated. Use available_parent_collections_data " \
|
183
|
+
"helper instead.")
|
162
184
|
return @available_parents if @available_parents.present?
|
163
185
|
collection = ::Collection.find(id)
|
164
186
|
colls = Hyrax::Collections::NestedCollectionQueryService.available_parent_collections(child: collection, scope: scope, limit_to_id: nil)
|
165
187
|
@available_parents = colls.map do |col|
|
166
188
|
{ "id" => col.id, "title_first" => col.title.first }
|
167
|
-
end
|
168
|
-
@available_parents.to_json
|
189
|
+
end.to_json
|
169
190
|
end
|
170
191
|
|
171
192
|
def subcollection_count=(total)
|
@@ -57,8 +57,13 @@ module Hyrax
|
|
57
57
|
current_ability.can?(:read, id) ? first_title : 'File'
|
58
58
|
end
|
59
59
|
|
60
|
+
##
|
61
|
+
# @deprecated use `::Ability.can?(:edit, presenter)`. Hyrax views calling
|
62
|
+
# presenter {#editor} methods will continue to call them until Hyrax
|
63
|
+
# 4.0.0. The deprecation time horizon for the presenter methods themselves
|
64
|
+
# is 5.0.0.
|
60
65
|
def editor?
|
61
|
-
current_ability.can?(:edit,
|
66
|
+
current_ability.can?(:edit, self)
|
62
67
|
end
|
63
68
|
|
64
69
|
def tweeter
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# Called by the stats controller, it finds cached file pageview data,
|
3
|
-
# and prepares it for visualization in /app/views/stats/file.html.erb
|
4
2
|
module Hyrax
|
3
|
+
##
|
4
|
+
# Called by the stats controller, it finds cached file pageview data,
|
5
|
+
# and prepares it for visualization in /app/views/stats/file.html.erb
|
5
6
|
class FileUsage < StatsUsagePresenter
|
6
7
|
def initialize(id)
|
7
8
|
self.model = ::FileSet.find(id)
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
##
|
4
|
+
# constructs presenters for the pcdm:members of an Object, omitting those
|
5
|
+
# not readable by a provided +Ability+.
|
6
|
+
#
|
7
|
+
# this implementation builds the presenters without recourse to the request
|
8
|
+
# context and ActiveFedora-specific index structures (i.e. no `list_source`
|
9
|
+
# or `proxy_in_ssi`).
|
10
|
+
#
|
11
|
+
# @see MemberPresenterFactory
|
12
|
+
class PcdmMemberPresenterFactory
|
13
|
+
class_attribute :file_presenter_class, :work_presenter_class
|
14
|
+
self.file_presenter_class = FileSetPresenter
|
15
|
+
self.work_presenter_class = WorkShowPresenter
|
16
|
+
|
17
|
+
attr_reader :ability, :object
|
18
|
+
|
19
|
+
##
|
20
|
+
# @param [#member_ids] object
|
21
|
+
# @param [::Ability] ability
|
22
|
+
def initialize(object, ability)
|
23
|
+
@object = object
|
24
|
+
@ability = ability
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# @return [Array<FileSetPresenter, WorkShowPresenter>]
|
29
|
+
# @return [Enumerator<FileSetPresenter>]
|
30
|
+
def file_set_presenters
|
31
|
+
return enum_for(:file_set_presenters) unless block_given?
|
32
|
+
|
33
|
+
results = query_docs(generic_type: "FileSet")
|
34
|
+
|
35
|
+
object.member_ids.each do |id|
|
36
|
+
id = id.to_s
|
37
|
+
indx = results.index { |doc| id == doc['id'] }
|
38
|
+
next if indx.nil?
|
39
|
+
hash = results.delete_at(indx)
|
40
|
+
yield presenter_for(document: ::SolrDocument.new(hash), ability: ability)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# @note defaults to using `object.member_ids`. passing a specific set of
|
46
|
+
# ids is supported for compatibility with {MemberPresenterFactory}, but
|
47
|
+
# we recommend making sparing use of this feature.
|
48
|
+
#
|
49
|
+
# @overload member_presenters
|
50
|
+
# @return [Enumerator<FileSetPresenter, WorkShowPresenter>]
|
51
|
+
# @raise [ArgumentError] if an unindexed id is passed
|
52
|
+
# @overload member_presenters
|
53
|
+
# @param [Array<#to_s>] ids
|
54
|
+
# @return [Enumerator<FileSetPresenter, WorkShowPresenter>]
|
55
|
+
# @raise [ArgumentError] if an unindexed id is passed
|
56
|
+
def member_presenters(ids = object.member_ids)
|
57
|
+
return enum_for(:member_presenters, ids) unless block_given?
|
58
|
+
|
59
|
+
results = query_docs(ids: ids)
|
60
|
+
|
61
|
+
ids.each do |id|
|
62
|
+
id = id.to_s
|
63
|
+
indx = results.index { |doc| id == doc['id'] }
|
64
|
+
raise(ArgumentError, "Could not find an indexed document for id: #{id}") if
|
65
|
+
indx.nil?
|
66
|
+
hash = results.delete_at(indx)
|
67
|
+
yield presenter_for(document: ::SolrDocument.new(hash), ability: ability)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# @return [Array<#to_s>]
|
73
|
+
def ordered_ids
|
74
|
+
object.member_ids
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# @return [Array<WorkShowPresenter>]
|
79
|
+
def work_presenters
|
80
|
+
return enum_for(:work_presenters) unless block_given?
|
81
|
+
|
82
|
+
results = query_docs(generic_type: "Work")
|
83
|
+
|
84
|
+
object.member_ids.each do |id|
|
85
|
+
id = id.to_s
|
86
|
+
indx = results.index { |doc| id == doc['id'] }
|
87
|
+
next if indx.nil?
|
88
|
+
hash = results.delete_at(indx)
|
89
|
+
yield presenter_for(document: ::SolrDocument.new(hash), ability: ability)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# @param [::SolrDocument] document
|
95
|
+
# @param [::Ability] ability
|
96
|
+
#
|
97
|
+
# @return
|
98
|
+
def presenter_for(document:, ability:)
|
99
|
+
case document['has_model_ssim'].first
|
100
|
+
when Hyrax::FileSet.name
|
101
|
+
Hyrax::FileSetPresenter.new(document, ability)
|
102
|
+
else
|
103
|
+
Hyrax::WorkShowPresenter.new(document, ability)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
108
|
+
|
109
|
+
def query_docs(generic_type: nil, ids: object.member_ids)
|
110
|
+
query = "{!terms f=id}#{ids.join(',')}"
|
111
|
+
query += "{!term f=generic_type_si}#{generic_type}" if generic_type
|
112
|
+
|
113
|
+
Hyrax::SolrService
|
114
|
+
.post(query, rows: 10_000)
|
115
|
+
.fetch('response')
|
116
|
+
.fetch('docs')
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -1,27 +1,56 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module Hyrax
|
4
|
+
##
|
5
|
+
# @api public
|
6
|
+
#
|
7
|
+
# Presents works in context as "trophied" for a given user.
|
8
|
+
#
|
9
|
+
# @example
|
10
|
+
# my_user = User.find(user_id)
|
11
|
+
#
|
12
|
+
# trophies = Hyrax::TrophyPresenter.find_by_user(my_user)
|
13
|
+
# trophies.each do |trophy|
|
14
|
+
# puts "Object name/title: #{trophy}"
|
15
|
+
# puts "Thumbnail path: #{trophy.thumbnail_path}"
|
16
|
+
# end
|
3
17
|
class TrophyPresenter
|
4
18
|
include ModelProxy
|
19
|
+
|
20
|
+
##
|
21
|
+
# @param solr_document [::SolrDocument]
|
5
22
|
def initialize(solr_document)
|
6
23
|
@solr_document = solr_document
|
7
24
|
end
|
8
25
|
|
26
|
+
##
|
27
|
+
# @!attribute [r] SolrDocument
|
28
|
+
# @return [::SolrDocument]
|
9
29
|
attr_reader :solr_document
|
10
30
|
|
11
31
|
delegate :to_s, :thumbnail_path, to: :solr_document
|
12
32
|
|
33
|
+
##
|
13
34
|
# @param user [User] the user to find the TrophyPresentes for.
|
35
|
+
#
|
14
36
|
# @return [Array<TrophyPresenter>] a list of all the trophy presenters for the user
|
15
37
|
def self.find_by_user(user)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
38
|
+
ids = user.trophies.pluck(:work_id)
|
39
|
+
return ids if ids.empty?
|
40
|
+
|
41
|
+
documents = Hyrax::SolrQueryService.new.with_ids(ids: ids).solr_documents
|
42
|
+
|
43
|
+
documents.map { |doc| new(doc) }
|
20
44
|
rescue RSolr::Error::ConnectionRefused
|
21
45
|
[]
|
22
46
|
end
|
23
47
|
|
48
|
+
##
|
49
|
+
# @api private
|
50
|
+
# @deprecated use CatalogController.blacklight_config.document_model instead
|
24
51
|
def self.document_model
|
52
|
+
Deprecation
|
53
|
+
.warn("Use CatalogController.blacklight_config.document_model instead.")
|
25
54
|
CatalogController.blacklight_config.document_model
|
26
55
|
end
|
27
56
|
private_class_method :document_model
|