hyrax 3.0.1 → 3.3.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 +49 -19
- data/.dassie/.env +1 -2
- data/.dassie/Gemfile +18 -9
- data/.dassie/app/controllers/catalog_controller.rb +6 -0
- data/.dassie/app/models/user.rb +0 -2
- data/.dassie/config/analytics.yml +12 -5
- data/.dassie/config/environments/development.rb +2 -0
- data/.dassie/config/initializers/hyrax.rb +7 -0
- data/.dassie/config/role_map.yml +2 -0
- data/.dassie/db/migrate/20210921150120_enable_uuid_extension.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150121_create_orm_resources.valkyrie_engine.rb +19 -0
- data/.dassie/db/migrate/20210921150122_add_model_type_to_orm_resources.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150123_change_model_type_to_internal_model.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150124_create_path_gin_index.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150125_create_internal_resource_index.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150126_create_updated_at_index.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20210921150127_add_optimistic_locking_to_orm_resources.valkyrie_engine.rb +7 -0
- data/.dassie/db/migrate/20211130181150_create_default_administrative_set.rb +8 -0
- data/.dassie/db/schema.rb +20 -1
- data/.dassie/db/seeds.rb +1 -1
- data/.dockerignore +3 -0
- data/.env +8 -6
- data/.github/workflows/main.yml +17 -0
- data/.github/workflows/release.yml +17 -0
- data/.gitignore +1 -0
- data/.regen +1 -1
- data/.rubocop.yml +4 -0
- data/CONTAINERS.md +33 -10
- data/Dockerfile +14 -9
- data/Gemfile +21 -27
- data/README.md +37 -0
- data/app/actors/hyrax/actors/base_actor.rb +2 -2
- data/app/actors/hyrax/actors/collections_membership_actor.rb +3 -3
- data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +85 -63
- data/app/actors/hyrax/actors/create_with_remote_files_ordered_members_actor.rb +7 -42
- data/app/actors/hyrax/actors/file_set_actor.rb +12 -5
- data/app/assets/javascripts/hyrax/admin/graphs.es6 +34 -37
- data/app/assets/javascripts/hyrax/analytics_events.js +69 -0
- data/app/assets/javascripts/hyrax/collapse.js +24 -0
- data/app/assets/javascripts/hyrax/collections.js +1 -2
- data/app/assets/javascripts/hyrax/ga_events.js +2 -8
- data/app/assets/javascripts/hyrax/reports-buttons.js +33 -0
- data/app/assets/javascripts/hyrax.js +2 -1
- data/app/assets/stylesheets/_bootstrap-default-overrides.scss +9 -0
- data/app/assets/stylesheets/hyrax/_styles.scss +5 -0
- data/app/authorities/qa/authorities/collections.rb +4 -5
- data/app/authorities/qa/authorities/find_works.rb +1 -1
- data/app/controllers/concerns/hyrax/breadcrumbs_for_collection_analytics.rb +26 -0
- data/app/controllers/concerns/hyrax/breadcrumbs_for_works_analytics.rb +26 -0
- data/app/controllers/concerns/hyrax/collections_controller_behavior.rb +30 -10
- data/app/controllers/concerns/hyrax/controller.rb +35 -2
- data/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb +21 -9
- data/app/controllers/concerns/hyrax/leases_controller_behavior.rb +14 -5
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +22 -3
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +2 -19
- data/app/controllers/hyrax/admin/analytics/analytics_controller.rb +40 -0
- data/app/controllers/hyrax/admin/analytics/collection_reports_controller.rb +61 -0
- data/app/controllers/hyrax/admin/analytics/work_reports_controller.rb +122 -0
- data/app/controllers/hyrax/admin/permission_template_accesses_controller.rb +5 -6
- data/app/controllers/hyrax/admin/workflows_controller.rb +8 -2
- data/app/controllers/hyrax/collections_controller.rb +6 -1
- data/app/controllers/hyrax/dashboard/collection_members_controller.rb +24 -17
- data/app/controllers/hyrax/dashboard/collections_controller.rb +112 -37
- data/app/controllers/hyrax/dashboard/nest_collections_controller.rb +75 -39
- data/app/controllers/hyrax/dashboard_controller.rb +8 -0
- data/app/controllers/hyrax/file_sets_controller.rb +49 -13
- data/app/controllers/hyrax/my_controller.rb +4 -4
- data/app/controllers/hyrax/permissions_controller.rb +3 -4
- data/app/controllers/hyrax/stats_controller.rb +3 -1
- data/app/controllers/hyrax/workflow_actions_controller.rb +11 -6
- data/app/forms/hyrax/forms/administrative_set_form.rb +62 -0
- data/app/forms/hyrax/forms/collection_form.rb +9 -5
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +38 -6
- data/app/forms/hyrax/forms/file_set_form.rb +46 -0
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +67 -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 +34 -26
- data/app/forms/hyrax/forms/work_form.rb +5 -2
- data/app/forms/hyrax/forms/workflow_action_form.rb +4 -0
- 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 +9 -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/pcdm_collection_indexer.rb +2 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +3 -1
- data/app/indexers/hyrax/valkyrie_indexer.rb +3 -3
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +1 -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/characterize_job.rb +28 -1
- data/app/jobs/ingest_local_file_job.rb +18 -2
- data/app/jobs/inherit_permissions_job.rb +9 -5
- data/app/jobs/valkyrie_ingest_job.rb +56 -0
- data/app/models/admin_set.rb +22 -30
- data/app/models/collection_branding_info.rb +25 -9
- 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 +31 -8
- 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/metadata.rb +1 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +11 -54
- 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/file_download_stat.rb +4 -4
- data/app/models/hyrax/administrative_set.rb +7 -1
- data/app/models/hyrax/default_administrative_set.rb +42 -0
- data/app/models/hyrax/file_set.rb +6 -0
- data/app/models/hyrax/pcdm_collection.rb +1 -0
- data/app/models/hyrax/permission.rb +1 -1
- data/app/models/hyrax/permission_template.rb +112 -12
- data/app/models/hyrax/statistic.rb +31 -4
- data/app/models/hyrax/virus_scanner.rb +27 -18
- data/app/models/hyrax/work.rb +1 -0
- data/app/models/hyrax/workflow_action_info.rb +16 -0
- data/app/models/sipity/agent.rb +1 -0
- data/app/models/sipity/comment.rb +17 -0
- data/app/models/sipity/entity.rb +30 -8
- data/app/models/sipity/workflow.rb +1 -0
- data/app/models/sipity.rb +53 -2
- data/app/presenters/hyrax/admin/dashboard_presenter.rb +8 -6
- data/app/presenters/hyrax/admin/repository_growth_presenter.rb +10 -5
- data/app/presenters/hyrax/admin/user_activity_presenter.rb +8 -12
- data/app/presenters/hyrax/admin_set_options_presenter.rb +12 -8
- data/app/presenters/hyrax/admin_set_presenter.rb +13 -4
- data/app/presenters/hyrax/admin_set_selection_presenter.rb +116 -0
- data/app/presenters/hyrax/collection_presenter.rb +34 -9
- data/app/presenters/hyrax/file_set_presenter.rb +8 -1
- data/app/presenters/hyrax/file_usage.rb +3 -2
- data/app/presenters/hyrax/menu_presenter.rb +4 -0
- 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 +37 -8
- data/app/presenters/hyrax/work_usage.rb +6 -3
- data/app/renderers/hyrax/renderers/attribute_renderer.rb +10 -2
- data/app/search_builders/hyrax/README.md +1 -1
- data/app/search_builders/hyrax/abstract_type_relation.rb +4 -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/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 +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/admin_set_create_service.rb +199 -53
- data/app/services/hyrax/analytics/google/events.rb +37 -0
- data/app/services/hyrax/analytics/google/events_daily.rb +72 -0
- data/app/services/hyrax/analytics/google/visits.rb +44 -0
- data/app/services/hyrax/analytics/google/visits_daily.rb +49 -0
- data/app/services/hyrax/analytics/google.rb +204 -0
- data/app/services/hyrax/analytics/matomo.rb +193 -0
- data/app/services/hyrax/analytics/results.rb +79 -0
- data/app/services/hyrax/analytics.rb +12 -82
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +134 -0
- data/app/services/hyrax/collection_types/permissions_service.rb +1 -1
- data/app/services/hyrax/collections/collection_member_search_service.rb +72 -0
- data/app/services/hyrax/collections/collection_member_service.rb +122 -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 +10 -3
- data/app/services/hyrax/collections/permissions_create_service.rb +82 -78
- data/app/services/hyrax/collections/permissions_service.rb +1 -1
- data/app/services/hyrax/contextual_path.rb +24 -1
- data/app/services/hyrax/curation_concern.rb +24 -2
- 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/default_middleware_stack.rb +11 -0
- data/app/services/hyrax/edit_permissions_service.rb +74 -41
- data/app/services/hyrax/ensure_well_formed_admin_set_service.rb +3 -3
- data/app/services/hyrax/find_objects_via_solr_service.rb +31 -0
- data/app/services/hyrax/listeners/acl_index_listener.rb +3 -1
- data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +4 -1
- data/app/services/hyrax/listeners/batch_notification_listener.rb +3 -1
- data/app/services/hyrax/listeners/file_metadata_listener.rb +19 -0
- data/app/services/hyrax/listeners/file_set_lifecycle_listener.rb +6 -2
- data/app/services/hyrax/listeners/file_set_lifecycle_notification_listener.rb +6 -2
- data/app/services/hyrax/listeners/member_cleanup_listener.rb +3 -0
- data/app/services/hyrax/listeners/metadata_index_listener.rb +33 -11
- data/app/services/hyrax/listeners/object_lifecycle_listener.rb +9 -3
- data/app/services/hyrax/listeners/proxy_deposit_listener.rb +3 -1
- data/app/services/hyrax/listeners/trophy_cleanup_listener.rb +3 -0
- data/app/services/hyrax/listeners/workflow_listener.rb +3 -1
- data/app/services/hyrax/listeners.rb +8 -0
- data/app/services/hyrax/multiple_membership_checker.rb +53 -29
- data/app/services/hyrax/permission_manager.rb +4 -4
- data/app/services/hyrax/resource_status.rb +7 -0
- data/app/services/hyrax/restriction_service.rb +4 -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 +9 -2
- data/app/services/hyrax/statistics/collections/over_time.rb +2 -1
- data/app/services/hyrax/statistics/depositors/summary.rb +2 -1
- data/app/services/hyrax/statistics/users/over_time.rb +8 -5
- data/app/services/hyrax/statistics/works/over_time.rb +10 -0
- data/app/services/hyrax/visibility_intention.rb +20 -2
- data/app/services/hyrax/work_uploads_handler.rb +21 -3
- 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/actionable_objects.rb +70 -0
- 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/object_in_workflow_decorator.rb +31 -0
- data/app/services/hyrax/workflow/revoke_edit_from_depositor.rb +8 -2
- data/app/services/hyrax/workflow/status_list_service.rb +43 -13
- 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/admin/analytics/_date_range_form.html.erb +11 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_custom_range.html.erb +39 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_monthly_summary.html.erb +48 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_summary.html.erb +55 -0
- data/app/views/hyrax/admin/analytics/collection_reports/_top_collections.html.erb +55 -0
- data/app/views/hyrax/admin/analytics/collection_reports/index.html.erb +70 -0
- data/app/views/hyrax/admin/analytics/collection_reports/show.html.erb +94 -0
- data/app/views/hyrax/admin/analytics/work_reports/_custom_range.html.erb +43 -0
- data/app/views/hyrax/admin/analytics/work_reports/_monthly_summary.html.erb +35 -0
- data/app/views/hyrax/admin/analytics/work_reports/_summary.html.erb +60 -0
- data/app/views/hyrax/admin/analytics/work_reports/_top_file_set_downloads.html.erb +33 -0
- data/app/views/hyrax/admin/analytics/work_reports/_top_works.html.erb +40 -0
- data/app/views/hyrax/admin/analytics/work_reports/_work_counts.html.erb +18 -0
- data/app/views/hyrax/admin/analytics/work_reports/_work_files.html.erb +41 -0
- data/app/views/hyrax/admin/analytics/work_reports/index.html.erb +77 -0
- data/app/views/hyrax/admin/analytics/work_reports/show.html.erb +90 -0
- data/app/views/hyrax/admin/stats/show.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_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/_relationships_parent_row.html.erb +0 -1
- 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/show.html.erb +6 -0
- data/app/views/hyrax/batch_uploads/_form.html.erb +1 -1
- data/app/views/hyrax/collections/show.html.erb +4 -0
- data/app/views/hyrax/dashboard/_repository_growth.html.erb +5 -5
- data/app/views/hyrax/dashboard/_resource_type_graph.html.erb +41 -0
- data/app/views/hyrax/dashboard/_sidebar.html.erb +4 -1
- data/app/views/hyrax/dashboard/_tabs.html.erb +11 -0
- data/app/views/hyrax/dashboard/_user_activity.html.erb +17 -23
- data/app/views/hyrax/dashboard/_user_activity_graph.html.erb +55 -0
- data/app/views/hyrax/dashboard/_visibility_graph.html.erb +31 -0
- data/app/views/hyrax/dashboard/_work_type_graph.html.erb +41 -0
- data/app/views/hyrax/dashboard/collections/_collection_title.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form.html.erb +6 -5
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_sort_and_per_page.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/dashboard/show_admin.html.erb +24 -45
- data/app/views/hyrax/dashboard/sidebar/_activity.html.erb +22 -0
- data/app/views/hyrax/file_sets/_actions.html.erb +4 -3
- 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 +7 -1
- data/app/views/hyrax/homepage/index.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/my/collections/_modal_collection_types_to_create.html.erb +1 -1
- data/app/views/hyrax/my/collections/index.html.erb +1 -1
- data/app/views/hyrax/stats/_downloads.html.erb +18 -0
- data/app/views/hyrax/stats/_pageviews.html.erb +18 -0
- data/app/views/hyrax/stats/work.html.erb +17 -9
- data/app/views/layouts/_head_tag_content.html.erb +7 -2
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -0
- data/app/views/layouts/hyrax.html.erb +1 -0
- data/app/views/{_ga.html.erb → shared/_ga.html.erb} +3 -7
- data/app/views/shared/_matomo.html.erb +15 -0
- data/app/views/shared/_read_only.html.erb +5 -0
- data/bin/db-migrate-seed.sh +3 -1
- data/bin/hyrax-entrypoint.sh +0 -14
- data/bin/solrcloud-assign-configset.sh +11 -3
- data/bin/solrcloud-upload-configset.sh +17 -6
- data/chart/hyrax/Chart.yaml +9 -5
- data/chart/hyrax/README.md +52 -5
- data/chart/hyrax/templates/_helpers.tpl +15 -1
- data/chart/hyrax/templates/branding-pvc.yaml +2 -2
- data/chart/hyrax/templates/configmap-env.yaml +6 -2
- data/chart/hyrax/templates/deployment-worker.yaml +42 -5
- data/chart/hyrax/templates/deployment.yaml +53 -0
- data/chart/hyrax/templates/derivatives-pvc.yaml +2 -2
- data/chart/hyrax/templates/ingress.yaml +13 -4
- data/chart/hyrax/templates/secrets.yaml +8 -0
- data/chart/hyrax/templates/uploads-pvc.yaml +2 -2
- data/chart/hyrax/values.yaml +84 -2
- data/config/brakeman.ignore +2 -2
- data/config/features.rb +3 -0
- data/config/i18n-tasks.yml +2 -2
- data/config/initializers/1_healthz.rb +1 -0
- data/config/initializers/listeners.rb +5 -4
- data/config/initializers/valkryrie_storage.rb +7 -0
- data/config/locales/hyrax.de.yml +195 -1
- data/config/locales/hyrax.en.yml +192 -13
- data/config/locales/hyrax.es.yml +195 -1
- data/config/locales/hyrax.fr.yml +195 -1
- data/config/locales/hyrax.it.yml +195 -1
- data/config/locales/hyrax.pt-BR.yml +195 -1
- data/config/locales/hyrax.zh.yml +195 -1
- data/config/routes.rb +4 -0
- data/db/seeds.rb +1 -1
- data/docker-compose.yml +42 -9
- data/documentation/developing-your-hyrax-based-app.md +4 -4
- data/documentation/legacyREADME.md +4 -4
- data/hyrax.gemspec +4 -2
- data/lib/generators/hyrax/templates/catalog_controller.rb +3 -1
- data/lib/generators/hyrax/templates/config/analytics.yml +13 -7
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +15 -13
- data/lib/generators/hyrax/templates/db/migrate/20211130181150_create_default_administrative_set.rb.erb +8 -0
- data/lib/generators/hyrax/work/templates/feature_spec.rb.erb +4 -2
- data/lib/generators/hyrax/work_resource/templates/indexer_spec.rb.erb +1 -0
- data/lib/hyrax/active_fedora_dummy_model.rb +62 -0
- data/lib/hyrax/collection_name.rb +6 -2
- data/lib/hyrax/configuration.rb +114 -4
- data/lib/hyrax/engine.rb +9 -6
- data/lib/hyrax/errors.rb +2 -0
- data/lib/hyrax/form_fields.rb +1 -0
- data/lib/hyrax/publisher.rb +16 -0
- data/lib/hyrax/resource_name.rb +1 -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/capybara.rb +5 -3
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +2 -0
- data/lib/hyrax/specs/shared_specs/indexers.rb +6 -0
- data/lib/hyrax/specs/shared_specs/valkyrie_storage_versions.rb +9 -0
- data/lib/hyrax/transactions/admin_set_create.rb +22 -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 +58 -0
- data/lib/hyrax/transactions/file_set_destroy.rb +21 -0
- data/lib/hyrax/transactions/steps/add_file_sets.rb +3 -2
- data/lib/hyrax/transactions/steps/add_to_collections.rb +13 -1
- data/lib/hyrax/transactions/steps/add_to_parent.rb +36 -0
- data/lib/hyrax/transactions/steps/apply_collection_type_permissions.rb +29 -0
- data/lib/hyrax/transactions/steps/remove_file_set_from_work.rb +47 -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/transactions/work_create.rb +2 -1
- data/lib/hyrax/valkyrie_can_can_adapter.rb +1 -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/default_admin_set.rake +12 -11
- data/lib/tasks/regenerate_derivatives.rake +12 -0
- data/lib/wings/active_fedora_converter/default_work.rb +15 -0
- data/lib/wings/model_transformer.rb +17 -1
- data/lib/wings/orm_converter.rb +18 -2
- data/lib/wings/setup.rb +17 -0
- data/lib/wings/valkyrie/persister.rb +16 -0
- data/lib/wings/valkyrie/storage.rb +56 -1
- data/lib/wings.rb +0 -21
- data/template.rb +1 -1
- data/vendor/assets/javascripts/morris/morris.min.js +1 -7
- data/vendor/assets/stylesheets/morris.js/0.5.1/morris.css +1 -1
- metadata +120 -17
- data/app/views/hyrax/dashboard/_repository_objects.html.erb +0 -28
@@ -51,27 +51,22 @@ module Hyrax
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# Add members using the members association.
|
54
|
-
# TODO: Confirm if this is ever used. I believe all relationships are done through
|
55
|
-
# add_member_objects using the member_of_collections relationship. Deprecate?
|
56
54
|
def add_members(new_member_ids)
|
57
|
-
|
58
|
-
|
55
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
56
|
+
"Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
|
57
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
|
58
|
+
new_member_ids: new_member_ids,
|
59
|
+
user: nil)
|
59
60
|
end
|
60
61
|
|
61
62
|
# Add member objects by adding this collection to the objects' member_of_collection association.
|
62
63
|
# @param [Enumerable<String>] the ids of the new child collections and works collection ids
|
63
64
|
def add_member_objects(new_member_ids)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
else
|
70
|
-
member.member_of_collections << self
|
71
|
-
member.save!
|
72
|
-
end
|
73
|
-
member
|
74
|
-
end
|
65
|
+
Deprecation.warn("'##{__method__}' will be removed in Hyrax 4.0. " \
|
66
|
+
"Instead, use Hyrax::Collections::CollectionMemberService.add_members_by_ids.")
|
67
|
+
Hyrax::Collections::CollectionMemberService.add_members_by_ids(collection_id: id,
|
68
|
+
new_member_ids: new_member_ids,
|
69
|
+
user: nil)
|
75
70
|
end
|
76
71
|
|
77
72
|
# @return [Enumerable<ActiveFedora::Base>] an enumerable over the children of this collection
|
@@ -125,41 +120,19 @@ module Hyrax
|
|
125
120
|
Hyrax::PermissionTemplate.find_by!(source_id: id)
|
126
121
|
end
|
127
122
|
|
123
|
+
##
|
124
|
+
# @deprecated use PermissionTemplate#reset_access_controls instead
|
125
|
+
#
|
128
126
|
# Calculate and update who should have read/edit access to the collections based on who
|
129
127
|
# has access in PermissionTemplateAccess
|
130
128
|
def reset_access_controls!
|
131
|
-
|
132
|
-
edit_groups: permission_template_edit_groups,
|
133
|
-
read_users: permission_template_read_users,
|
134
|
-
read_groups: (permission_template_read_groups + visibility_group).uniq)
|
135
|
-
end
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def permission_template_edit_users
|
140
|
-
permission_template.agent_ids_for(access: 'manage', agent_type: 'user')
|
141
|
-
end
|
129
|
+
Deprecation.warn("reset_access_controls! is deprecated; use PermissionTemplate#reset_access_controls instead.")
|
142
130
|
|
143
|
-
|
144
|
-
|
131
|
+
permission_template
|
132
|
+
.reset_access_controls_for(collection: self, interpret_visibility: true)
|
145
133
|
end
|
146
134
|
|
147
|
-
|
148
|
-
(permission_template.agent_ids_for(access: 'view', agent_type: 'user') +
|
149
|
-
permission_template.agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
|
150
|
-
end
|
151
|
-
|
152
|
-
def permission_template_read_groups
|
153
|
-
(permission_template.agent_ids_for(access: 'view', agent_type: 'group') +
|
154
|
-
permission_template.agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
|
155
|
-
[::Ability.registered_group_name, ::Ability.public_group_name]
|
156
|
-
end
|
157
|
-
|
158
|
-
def visibility_group
|
159
|
-
return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_PUBLIC] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
|
160
|
-
return [Hydra::AccessControls::AccessRight::PERMISSION_TEXT_VALUE_AUTHENTICATED] if visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
|
161
|
-
[]
|
162
|
-
end
|
135
|
+
private
|
163
136
|
|
164
137
|
# Solr field name works use to index member ids
|
165
138
|
def member_ids_field
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Embargoable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Hydra::AccessControls::Embargoable
|
6
|
+
|
7
|
+
included do
|
8
|
+
validates :lease_expiration_date, 'hydra/future_date': true, on: :create
|
9
|
+
validates :embargo_release_date, 'hydra/future_date': true, on: :create
|
10
|
+
end
|
11
|
+
|
12
|
+
##
|
13
|
+
# Override aggressive Hydra::AccessControls validation
|
14
|
+
def enforce_future_date_for_embargo?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
##
|
19
|
+
# Override aggressive Hydra::AccessControls validation
|
20
|
+
def enforce_future_date_for_lease?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,18 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# By default, the file holding the metadata is :original_file and the terms
|
4
|
-
# are listed under ::characterization_terms.
|
5
|
-
# Implementations may define their own terms or use a different source file, but
|
6
|
-
# any terms must be set on the ::characterization_proxy by the Hydra::Works::CharacterizationService
|
7
|
-
#
|
8
|
-
# class MyFileSet
|
9
|
-
# include Hyrax::FileSetBehavior
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# MyFileSet.characterization_proxy = :master_file
|
13
|
-
# MyFileSet.characterization_terms = [:term1, :term2, :term3]
|
2
|
+
|
14
3
|
module Hyrax
|
15
4
|
class FileSet
|
5
|
+
##
|
6
|
+
# This module points the FileSet to the location of the technical metadata.
|
7
|
+
# By default, the file holding the metadata is +:original_file+ and the terms
|
8
|
+
# are listed under +.characterization_terms+.
|
9
|
+
#
|
10
|
+
# Implementations may define their own terms or use a different source file, but
|
11
|
+
# any terms must be set on the +.characterization_proxy+ by the
|
12
|
+
# +Hydra::Works::CharacterizationService+.
|
13
|
+
#
|
14
|
+
# @example
|
15
|
+
# class MyFileSet
|
16
|
+
# include Hyrax::FileSetBehavior
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# MyFileSet.characterization_proxy = :master_file
|
20
|
+
# MyFileSet.characterization_terms = [:term1, :term2, :term3]
|
21
|
+
#
|
16
22
|
module Characterization
|
17
23
|
extend ActiveSupport::Concern
|
18
24
|
|
@@ -54,6 +54,7 @@ module Hyrax
|
|
54
54
|
attribute :admin_set, Solr::Array, "admin_set_tesim"
|
55
55
|
attribute :member_ids, Solr::Array, "member_ids_ssim"
|
56
56
|
attribute :member_of_collection_ids, Solr::Array, "member_of_collection_ids_ssim"
|
57
|
+
attribute :member_of_collections, Solr::Array, "member_of_collections_ssim"
|
57
58
|
attribute :description, Solr::Array, "description_tesim"
|
58
59
|
attribute :abstract, Solr::Array, "abstract_tesim"
|
59
60
|
attribute :title, Solr::Array, "title_tesim"
|
@@ -13,6 +13,8 @@ module Hyrax
|
|
13
13
|
#
|
14
14
|
# @see https://github.com/projectblacklight/blacklight/wiki/Understanding-Rails-and-Blacklight#models
|
15
15
|
module SolrDocumentBehavior
|
16
|
+
ModelWrapper = ActiveFedoraDummyModel # alias for backward compatibility
|
17
|
+
|
16
18
|
extend ActiveSupport::Concern
|
17
19
|
include Hydra::Works::MimeTypes
|
18
20
|
include Hyrax::Permissions::Readable
|
@@ -39,70 +41,19 @@ module Hyrax
|
|
39
41
|
title_or_label.to_s
|
40
42
|
end
|
41
43
|
|
42
|
-
##
|
43
|
-
# Given a model class and an +id+, provides +ActiveModel+ style model methods.
|
44
|
-
#
|
45
|
-
# @note access this via {SolrDocumentBehavior#to_model}.
|
46
|
-
class ModelWrapper
|
47
|
-
##
|
48
|
-
# @api private
|
49
|
-
#
|
50
|
-
# @param [Class] model
|
51
|
-
# @param [String, nil] id
|
52
|
-
def initialize(model, id)
|
53
|
-
@model = model
|
54
|
-
@id = id
|
55
|
-
end
|
56
|
-
|
57
|
-
##
|
58
|
-
# @api public
|
59
|
-
def persisted?
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
##
|
64
|
-
# @api public
|
65
|
-
def to_param
|
66
|
-
@id
|
67
|
-
end
|
68
|
-
|
69
|
-
##
|
70
|
-
# @api public
|
71
|
-
def model_name
|
72
|
-
@model.model_name
|
73
|
-
end
|
74
|
-
|
75
|
-
##
|
76
|
-
# @api public
|
77
|
-
#
|
78
|
-
# @note uses the @model's `._to_partial_path` if implemented, otherwise
|
79
|
-
# constructs a default
|
80
|
-
def to_partial_path
|
81
|
-
return @model._to_partial_path if
|
82
|
-
@model.respond_to?(:_to_partial_path)
|
83
|
-
|
84
|
-
"hyrax/#{model_name.collection}/#{model_name.element}"
|
85
|
-
end
|
86
|
-
|
87
|
-
##
|
88
|
-
# @api public
|
89
|
-
def to_global_id
|
90
|
-
URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id
|
91
|
-
end
|
92
|
-
end
|
93
44
|
##
|
94
45
|
# Offer the source model to Rails for some of the Rails methods (e.g. link_to).
|
95
46
|
#
|
96
47
|
# @example
|
97
48
|
# link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>
|
98
49
|
def to_model
|
99
|
-
@model ||=
|
50
|
+
@model ||= ActiveFedoraDummyModel.new(hydra_model, id)
|
100
51
|
end
|
101
52
|
|
102
53
|
##
|
103
54
|
# @return [Boolean]
|
104
55
|
def collection?
|
105
|
-
hydra_model ==
|
56
|
+
hydra_model == Hyrax.config.collection_class
|
106
57
|
end
|
107
58
|
|
108
59
|
##
|
@@ -117,9 +68,15 @@ module Hyrax
|
|
117
68
|
hydra_model == ::AdminSet
|
118
69
|
end
|
119
70
|
|
71
|
+
##
|
72
|
+
# @return [Boolean]
|
73
|
+
def work?
|
74
|
+
Hyrax.config.curation_concerns.include? hydra_model
|
75
|
+
end
|
76
|
+
|
120
77
|
# Method to return the model
|
121
78
|
def hydra_model(classifier: ActiveFedora.model_mapper)
|
122
|
-
|
79
|
+
first('has_model_ssim')&.safe_constantize ||
|
123
80
|
classifier.classifier(self).best_model
|
124
81
|
end
|
125
82
|
|
@@ -10,6 +10,11 @@ module Hyrax
|
|
10
10
|
end
|
11
11
|
|
12
12
|
##
|
13
|
+
# @deprecated use `Hyrax::ResourceStatus` instead. in most cases,
|
14
|
+
# {#suppressed?} is being called on a {SolrDocumentBehavior}. we continue
|
15
|
+
# to index `suppressed_bsi` and expose its value as an attribute on solr
|
16
|
+
# document objects.
|
17
|
+
#
|
13
18
|
# Used to restrict visibility on search results for a work that is inactive. If the state is not set, the
|
14
19
|
# default behavior is to consider the work not to be suppressed.
|
15
20
|
#
|
@@ -31,7 +31,7 @@ module Hyrax::User
|
|
31
31
|
|
32
32
|
scope :guests, ->() { where(guest: true) }
|
33
33
|
scope :registered, ->() { where(guest: false) }
|
34
|
-
scope :without_system_accounts, -> { where("#{::User.user_key_field} not in (?)", [::User.batch_user_key, ::User.audit_user_key]) }
|
34
|
+
scope :without_system_accounts, -> { where("#{::User.user_key_field} not in (?)", [::User.batch_user_key, ::User.audit_user_key, ::User.system_user_key]) }
|
35
35
|
|
36
36
|
# Validate and normalize ORCIDs
|
37
37
|
validates_with OrcidValidator
|
@@ -145,7 +145,14 @@ module Hyrax::User
|
|
145
145
|
end
|
146
146
|
|
147
147
|
module ClassMethods
|
148
|
-
|
148
|
+
def system_user
|
149
|
+
find_or_create_system_user(system_user_key)
|
150
|
+
end
|
151
|
+
|
152
|
+
def system_user_key
|
153
|
+
Hyrax.config.system_user_key
|
154
|
+
end
|
155
|
+
|
149
156
|
def audit_user
|
150
157
|
find_or_create_system_user(audit_user_key)
|
151
158
|
end
|
@@ -158,7 +165,6 @@ module Hyrax::User
|
|
158
165
|
Hydra.config.user_key_field
|
159
166
|
end
|
160
167
|
|
161
|
-
# Override this method if you aren't using email/password
|
162
168
|
def batch_user
|
163
169
|
find_or_create_system_user(batch_user_key)
|
164
170
|
end
|
@@ -12,10 +12,10 @@ class FileDownloadStat < Hyrax::Statistic
|
|
12
12
|
Rails.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
|
13
13
|
return []
|
14
14
|
end
|
15
|
-
profile.
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
profile.hyrax__analytics__google__download(sort: 'date',
|
16
|
+
start_date: start_date,
|
17
|
+
end_date: Date.yesterday,
|
18
|
+
limit: 10_000)
|
19
19
|
.for_file(file.id)
|
20
20
|
end
|
21
21
|
|
@@ -4,9 +4,15 @@ module Hyrax
|
|
4
4
|
##
|
5
5
|
# Valkyrie model for Admin Set domain objects.
|
6
6
|
class AdministrativeSet < Hyrax::Resource
|
7
|
+
include Hyrax::Schema(:core_metadata)
|
8
|
+
|
7
9
|
attribute :alternative_title, Valkyrie::Types::Set.of(Valkyrie::Types::String)
|
8
10
|
attribute :creator, Valkyrie::Types::Set.of(Valkyrie::Types::String)
|
9
11
|
attribute :description, Valkyrie::Types::Set.of(Valkyrie::Types::String)
|
10
|
-
|
12
|
+
|
13
|
+
def collection_type_gid
|
14
|
+
# allow AdministrativeSet to behave more like a regular PcdmCollection
|
15
|
+
Hyrax::CollectionType.find_or_create_admin_set_type.to_global_id
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
# This class stores the id of the default `Hyrax::AdministrativeSet`. This is
|
4
|
+
# used to populate a cache of the default admin set in Hyrax::Configuration.
|
5
|
+
#
|
6
|
+
# @see Hyrax::Configuration.default_admin_set
|
7
|
+
# @see Hyrax::Configuration.default_admin_set_id
|
8
|
+
# @see Hyrax::Configuration.reset_default_admin_set
|
9
|
+
class DefaultAdministrativeSet < ActiveRecord::Base
|
10
|
+
self.table_name = 'hyrax_default_administrative_set'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
# Set the default admin set id in the first record.
|
14
|
+
# @param default_admin_set_id [String | Valkyrie::ID] id of the new default admin set
|
15
|
+
def update(default_admin_set_id:)
|
16
|
+
validate_id(default_admin_set_id)
|
17
|
+
Hyrax.config.reset_default_admin_set
|
18
|
+
|
19
|
+
# saving default_admin_set_id for the first time
|
20
|
+
return new(default_admin_set_id: default_admin_set_id.to_s).save if count.zero?
|
21
|
+
|
22
|
+
# replacing previously saved default_admin_set_id
|
23
|
+
existing = first
|
24
|
+
existing.default_admin_set_id = default_admin_set_id.to_s
|
25
|
+
existing.save
|
26
|
+
end
|
27
|
+
|
28
|
+
def save_supported?
|
29
|
+
ActiveRecord::Base.connection.table_exists? table_name
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def validate_id(id)
|
35
|
+
# The id is validated prior to updating because a bad default admin set
|
36
|
+
# will cause lots of problems.
|
37
|
+
return true if id.is_a?(String) || id.is_a?(Valkyrie::ID)
|
38
|
+
raise ArgumentError, "default_admin_set_id must be a non-blank String or Valkyrie::ID"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -9,6 +9,12 @@ module Hyrax
|
|
9
9
|
include Hyrax::Schema(:core_metadata)
|
10
10
|
include Hyrax::Schema(:basic_metadata)
|
11
11
|
|
12
|
+
def self.model_name(name_class: Hyrax::Name)
|
13
|
+
@_model_name ||= begin
|
14
|
+
name_class.new(self, nil, 'FileSet')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
12
18
|
attribute :file_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID) # id for FileMetadata resources
|
13
19
|
attribute :original_file_id, Valkyrie::Types::ID # id for FileMetadata resource
|
14
20
|
attribute :thumbnail_id, Valkyrie::Types::ID # id for FileMetadata resource
|
@@ -11,6 +11,7 @@ module Hyrax
|
|
11
11
|
|
12
12
|
attribute :collection_type_gid, Valkyrie::Types::String
|
13
13
|
attribute :member_ids, Valkyrie::Types::Array.of(Valkyrie::Types::ID).meta(ordered: true)
|
14
|
+
attribute :member_of_collection_ids, Valkyrie::Types::Set.of(Valkyrie::Types::ID)
|
14
15
|
|
15
16
|
##
|
16
17
|
# @api private
|
@@ -1,20 +1,61 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module Hyrax
|
3
3
|
##
|
4
|
-
#
|
4
|
+
# Holds policy data about the workflow and permissions applied objects when
|
5
|
+
# they are deposited through an Administrative Set or a Collection. Each
|
6
|
+
# template record has a {#source} (through {#source_id}); the template's
|
7
|
+
# rules inform the behavior of objects deposited through that {#source_model}.
|
5
8
|
#
|
6
|
-
#
|
7
|
-
# * calculate embargo/lease release dates
|
9
|
+
# The {PermissionTemplate} specifies:
|
8
10
|
#
|
9
|
-
#
|
11
|
+
# - an {#active_workflow} that the object will enter and be processed through.
|
12
|
+
# - {#access_grants} that can be applied to each object (especially at deposit
|
13
|
+
# time).
|
14
|
+
# - an embargo configuration ({#release_date} {#release_period}) for default
|
15
|
+
# embargo behavior.
|
10
16
|
#
|
11
|
-
#
|
12
|
-
|
17
|
+
# Additionally, the {PermissionTemplate} grants authority to perform actions
|
18
|
+
# that relate to the Administrative Set/Collection itself. Rules for who can
|
19
|
+
# deposit to, view(?!), or manage the admin set are governed by related
|
20
|
+
# {PermissionTemplateAccess} records. Administrat Sets should have a manager
|
21
|
+
# granted by some such record.
|
22
|
+
#
|
23
|
+
# @todo write up what "default embargo behavior", when it is applied, and how
|
24
|
+
# it interacts with embargoes specified by user input.
|
25
|
+
#
|
26
|
+
# @example cerating a permission template and manager for an admin set
|
27
|
+
# admin_set = Hyrax::AdministrativeSet.new(title: 'My Admin Set')
|
28
|
+
# admin_set = Hyrax.persister.save(resource: admin_set)
|
29
|
+
#
|
30
|
+
# template = PermissionTemplate.create!(source_id: admin_set.id.to_s)
|
31
|
+
# Hyrax::PermissionTemplateAccess.create!(permission_template: template,
|
32
|
+
# agent_type: Hyrax::PermissionTemplateAccess::USER,
|
33
|
+
# agent_id: user.user_key,
|
34
|
+
# access: Hyrax::PermissionTemplateAccess::MANAGE)
|
35
|
+
#
|
36
|
+
# @see Hyrax::AdministrativeSet
|
37
|
+
class PermissionTemplate < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
|
13
38
|
self.table_name = 'permission_templates'
|
14
39
|
|
40
|
+
##
|
41
|
+
# @!attribute [rw] source_id
|
42
|
+
# @return [String] identifier for the {Collection} or {AdministrativeSet}
|
43
|
+
# to which this template applies.
|
44
|
+
# @!attribute [rw] access_grants
|
45
|
+
# @return [Hyrax::PermissionTemplateAccess]
|
46
|
+
# @!attribute [rw] active_workflow
|
47
|
+
# @return [Sipity::Workflow]
|
48
|
+
# @!attribute [rw] available_workflows
|
49
|
+
# @return [Enumerable<Sipity::Workflow>]
|
15
50
|
has_many :access_grants, class_name: 'Hyrax::PermissionTemplateAccess', dependent: :destroy
|
16
51
|
accepts_nested_attributes_for :access_grants, reject_if: :all_blank
|
17
52
|
|
53
|
+
# The list of workflows that could be activated; It includes the active workflow
|
54
|
+
has_many :available_workflows, class_name: 'Sipity::Workflow', dependent: :destroy
|
55
|
+
|
56
|
+
# In a perfect world, there would be a join table that enforced uniqueness on the ID.
|
57
|
+
has_one :active_workflow, -> { where(active: true) }, class_name: 'Sipity::Workflow', foreign_key: :permission_template_id
|
58
|
+
|
18
59
|
##
|
19
60
|
# @api public
|
20
61
|
#
|
@@ -28,12 +69,6 @@ module Hyrax
|
|
28
69
|
access_grants.where(agent_type: agent_type, access: access).pluck(:agent_id)
|
29
70
|
end
|
30
71
|
|
31
|
-
# The list of workflows that could be activated; It includes the active workflow
|
32
|
-
has_many :available_workflows, class_name: 'Sipity::Workflow', dependent: :destroy
|
33
|
-
|
34
|
-
# In a perfect world, there would be a join table that enforced uniqueness on the ID.
|
35
|
-
has_one :active_workflow, -> { where(active: true) }, class_name: 'Sipity::Workflow', foreign_key: :permission_template_id
|
36
|
-
|
37
72
|
##
|
38
73
|
# @note this is a convenience method for +Hyrax.query_service.find_by(id: template.source_id)+
|
39
74
|
#
|
@@ -153,6 +188,71 @@ module Hyrax
|
|
153
188
|
visibility == value
|
154
189
|
end
|
155
190
|
|
191
|
+
##
|
192
|
+
# @return [Array<String>]
|
193
|
+
def edit_users
|
194
|
+
agent_ids_for(access: 'manage', agent_type: 'user')
|
195
|
+
end
|
196
|
+
|
197
|
+
##
|
198
|
+
# @return [Array<String>]
|
199
|
+
def edit_groups
|
200
|
+
agent_ids_for(access: 'manage', agent_type: 'group')
|
201
|
+
end
|
202
|
+
|
203
|
+
##
|
204
|
+
# @return [Array<String>]
|
205
|
+
def read_users
|
206
|
+
(agent_ids_for(access: 'view', agent_type: 'user') +
|
207
|
+
agent_ids_for(access: 'deposit', agent_type: 'user')).uniq
|
208
|
+
end
|
209
|
+
|
210
|
+
##
|
211
|
+
# @return [Array<String>]
|
212
|
+
def read_groups
|
213
|
+
(agent_ids_for(access: 'view', agent_type: 'group') +
|
214
|
+
agent_ids_for(access: 'deposit', agent_type: 'group')).uniq -
|
215
|
+
[::Ability.registered_group_name, ::Ability.public_group_name]
|
216
|
+
end
|
217
|
+
|
218
|
+
##
|
219
|
+
# @param interpret_visibility [Boolean] whether to retain the existing
|
220
|
+
# visibility when applying permission template ACLs
|
221
|
+
# @return [Boolean]
|
222
|
+
def reset_access_controls(interpret_visibility: false)
|
223
|
+
reset_access_controls_for(collection: source_model,
|
224
|
+
interpret_visibility: interpret_visibility)
|
225
|
+
end
|
226
|
+
|
227
|
+
##
|
228
|
+
# @param collection [::Collection, Hyrax::Resource]
|
229
|
+
# @param interpret_visibility [Boolean] whether to retain the existing
|
230
|
+
# visibility when applying permission template ACLs
|
231
|
+
# @return [Boolean]
|
232
|
+
def reset_access_controls_for(collection:, interpret_visibility: false) # rubocop:disable Metrics/MethodLength
|
233
|
+
interpreted_read_groups = read_groups
|
234
|
+
|
235
|
+
if interpret_visibility
|
236
|
+
visibilities = Hyrax::VisibilityMap.instance
|
237
|
+
interpreted_read_groups -= visibilities.deletions_for(visibility: collection.visibility)
|
238
|
+
interpreted_read_groups += visibilities.additions_for(visibility: collection.visibility)
|
239
|
+
end
|
240
|
+
|
241
|
+
case collection
|
242
|
+
when Valkyrie::Resource
|
243
|
+
collection.permission_manager.edit_groups = edit_groups
|
244
|
+
collection.permission_manager.edit_users = edit_users
|
245
|
+
collection.permission_manager.read_groups = interpreted_read_groups
|
246
|
+
collection.permission_manager.read_users = read_users
|
247
|
+
collection.permission_manager.acl.save
|
248
|
+
else
|
249
|
+
collection.update!(edit_users: edit_users,
|
250
|
+
edit_groups: edit_groups,
|
251
|
+
read_users: read_users,
|
252
|
+
read_groups: interpreted_read_groups.uniq)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
156
256
|
private
|
157
257
|
|
158
258
|
# If template requires no delays, check if date is exactly today
|
@@ -34,13 +34,40 @@ module Hyrax
|
|
34
34
|
Rails.logger.error("Google Analytics profile has not been established. Unable to fetch statistics.")
|
35
35
|
return []
|
36
36
|
end
|
37
|
-
profile.
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
profile.hyrax__analytics__google__pageviews(sort: 'date',
|
38
|
+
start_date: start_date,
|
39
|
+
end_date: Date.yesterday,
|
40
|
+
limit: 10_000)
|
41
41
|
.for_path(path)
|
42
42
|
end
|
43
43
|
|
44
|
+
def query_works(query)
|
45
|
+
models = Hyrax.config.curation_concerns.map { |m| "\"#{m}\"" }
|
46
|
+
ActiveFedora::SolrService.query("has_model_ssim:(#{models.join(' OR ')})", fl: query, rows: 100_000)
|
47
|
+
end
|
48
|
+
|
49
|
+
def work_types
|
50
|
+
results = query_works("human_readable_type_tesim")
|
51
|
+
results.group_by { |result| result['human_readable_type_tesim'].join('') }.transform_values(&:count)
|
52
|
+
end
|
53
|
+
|
54
|
+
def resource_types
|
55
|
+
results = query_works("resource_type_tesim")
|
56
|
+
resource_types = []
|
57
|
+
results.each do |y|
|
58
|
+
if y["resource_type_tesim"].nil? || (y["resource_type_tesim"] == [""])
|
59
|
+
resource_types.push("Unknown")
|
60
|
+
elsif y["resource_type_tesim"].count > 1
|
61
|
+
y["resource_type_tesim"].each do |t|
|
62
|
+
resource_types.push(t)
|
63
|
+
end
|
64
|
+
else
|
65
|
+
resource_types.push(y["resource_type_tesim"].join(""))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
resource_types.group_by { |rt| rt }.transform_values(&:count)
|
69
|
+
end
|
70
|
+
|
44
71
|
private
|
45
72
|
|
46
73
|
def cached_stats(object, start_date, _method)
|