hyrax 3.2.0 → 3.4.1
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 +3 -6
- data/.dassie/.env +1 -1
- data/.dassie/Gemfile +7 -3
- 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 +13 -1
- 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 +70 -15
- data/.env +7 -4
- data/.github/release.yml +26 -0
- data/.github/workflows/main.yml +17 -0
- data/.github/workflows/release.yml +17 -0
- data/.gitignore +4 -0
- data/.regen +1 -1
- data/.rubocop_fixme.yml +3 -1
- data/CONTAINERS.md +13 -10
- data/Dockerfile +2 -1
- data/README.md +37 -0
- data/app/actors/hyrax/actors/file_actor.rb +6 -4
- data/app/actors/hyrax/actors/transfer_request_actor.rb +3 -7
- data/app/assets/javascripts/hyrax/admin/graphs.es6 +34 -37
- data/app/assets/javascripts/hyrax/analytics_events.js +75 -0
- data/app/assets/javascripts/hyrax/autocomplete/linked_data.es6 +1 -3
- 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/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/controller.rb +43 -0
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +83 -59
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +105 -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 +12 -19
- data/app/controllers/hyrax/batch_edits_controller.rb +12 -3
- data/app/controllers/hyrax/batch_uploads_controller.rb +4 -0
- data/app/controllers/hyrax/citations_controller.rb +1 -1
- data/app/controllers/hyrax/collections_controller.rb +4 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +34 -16
- data/app/controllers/hyrax/dashboard_controller.rb +8 -0
- data/app/controllers/hyrax/stats_controller.rb +3 -1
- data/app/forms/hyrax/forms/administrative_set_form.rb +19 -1
- data/app/forms/hyrax/forms/batch_edit_form.rb +1 -1
- data/app/forms/hyrax/forms/dashboard/nest_collection_form.rb +21 -6
- data/app/forms/hyrax/forms/pcdm_collection_form.rb +4 -0
- data/app/forms/hyrax/forms/permission_template_form.rb +17 -9
- data/app/forms/hyrax/forms/resource_form.rb +9 -5
- data/app/helpers/hyrax/collections_helper.rb +14 -0
- data/app/helpers/hyrax/membership_helper.rb +1 -1
- data/app/helpers/hyrax/trophy_helper.rb +1 -1
- data/app/helpers/hyrax/url_helper.rb +1 -1
- data/app/indexers/hyrax/administrative_set_indexer.rb +8 -2
- data/app/indexers/hyrax/deep_indexing_service.rb +1 -1
- data/app/indexers/hyrax/file_set_indexer.rb +1 -0
- data/app/indexers/hyrax/pcdm_collection_indexer.rb +3 -1
- data/app/indexers/hyrax/thumbnail_indexer.rb +31 -0
- data/app/indexers/hyrax/valkyrie_file_set_indexer.rb +7 -7
- data/app/indexers/hyrax/valkyrie_indexer.rb +4 -2
- data/app/indexers/hyrax/valkyrie_work_indexer.rb +13 -0
- data/app/inputs/controlled_vocabulary_input.rb +2 -0
- data/app/jobs/change_depositor_event_job.rb +47 -0
- data/app/jobs/characterize_job.rb +66 -3
- data/app/jobs/concerns/hyrax/members_permission_job_behavior.rb +1 -1
- data/app/jobs/content_depositor_change_event_job.rb +2 -1
- data/app/jobs/hyrax/propagate_change_depositor_job.rb +32 -0
- data/app/jobs/inherit_permissions_job.rb +1 -1
- data/app/jobs/valkyrie_create_derivatives_job.rb +25 -0
- data/app/jobs/valkyrie_ingest_job.rb +124 -0
- data/app/models/admin_set.rb +2 -2
- data/app/models/collection_branding_info.rb +8 -6
- data/app/models/concerns/hyrax/ability.rb +26 -5
- data/app/models/concerns/hyrax/collection_behavior.rb +2 -2
- data/app/models/concerns/hyrax/file_set/characterization.rb +7 -1
- data/app/models/concerns/hyrax/solr_document/metadata.rb +2 -0
- data/app/models/concerns/hyrax/solr_document_behavior.rb +9 -3
- data/app/models/file_download_stat.rb +4 -4
- data/app/models/hyrax/administrative_set.rb +36 -1
- data/app/models/hyrax/collection_type.rb +2 -2
- data/app/models/hyrax/default_administrative_set.rb +42 -0
- data/app/models/hyrax/file_metadata.rb +5 -1
- data/app/models/hyrax/file_set.rb +42 -1
- data/app/models/hyrax/pcdm_collection.rb +56 -0
- data/app/models/hyrax/permission_template.rb +11 -5
- data/app/models/hyrax/statistic.rb +31 -4
- data/app/models/hyrax/work.rb +91 -0
- data/app/models/proxy_deposit_request.rb +1 -1
- 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_presenter.rb +2 -2
- data/app/presenters/hyrax/file_set_presenter.rb +2 -0
- data/app/presenters/hyrax/menu_presenter.rb +4 -0
- data/app/presenters/hyrax/pcdm_member_presenter_factory.rb +3 -3
- data/app/presenters/hyrax/work_show_presenter.rb +9 -2
- data/app/presenters/hyrax/work_usage.rb +1 -0
- data/app/search_builders/hyrax/README.md +1 -1
- data/app/search_builders/hyrax/dashboard/collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/dashboard/managed_search_filters.rb +44 -4
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +2 -2
- data/app/search_builders/hyrax/my/collections_search_builder.rb +12 -5
- data/app/services/hyrax/access_control_list.rb +13 -0
- data/app/services/hyrax/admin_set_create_service.rb +94 -48
- 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/change_content_depositor_service.rb +2 -2
- data/app/services/hyrax/change_depositor_service.rb +70 -0
- data/app/services/hyrax/characterization/valkyrie_characterization_service.rb +134 -0
- data/app/services/hyrax/collections/nested_collection_query_service.rb +32 -15
- data/app/services/hyrax/custom_queries/navigators/child_file_sets_navigator.rb +45 -0
- data/app/services/hyrax/custom_queries/navigators/child_filesets_navigator.rb +7 -2
- data/app/services/hyrax/custom_queries/navigators/parent_work_navigator.rb +54 -0
- data/app/services/hyrax/default_middleware_stack.rb +3 -0
- data/app/services/hyrax/file_set_derivatives_service.rb +21 -2
- data/app/services/hyrax/file_set_type_service.rb +2 -5
- data/app/services/hyrax/listeners/acl_index_listener.rb +3 -1
- data/app/services/hyrax/listeners/active_fedora_acl_index_listener.rb +3 -1
- data/app/services/hyrax/listeners/batch_notification_listener.rb +3 -1
- data/app/services/hyrax/listeners/file_metadata_listener.rb +38 -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 +26 -3
- data/app/services/hyrax/listeners/metadata_index_listener.rb +48 -3
- data/app/services/hyrax/listeners/object_lifecycle_listener.rb +9 -3
- data/app/services/hyrax/listeners/proxy_deposit_listener.rb +16 -8
- 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/location_service.rb +33 -0
- data/app/services/hyrax/multiple_membership_checker.rb +44 -1
- data/app/services/hyrax/resource_visibility_propagator.rb +1 -1
- data/app/services/hyrax/restriction_service.rb +4 -0
- data/app/services/hyrax/simple_schema_loader.rb +5 -1
- data/app/services/hyrax/solr_query_service.rb +12 -7
- 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/thumbnail_path_service.rb +1 -1
- data/app/services/hyrax/work_uploads_handler.rb +2 -9
- data/app/utils/hyrax/data_destroyers/collection_branding_destroyer.rb +29 -0
- data/app/utils/hyrax/data_destroyers/collection_types_destroyer.rb +26 -0
- data/app/utils/hyrax/data_destroyers/default_admin_set_id_cache_destroyer.rb +26 -0
- data/app/utils/hyrax/data_destroyers/featured_works_destroyer.rb +27 -0
- data/app/utils/hyrax/data_destroyers/permission_templates_destroyer.rb +30 -0
- data/app/utils/hyrax/data_destroyers/repository_metadata_destroyer.rb +42 -0
- data/app/utils/hyrax/data_destroyers/stats_destroyer.rb +33 -0
- data/app/utils/hyrax/data_maintenance.rb +51 -0
- data/app/utils/hyrax/required_data_seeder.rb +21 -0
- data/app/utils/hyrax/required_data_seeders/collection_seeder.rb +26 -0
- data/app/utils/hyrax/required_data_seeders/collection_type_seeder.rb +36 -0
- data/app/utils/hyrax/test_data_seeder.rb +24 -0
- data/app/utils/hyrax/test_data_seeders/collection_seeder.rb +91 -0
- data/app/utils/hyrax/test_data_seeders/collection_type_seeder.rb +72 -0
- data/app/utils/hyrax/test_data_seeders/user_seeder.rb +52 -0
- data/app/validators/hyrax/collection_membership_validator.rb +38 -0
- data/app/views/catalog/_index_header_list_hyrax_pcdm_collection.html.erb +4 -0
- data/app/views/hyrax/admin/admin_sets/_form_participant_table.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_participants.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_visibility.html.erb +2 -2
- data/app/views/hyrax/admin/admin_sets/_form_workflow.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/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/admin/stats/show.html.erb +1 -1
- data/app/views/hyrax/base/_form.html.erb +1 -1
- data/app/views/hyrax/base/_form_child_work_relationships.html.erb +1 -1
- data/app/views/hyrax/base/_relationships_parent_row.html.erb +0 -1
- data/app/views/hyrax/base/show.html.erb +6 -0
- 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/_default_group.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +23 -16
- data/app/views/hyrax/dashboard/collections/_form_discovery.html.erb +6 -3
- data/app/views/hyrax/dashboard/collections/_form_share.html.erb +2 -2
- data/app/views/hyrax/dashboard/collections/_form_share_table.html.erb +3 -3
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +2 -2
- 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/dashboard/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/dashboard/works/_list_works.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +4 -3
- data/app/views/hyrax/file_sets/show.html.erb +6 -0
- data/app/views/hyrax/my/_facet_pagination.html.erb +12 -9
- data/app/views/hyrax/my/_work_action_menu.html.erb +8 -9
- data/app/views/hyrax/my/collections/_default_group.html.erb +2 -2
- data/app/views/hyrax/my/collections/_list_collections.html.erb +2 -2
- data/app/views/hyrax/my/collections/index.html.erb +4 -3
- data/app/views/hyrax/my/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/my/works/_list_works.html.erb +1 -2
- data/app/views/hyrax/my/works/index.html.erb +4 -2
- 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/{_ga.html.erb → shared/_ga.html.erb} +3 -7
- data/app/views/shared/_matomo.html.erb +15 -0
- data/chart/hyrax/Chart.yaml +2 -2
- data/chart/hyrax/README.md +22 -1
- data/chart/hyrax/values.yaml +1 -1
- data/config/i18n-tasks.yml +2 -2
- data/config/initializers/listeners.rb +5 -6
- data/config/locales/hyrax.de.yml +200 -5
- data/config/locales/hyrax.en.yml +201 -21
- data/config/locales/hyrax.es.yml +204 -9
- data/config/locales/hyrax.fr.yml +196 -1
- data/config/locales/hyrax.it.yml +197 -2
- data/config/locales/hyrax.pt-BR.yml +196 -1
- data/config/locales/hyrax.zh.yml +196 -1
- data/config/metadata/basic_metadata.yaml +2 -0
- data/config/metadata/core_metadata.yaml +1 -1
- data/config/routes.rb +4 -0
- data/docker-compose.yml +48 -42
- data/documentation/developing-your-hyrax-based-app.md +2 -2
- data/documentation/legacyREADME.md +1 -1
- data/hyrax.gemspec +3 -1
- data/lib/generators/hyrax/templates/config/analytics.yml +13 -7
- data/lib/generators/hyrax/templates/config/initializers/hyrax.rb +0 -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 +3 -1
- data/lib/hyrax/administrative_set_name.rb +18 -0
- data/lib/hyrax/collection_name.rb +2 -0
- data/lib/hyrax/configuration.rb +77 -5
- data/lib/hyrax/controlled_vocabularies/location.rb +9 -2
- data/lib/hyrax/controlled_vocabularies/resource_label_caching.rb +42 -0
- data/lib/hyrax/controlled_vocabularies.rb +1 -0
- data/lib/hyrax/engine.rb +7 -6
- data/lib/hyrax/publisher.rb +49 -0
- data/lib/hyrax/schema.rb +16 -13
- data/lib/hyrax/specs/capybara.rb +1 -1
- data/lib/hyrax/specs/shared_specs/hydra_works.rb +11 -4
- data/lib/hyrax/specs/shared_specs/indexers.rb +117 -3
- data/lib/hyrax/transactions/admin_set_create.rb +23 -0
- data/lib/hyrax/transactions/admin_set_destroy.rb +22 -0
- data/lib/hyrax/transactions/admin_set_update.rb +21 -0
- data/lib/hyrax/transactions/collection_destroy.rb +22 -0
- data/lib/hyrax/transactions/collection_update.rb +3 -2
- data/lib/hyrax/transactions/container.rb +97 -22
- data/lib/hyrax/transactions/create_work.rb +3 -0
- data/lib/hyrax/transactions/destroy_work.rb +3 -0
- data/lib/hyrax/transactions/steps/apply_collection_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/apply_visibility.rb +2 -0
- data/lib/hyrax/transactions/steps/change_depositor.rb +46 -0
- data/lib/hyrax/transactions/steps/check_for_empty_admin_set.rb +36 -0
- data/lib/hyrax/transactions/steps/delete_access_control.rb +32 -0
- data/lib/hyrax/transactions/steps/delete_resource.rb +19 -3
- data/lib/hyrax/transactions/steps/destroy_work.rb +3 -1
- data/lib/hyrax/transactions/steps/ensure_permission_template.rb +2 -0
- data/lib/hyrax/transactions/steps/save.rb +24 -6
- data/lib/hyrax/transactions/steps/save_access_control.rb +2 -2
- data/lib/hyrax/transactions/steps/save_work.rb +3 -0
- data/lib/hyrax/transactions/steps/set_user_as_creator.rb +41 -0
- data/lib/hyrax/transactions/steps/update_work_members.rb +51 -0
- data/lib/hyrax/transactions/update_work.rb +4 -3
- data/lib/hyrax/transactions/work_create.rb +1 -1
- data/lib/hyrax/transactions/work_destroy.rb +2 -1
- data/lib/hyrax/transactions/work_update.rb +19 -0
- data/lib/hyrax/version.rb +1 -1
- data/lib/tasks/regenerate_derivatives.rake +1 -1
- data/lib/wings/attribute_transformer.rb +5 -1
- data/lib/wings/setup.rb +18 -1
- data/lib/wings/valkyrie/persister.rb +18 -0
- data/lib/wings/valkyrie/query_service.rb +2 -1
- data/lib/wings/valkyrie/storage.rb +7 -1
- 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 +124 -11
- data/app/views/hyrax/dashboard/_repository_objects.html.erb +0 -28
@@ -55,21 +55,12 @@ module Hyrax
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def create
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
after_create_response
|
58
|
+
case curation_concern
|
59
|
+
when ActiveFedora::Base
|
60
|
+
original_input_params_for_form = params[hash_key_for_curation_concern].deep_dup
|
61
|
+
actor.create(actor_environment) ? after_create_response : after_create_error(curation_concern.errors, original_input_params_for_form)
|
62
62
|
else
|
63
|
-
|
64
|
-
wants.html do
|
65
|
-
build_form
|
66
|
-
# Creating a form object that can re-render most of the
|
67
|
-
# submitted parameters
|
68
|
-
@form = Hyrax::Forms::FailedSubmissionFormWrapper.new(form: @form, input_params: original_input_params_for_form)
|
69
|
-
render 'new', status: :unprocessable_entity
|
70
|
-
end
|
71
|
-
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
|
72
|
-
end
|
63
|
+
create_valkyrie_work
|
73
64
|
end
|
74
65
|
end
|
75
66
|
|
@@ -101,16 +92,11 @@ module Hyrax
|
|
101
92
|
end
|
102
93
|
|
103
94
|
def update
|
104
|
-
|
105
|
-
|
95
|
+
case curation_concern
|
96
|
+
when ActiveFedora::Base
|
97
|
+
actor.update(actor_environment) ? after_update_response : after_update_error(curation_concern.errors)
|
106
98
|
else
|
107
|
-
|
108
|
-
wants.html do
|
109
|
-
build_form
|
110
|
-
render 'edit', status: :unprocessable_entity
|
111
|
-
end
|
112
|
-
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: curation_concern.errors }) }
|
113
|
-
end
|
99
|
+
update_valkyrie_work
|
114
100
|
end
|
115
101
|
end
|
116
102
|
|
@@ -176,13 +162,7 @@ module Hyrax
|
|
176
162
|
end
|
177
163
|
|
178
164
|
def admin_set_id_for_new
|
179
|
-
|
180
|
-
# however it isn't a required field for someone to submit via json.
|
181
|
-
# Set the default admin set if it exists; otherwise, set to first admin_set they have access to.
|
182
|
-
admin_sets = Hyrax::AdminSetService.new(self).search_results(:deposit)
|
183
|
-
return nil if admin_sets.blank? # shouldn't happen
|
184
|
-
return AdminSet::DEFAULT_ID if admin_sets.map(&:id).include?(AdminSet::DEFAULT_ID)
|
185
|
-
admin_sets.first.id
|
165
|
+
Hyrax::AdminSetCreateService.find_or_create_default_admin_set.id.to_s
|
186
166
|
end
|
187
167
|
|
188
168
|
def build_form
|
@@ -195,36 +175,45 @@ module Hyrax
|
|
195
175
|
|
196
176
|
##
|
197
177
|
# @return [#errors]
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
178
|
+
def create_valkyrie_work
|
179
|
+
form = build_form
|
180
|
+
return after_create_error(form_err_msg(form)) unless form.validate(params[hash_key_for_curation_concern])
|
181
|
+
|
182
|
+
result =
|
183
|
+
transactions['change_set.create_work']
|
184
|
+
.with_step_args(
|
185
|
+
'work_resource.add_to_parent' => { parent_id: params[:parent_id], user: current_user },
|
186
|
+
'work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
|
187
|
+
'change_set.set_user_as_depositor' => { user: current_user },
|
188
|
+
'work_resource.change_depositor' => { user: ::User.find_by_user_key(form.on_behalf_of) }
|
189
|
+
)
|
190
|
+
.call(form)
|
191
|
+
@curation_concern = result.value_or { return after_create_error(transaction_err_msg(result)) }
|
192
|
+
after_create_response
|
213
193
|
end
|
214
194
|
|
215
|
-
def
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
195
|
+
def update_valkyrie_work
|
196
|
+
form = build_form
|
197
|
+
return after_update_error(form_err_msg(form)) unless form.validate(params[hash_key_for_curation_concern])
|
198
|
+
result =
|
199
|
+
transactions['change_set.update_work']
|
200
|
+
.with_step_args('work_resource.add_file_sets' => { uploaded_files: uploaded_files, file_set_params: params[hash_key_for_curation_concern][:file_set] },
|
201
|
+
'work_resource.update_work_members' => { work_members_attributes: work_members_attributes })
|
202
|
+
.call(form)
|
203
|
+
@curation_concern = result.value_or { return after_update_error(transaction_err_msg(result)) }
|
204
|
+
after_update_response
|
205
|
+
end
|
221
206
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
207
|
+
def work_members_attributes
|
208
|
+
params[hash_key_for_curation_concern][:work_members_attributes]&.permit!&.to_h
|
209
|
+
end
|
210
|
+
|
211
|
+
def form_err_msg(form)
|
212
|
+
form.errors.messages.values.flatten.to_sentence
|
213
|
+
end
|
214
|
+
|
215
|
+
def transaction_err_msg(result)
|
216
|
+
result.failure.first
|
228
217
|
end
|
229
218
|
|
230
219
|
def presenter
|
@@ -383,6 +372,26 @@ module Hyrax
|
|
383
372
|
end
|
384
373
|
end
|
385
374
|
|
375
|
+
def after_create_error(errors, original_input_params_for_form = nil)
|
376
|
+
respond_to do |wants|
|
377
|
+
wants.html do
|
378
|
+
flash[:error] = errors.to_s
|
379
|
+
rebuild_form(original_input_params_for_form) if original_input_params_for_form.present?
|
380
|
+
render 'new', status: :unprocessable_entity
|
381
|
+
end
|
382
|
+
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
# Creating a form object that can re-render most of the submitted parameters.
|
387
|
+
# Required for ActiveFedora::Base objects only.
|
388
|
+
def rebuild_form(original_input_params_for_form)
|
389
|
+
build_form
|
390
|
+
@form = Hyrax::Forms::FailedSubmissionFormWrapper
|
391
|
+
.new(form: @form,
|
392
|
+
input_params: original_input_params_for_form)
|
393
|
+
end
|
394
|
+
|
386
395
|
def after_update_response
|
387
396
|
return redirect_to hyrax.confirm_access_permission_path(curation_concern) if permissions_changed? && concern_has_file_sets?
|
388
397
|
|
@@ -392,6 +401,17 @@ module Hyrax
|
|
392
401
|
end
|
393
402
|
end
|
394
403
|
|
404
|
+
def after_update_error(errors)
|
405
|
+
respond_to do |wants|
|
406
|
+
wants.html do
|
407
|
+
flash[:error] = errors.to_s
|
408
|
+
build_form unless @form.is_a? Hyrax::ChangeSet
|
409
|
+
render 'edit', status: :unprocessable_entity
|
410
|
+
end
|
411
|
+
wants.json { render_json_response(response_type: :unprocessable_entity, options: { errors: errors }) }
|
412
|
+
end
|
413
|
+
end
|
414
|
+
|
395
415
|
def after_destroy_response(title)
|
396
416
|
respond_to do |wants|
|
397
417
|
wants.html { redirect_to hyrax.my_works_path, notice: "Deleted #{title}" }
|
@@ -432,7 +452,7 @@ module Hyrax
|
|
432
452
|
when ActiveFedora::Common
|
433
453
|
curation_concern.file_sets.present?
|
434
454
|
else
|
435
|
-
Hyrax.custom_queries.
|
455
|
+
Hyrax.custom_queries.find_child_file_set_ids(resource: curation_concern).any?
|
436
456
|
end
|
437
457
|
end
|
438
458
|
|
@@ -441,12 +461,16 @@ module Hyrax
|
|
441
461
|
end
|
442
462
|
|
443
463
|
def available_admin_sets
|
464
|
+
# only returns admin sets in which the user can deposit
|
444
465
|
admin_set_results = Hyrax::AdminSetService.new(self).search_results(:deposit)
|
466
|
+
|
445
467
|
# get all the templates at once, reducing query load
|
446
|
-
templates = PermissionTemplate.where(
|
468
|
+
templates = PermissionTemplate.where(source_id: admin_set_results.map(&:id)).to_a
|
447
469
|
|
448
470
|
admin_sets = admin_set_results.map do |admin_set_doc|
|
449
471
|
template = templates.find { |temp| temp.source_id == admin_set_doc.id.to_s }
|
472
|
+
|
473
|
+
# determine if sharing tab should be visible
|
450
474
|
sharing = can?(:manage, template) || !!template&.active_workflow&.allows_access_grant?
|
451
475
|
|
452
476
|
AdminSetSelectionPresenter::OptionsEntry
|
@@ -4,7 +4,8 @@ module Hyrax
|
|
4
4
|
include Hyrax::CollectionsControllerBehavior
|
5
5
|
|
6
6
|
before_action :authenticate_user!
|
7
|
-
load_and_authorize_resource
|
7
|
+
load_and_authorize_resource instance_name: :admin_set,
|
8
|
+
class: Hyrax.config.admin_set_model
|
8
9
|
|
9
10
|
# Catch permission errors
|
10
11
|
rescue_from Hydra::AccessDenied, CanCan::AccessDenied, with: :deny_adminset_access
|
@@ -61,28 +62,52 @@ module Hyrax
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def update
|
64
|
-
|
65
|
-
|
65
|
+
case @admin_set
|
66
|
+
when Valkyrie::Resource
|
67
|
+
valkyrie_update
|
66
68
|
else
|
67
|
-
|
68
|
-
render :edit
|
69
|
+
active_fedora_update
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
73
|
+
def after_create
|
74
|
+
Hyrax::SolrService.commit
|
75
|
+
redirect_to hyrax.edit_admin_admin_set_path(admin_set_id),
|
76
|
+
notice: I18n.t('new_admin_set',
|
77
|
+
scope: 'hyrax.admin.admin_sets.form.permission_update_notices',
|
78
|
+
name: @admin_set.title.first)
|
79
|
+
end
|
80
|
+
|
81
|
+
def after_create_error(err_msg: "")
|
82
|
+
msg = "Failed to create admin set: #{err_msg}"
|
83
|
+
setup_form
|
84
|
+
flash[:error] = msg
|
85
|
+
Hyrax.logger.error(msg)
|
86
|
+
render :new
|
87
|
+
end
|
88
|
+
|
72
89
|
def create
|
73
|
-
|
74
|
-
|
90
|
+
case @admin_set
|
91
|
+
when Valkyrie::Resource
|
92
|
+
valkyrie_create
|
75
93
|
else
|
76
|
-
|
77
|
-
render :new
|
94
|
+
active_fedora_create
|
78
95
|
end
|
79
96
|
end
|
80
97
|
|
81
98
|
def destroy
|
82
|
-
|
99
|
+
case @admin_set
|
100
|
+
when Valkyrie::Resource
|
101
|
+
transactions['admin_set_resource.destroy'].call(@admin_set).value_or do |failure|
|
102
|
+
redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: failure.first
|
103
|
+
end
|
83
104
|
after_delete_success
|
84
105
|
else
|
85
|
-
|
106
|
+
if @admin_set.destroy
|
107
|
+
after_delete_success
|
108
|
+
else
|
109
|
+
redirect_to hyrax.admin_admin_set_path(admin_set_id), alert: @admin_set.errors.full_messages.to_sentence
|
110
|
+
end
|
86
111
|
end
|
87
112
|
end
|
88
113
|
|
@@ -98,12 +123,50 @@ module Hyrax
|
|
98
123
|
|
99
124
|
private
|
100
125
|
|
101
|
-
def
|
102
|
-
|
126
|
+
def valkyrie_update
|
127
|
+
@admin_set = form.validate(admin_set_params) && transactions['admin_set_resource.update'].call(form).value_or do |_failure|
|
128
|
+
setup_form # probably should do some real error handling here
|
129
|
+
render :edit
|
130
|
+
end
|
131
|
+
redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
|
132
|
+
end
|
133
|
+
|
134
|
+
def active_fedora_update
|
135
|
+
if @admin_set.update(admin_set_params)
|
136
|
+
redirect_to update_referer, notice: I18n.t('updated_admin_set', scope: 'hyrax.admin.admin_sets.form.permission_update_notices', name: @admin_set.title.first)
|
137
|
+
else
|
138
|
+
setup_form
|
139
|
+
render :edit
|
140
|
+
end
|
103
141
|
end
|
104
142
|
|
105
|
-
def
|
106
|
-
|
143
|
+
def update_referer
|
144
|
+
hyrax.edit_admin_admin_set_path(admin_set_id) + (params[:referer_anchor] || '')
|
145
|
+
end
|
146
|
+
|
147
|
+
def valkyrie_create
|
148
|
+
form.validate(admin_set_params) &&
|
149
|
+
@admin_set = transactions['change_set.create_admin_set']
|
150
|
+
.with_step_args(
|
151
|
+
'change_set.set_user_as_creator' => { user: current_user },
|
152
|
+
'admin_set_resource.apply_collection_type_permissions' => { user: current_user }
|
153
|
+
)
|
154
|
+
.call(form).value_or do |_failure|
|
155
|
+
setup_form # probably should do some real error handling here
|
156
|
+
render :edit
|
157
|
+
end
|
158
|
+
@admin_set = admin_set_create_service.call!(admin_set: @admin_set, creating_user: current_user)
|
159
|
+
after_create
|
160
|
+
rescue RuntimeError => err
|
161
|
+
after_create_error(err_msg: err.message)
|
162
|
+
end
|
163
|
+
|
164
|
+
def active_fedora_create
|
165
|
+
updated_admin_set = admin_set_create_service.call!(admin_set: admin_set_resource, creating_user: current_user)
|
166
|
+
@admin_set = Wings::ActiveFedoraConverter.convert(resource: updated_admin_set)
|
167
|
+
after_create
|
168
|
+
rescue RuntimeError => err
|
169
|
+
after_create_error(err_msg: err.message)
|
107
170
|
end
|
108
171
|
|
109
172
|
def setup_form
|
@@ -116,7 +179,13 @@ module Hyrax
|
|
116
179
|
|
117
180
|
# initialize the form object
|
118
181
|
def form
|
119
|
-
@form ||=
|
182
|
+
@form ||=
|
183
|
+
case @admin_set
|
184
|
+
when Valkyrie::Resource
|
185
|
+
Hyrax::Forms::ResourceForm.for(@admin_set)
|
186
|
+
else
|
187
|
+
form_class.new(@admin_set, current_ability, repository)
|
188
|
+
end
|
120
189
|
end
|
121
190
|
|
122
191
|
def action_breadcrumb
|
@@ -129,7 +198,11 @@ module Hyrax
|
|
129
198
|
end
|
130
199
|
|
131
200
|
def admin_set_params
|
132
|
-
|
201
|
+
if Hyrax.config.admin_set_class < ActiveFedora::Base
|
202
|
+
form_class.model_attributes(params[:admin_set])
|
203
|
+
else
|
204
|
+
params.permit(admin_set: {})[:admin_set]
|
205
|
+
end
|
133
206
|
end
|
134
207
|
|
135
208
|
def repository_class
|
@@ -137,13 +210,26 @@ module Hyrax
|
|
137
210
|
end
|
138
211
|
|
139
212
|
def after_delete_success
|
140
|
-
if request.referer
|
213
|
+
if request.referer&.include? "my/collections"
|
141
214
|
redirect_to hyrax.my_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
|
142
|
-
elsif request.referer
|
215
|
+
elsif request.referer&.include? "collections"
|
143
216
|
redirect_to hyrax.dashboard_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
|
144
217
|
else
|
145
218
|
redirect_to hyrax.my_collections_path, notice: t(:'hyrax.admin.admin_sets.delete.notification')
|
146
219
|
end
|
147
220
|
end
|
221
|
+
|
222
|
+
def admin_set_id
|
223
|
+
@admin_set&.id&.to_s
|
224
|
+
end
|
225
|
+
|
226
|
+
def admin_set_resource
|
227
|
+
case @admin_set
|
228
|
+
when Valkyrie::Resource
|
229
|
+
@admin_set
|
230
|
+
else
|
231
|
+
@admin_set.valkyrie_resource
|
232
|
+
end
|
233
|
+
end
|
148
234
|
end
|
149
235
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Admin
|
4
|
+
module Analytics
|
5
|
+
class AnalyticsController < ApplicationController
|
6
|
+
include Hyrax::SingularSubresourceController
|
7
|
+
before_action :set_months
|
8
|
+
before_action :set_date_range
|
9
|
+
before_action :set_document, only: [:show]
|
10
|
+
with_themed_layout 'dashboard'
|
11
|
+
|
12
|
+
def set_document
|
13
|
+
@document = ::SolrDocument.find(params[:id])
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_months
|
17
|
+
@month_names = 12.downto(1).map { |n| DateTime::ABBR_MONTHNAMES.drop(1)[(Time.zone.today.month - n) % 12] }.reverse
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_date_range
|
21
|
+
@start_date = params[:start_date] || Hyrax.config.analytics_start_date
|
22
|
+
@end_date = params[:end_date] || Time.zone.today + 1.day
|
23
|
+
end
|
24
|
+
|
25
|
+
def date_range
|
26
|
+
"#{@start_date},#{@end_date}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def paginate(results_array, rows: 10)
|
30
|
+
return if results_array.nil?
|
31
|
+
|
32
|
+
total_pages = (results_array.size.to_f / rows.to_f).ceil
|
33
|
+
page = request.params[:page].nil? ? 1 : request.params[:page].to_i
|
34
|
+
current_page = page > total_pages ? total_pages : page
|
35
|
+
Kaminari.paginate_array(results_array, total_count: results_array.size).page(current_page).per(rows)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Admin
|
4
|
+
module Analytics
|
5
|
+
class CollectionReportsController < AnalyticsController
|
6
|
+
include Hyrax::BreadcrumbsForCollectionAnalytics
|
7
|
+
def index
|
8
|
+
return unless Hyrax.config.analytics?
|
9
|
+
|
10
|
+
@pageviews = Hyrax::Analytics.daily_events('collection-page-view')
|
11
|
+
@work_page_views = Hyrax::Analytics.daily_events('work-in-collection-view')
|
12
|
+
@downloads = Hyrax::Analytics.daily_events('work-in-collection-download')
|
13
|
+
@all_top_collections = Hyrax::Analytics.top_events('work-in-collection-view', date_range)
|
14
|
+
@top_collections = paginate(@all_top_collections, rows: 10)
|
15
|
+
@top_downloads = Hyrax::Analytics.top_events('work-in-collection-download', date_range)
|
16
|
+
@top_collection_pages = Hyrax::Analytics.top_events('collection-page-view', date_range)
|
17
|
+
respond_to do |format|
|
18
|
+
format.html
|
19
|
+
format.csv { export_data }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
return unless Hyrax.config.analytics?
|
25
|
+
@document = ::SolrDocument.find(params[:id])
|
26
|
+
@pageviews = Hyrax::Analytics.daily_events_for_id(@document.id, 'collection-page-view')
|
27
|
+
@work_page_views = Hyrax::Analytics.daily_events_for_id(@document.id, 'work-in-collection-view')
|
28
|
+
@uniques = Hyrax::Analytics.unique_visitors_for_id(@document.id)
|
29
|
+
@downloads = Hyrax::Analytics.daily_events_for_id(@document.id, 'work-in-collection-download')
|
30
|
+
respond_to do |format|
|
31
|
+
format.html
|
32
|
+
format.csv { export_data }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
# rubocop:disable Metrics/MethodLength
|
39
|
+
def export_data
|
40
|
+
csv_row = CSV.generate do |csv|
|
41
|
+
csv << ["Name", "ID", "View of Works In Collection", "Downloads of Works In Collection", "Collection Page Views"]
|
42
|
+
@all_top_collections.each do |collection|
|
43
|
+
document = begin
|
44
|
+
::SolrDocument.find(collection[0])
|
45
|
+
rescue
|
46
|
+
"Collection deleted"
|
47
|
+
end
|
48
|
+
download_match = @top_downloads.detect { |a, _b| a == collection[0] }
|
49
|
+
download_count = download_match ? download_match[1] : 0
|
50
|
+
collection_match = @top_collection_pages.detect { |a, _b| a == collection[0] }
|
51
|
+
collection_count = collection_match ? collection_match[1] : 0
|
52
|
+
csv << [document, collection[0], collection[1], download_count, collection_count]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
send_data csv_row, filename: "#{@start_date}-#{@end_date}-collections.csv"
|
56
|
+
end
|
57
|
+
# rubocop:enable Metrics/MethodLength
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module Admin
|
4
|
+
module Analytics
|
5
|
+
class WorkReportsController < AnalyticsController
|
6
|
+
include Hyrax::BreadcrumbsForWorksAnalytics
|
7
|
+
|
8
|
+
def index
|
9
|
+
return unless Hyrax.config.analytics?
|
10
|
+
|
11
|
+
@accessible_works ||= accessible_works
|
12
|
+
@accessible_file_sets ||= accessible_file_sets
|
13
|
+
@works_count = @accessible_works.count
|
14
|
+
@top_works = paginate(top_works_list, rows: 10)
|
15
|
+
@top_file_set_downloads = paginate(top_files_list, rows: 10)
|
16
|
+
|
17
|
+
if current_user.ability.admin?
|
18
|
+
@pageviews = Hyrax::Analytics.daily_events('work-view')
|
19
|
+
@downloads = Hyrax::Analytics.daily_events('file-set-download')
|
20
|
+
end
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
format.html
|
24
|
+
format.csv { export_data }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def show
|
29
|
+
@pageviews = Hyrax::Analytics.daily_events_for_id(@document.id, 'work-view')
|
30
|
+
@uniques = Hyrax::Analytics.unique_visitors_for_id(@document.id)
|
31
|
+
@downloads = Hyrax::Analytics.daily_events_for_id(@document.id, 'file_set_in_work_download')
|
32
|
+
@files = paginate(@document._source["file_set_ids_ssim"], rows: 5)
|
33
|
+
respond_to do |format|
|
34
|
+
format.html
|
35
|
+
format.csv { export_data }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def accessible_works
|
42
|
+
models = Hyrax.config.curation_concerns.map { |m| "\"#{m}\"" }
|
43
|
+
if current_user.ability.admin?
|
44
|
+
ActiveFedora::SolrService.query("has_model_ssim:(#{models.join(' OR ')})",
|
45
|
+
fl: 'title_tesim, id, member_of_collections',
|
46
|
+
rows: 50_000)
|
47
|
+
else
|
48
|
+
ActiveFedora::SolrService.query(
|
49
|
+
"edit_access_person_ssim:#{current_user} AND has_model_ssim:(#{models.join(' OR ')})",
|
50
|
+
fl: 'title_tesim, id, member_of_collections',
|
51
|
+
rows: 50_000
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def accessible_file_sets
|
57
|
+
if current_user.ability.admin?
|
58
|
+
ActiveFedora::SolrService.query(
|
59
|
+
"has_model_ssim:FileSet",
|
60
|
+
fl: 'title_tesim, id',
|
61
|
+
rows: 50_000
|
62
|
+
)
|
63
|
+
else
|
64
|
+
ActiveFedora::SolrService.query(
|
65
|
+
"edit_access_person_ssim:#{current_user} AND has_model_ssim:FileSet",
|
66
|
+
fl: 'title_tesim, id',
|
67
|
+
rows: 50_000
|
68
|
+
)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def top_analytics_works
|
73
|
+
@top_analytics_works ||= Hyrax::Analytics.top_events('work-view', date_range)
|
74
|
+
end
|
75
|
+
|
76
|
+
def top_analytics_downloads
|
77
|
+
@top_analytics_downloads ||= Hyrax::Analytics.top_events('file-set-in-work-download', date_range)
|
78
|
+
end
|
79
|
+
|
80
|
+
def top_analytics_file_sets
|
81
|
+
@top_analytics_file_sets ||= Hyrax::Analytics.top_events('file-set-download', date_range)
|
82
|
+
end
|
83
|
+
|
84
|
+
def top_works_list
|
85
|
+
list = []
|
86
|
+
top_analytics_works
|
87
|
+
top_analytics_downloads
|
88
|
+
@accessible_works.each do |doc|
|
89
|
+
views_match = @top_analytics_works.detect { |id, _count| id == doc["id"] }
|
90
|
+
@view_count = views_match ? views_match[1] : 0
|
91
|
+
downloads_match = @top_analytics_downloads.detect { |id, _count| id == doc["id"] }
|
92
|
+
@download_count = downloads_match ? downloads_match[1] : 0
|
93
|
+
list.push([doc["id"], doc["title_tesim"].join(''), @view_count, @download_count, doc["member_of_collections"]])
|
94
|
+
end
|
95
|
+
list.sort_by { |l| -l[2] }
|
96
|
+
end
|
97
|
+
|
98
|
+
def top_files_list
|
99
|
+
list = []
|
100
|
+
top_analytics_file_sets
|
101
|
+
@accessible_file_sets.each do |doc|
|
102
|
+
downloads_match = @top_analytics_file_sets.detect { |id, _count| id == doc["id"] }
|
103
|
+
@download_count = downloads_match ? downloads_match[1] : 0
|
104
|
+
list.push([doc["id"], doc["title_tesim"].join(''), @download_count]) if doc["title_tesim"].present?
|
105
|
+
end
|
106
|
+
list.sort_by { |l| -l[2] }
|
107
|
+
end
|
108
|
+
|
109
|
+
def export_data
|
110
|
+
data = top_works_list
|
111
|
+
csv_row = CSV.generate do |csv|
|
112
|
+
csv << ["Name", "ID", "Work Page Views", "Total Downloads of File Sets In Work", "Collections"]
|
113
|
+
data.each do |d|
|
114
|
+
csv << [d[0], d[1], d[2], d[3], d[4]]
|
115
|
+
end
|
116
|
+
end
|
117
|
+
send_data csv_row, filename: "#{params[:start_date]}-#{params[:end_date]}-works.csv"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -5,11 +5,11 @@ module Hyrax
|
|
5
5
|
load_and_authorize_resource class: 'Hyrax::PermissionTemplateAccess'
|
6
6
|
|
7
7
|
def destroy
|
8
|
+
authorize! :destroy, @permission_template_access
|
8
9
|
ActiveRecord::Base.transaction do
|
9
|
-
@permission_template_access.destroy
|
10
|
+
@permission_template_access.destroy
|
10
11
|
remove_access!
|
11
12
|
end
|
12
|
-
|
13
13
|
if @permission_template_access.destroyed?
|
14
14
|
after_destroy_success
|
15
15
|
else
|
@@ -19,38 +19,31 @@ module Hyrax
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
|
23
|
-
# because we don't want to prevent the ability to remove the whole
|
24
|
-
# PermissionTemplate and all of its associated PermissionTemplateAccesses
|
25
|
-
# @return [Boolean] true if it's valid
|
26
|
-
def valid_delete?
|
27
|
-
return true unless @permission_template_access.admin_group?
|
28
|
-
@permission_template_access.errors[:base] <<
|
29
|
-
t('hyrax.admin.admin_sets.form.permission_destroy_errors.admin_group')
|
30
|
-
false
|
31
|
-
end
|
32
|
-
|
33
|
-
def after_destroy_success
|
22
|
+
def after_destroy_error
|
34
23
|
if source.admin_set?
|
24
|
+
@permission_template_access.errors[:base] <<
|
25
|
+
t('hyrax.admin.admin_sets.form.permission_destroy_errors.participants')
|
35
26
|
redirect_to hyrax.edit_admin_admin_set_path(source_id,
|
36
27
|
anchor: 'participants'),
|
37
|
-
|
28
|
+
alert: @permission_template_access.errors.full_messages.to_sentence
|
38
29
|
else
|
30
|
+
@permission_template_access.errors[:base] <<
|
31
|
+
t('hyrax.dashboard.collections.form.permission_update_errors.sharing')
|
39
32
|
redirect_to hyrax.edit_dashboard_collection_path(source_id,
|
40
33
|
anchor: 'sharing'),
|
41
|
-
|
34
|
+
alert: @permission_template_access.errors.full_messages.to_sentence
|
42
35
|
end
|
43
36
|
end
|
44
37
|
|
45
|
-
def
|
38
|
+
def after_destroy_success
|
46
39
|
if source.admin_set?
|
47
40
|
redirect_to hyrax.edit_admin_admin_set_path(source_id,
|
48
41
|
anchor: 'participants'),
|
49
|
-
|
42
|
+
notice: translate('participants', scope: 'hyrax.admin.admin_sets.form.permission_update_notices')
|
50
43
|
else
|
51
44
|
redirect_to hyrax.edit_dashboard_collection_path(source_id,
|
52
45
|
anchor: 'sharing'),
|
53
|
-
|
46
|
+
notice: translate('sharing', scope: 'hyrax.dashboard.collections.form.permission_update_notices')
|
54
47
|
end
|
55
48
|
end
|
56
49
|
|