sufia 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +146 -0
- data/.travis.yml +4 -7
- data/Gemfile +2 -0
- data/History.md +29 -1
- data/README.md +25 -9
- data/SUFIA_VERSION +1 -1
- data/app/assets/stylesheets/sufia/_collections.scss +15 -0
- data/app/assets/stylesheets/sufia/_file-listing.scss +7 -0
- data/app/assets/stylesheets/sufia/_home-page.scss +10 -0
- data/app/builders/sufia/bootstrap_breadcrumbs_builder.rb +3 -5
- data/app/controllers/admin/stats_controller.rb +1 -76
- data/app/controllers/api/items_controller.rb +4 -6
- data/app/controllers/api/zotero_controller.rb +5 -5
- data/app/controllers/authorities_controller.rb +5 -1
- data/app/controllers/batch_edits_controller.rb +3 -3
- data/app/controllers/concerns/sufia/admin/depositor_stats.rb +41 -0
- data/app/controllers/concerns/sufia/admin/stats_behavior.rb +94 -0
- data/app/controllers/concerns/sufia/batch_controller_behavior.rb +16 -18
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +54 -56
- data/app/controllers/concerns/sufia/breadcrumbs.rb +3 -6
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +39 -39
- data/app/controllers/concerns/sufia/controller.rb +10 -10
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +17 -18
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +9 -12
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +6 -7
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +39 -40
- data/app/controllers/concerns/sufia/files_controller/upload_complete_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +109 -110
- data/app/controllers/concerns/sufia/homepage_controller.rb +8 -8
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +13 -10
- data/app/controllers/concerns/sufia/single_use_links_controller_behavior.rb +11 -14
- data/app/controllers/concerns/sufia/single_use_links_viewer_controller_behavior.rb +27 -21
- data/app/controllers/concerns/sufia/transfers_controller_behavior.rb +17 -17
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +54 -54
- data/app/controllers/contact_form_controller.rb +1 -1
- data/app/controllers/content_blocks_controller.rb +11 -12
- data/app/controllers/directory_controller.rb +2 -3
- data/app/controllers/featured_work_lists_controller.rb +1 -1
- data/app/controllers/featured_works_controller.rb +2 -4
- data/app/controllers/homepage_controller.rb +1 -2
- data/app/controllers/mailbox_controller.rb +12 -32
- data/app/controllers/my/collections_controller.rb +3 -4
- data/app/controllers/my/files_controller.rb +4 -6
- data/app/controllers/my/highlights_controller.rb +4 -6
- data/app/controllers/my/shares_controller.rb +3 -5
- data/app/controllers/pages_controller.rb +1 -3
- data/app/controllers/single_use_links_controller.rb +0 -1
- data/app/controllers/single_use_links_viewer_controller.rb +0 -1
- data/app/controllers/static_controller.rb +1 -0
- data/app/forms/sufia/forms/collection_edit_form.rb +2 -2
- data/app/helpers/batch_edits_helper.rb +1 -3
- data/app/helpers/content_block_helper.rb +7 -8
- data/app/helpers/generic_file_helper.rb +23 -24
- data/app/helpers/sufia/blacklight_override.rb +6 -7
- data/app/helpers/sufia/dashboard_helper_behavior.rb +4 -7
- data/app/helpers/sufia/permissions_helper.rb +3 -4
- data/app/helpers/sufia/sufia_helper_behavior.rb +30 -29
- data/app/helpers/trophy_helper.rb +15 -15
- data/app/inputs/select_with_modal_help_input.rb +3 -3
- data/app/inputs/with_help_icon.rb +4 -4
- data/app/jobs/content_delete_event_job.rb +0 -1
- data/app/jobs/content_depositor_change_event_job.rb +1 -2
- data/app/jobs/event_job.rb +0 -1
- data/app/jobs/user_unfollow_event_job.rb +1 -0
- data/app/models/concerns/sufia/solr_document_behavior.rb +1 -2
- data/app/models/contact_form.rb +6 -6
- data/app/models/content_block.rb +1 -2
- data/app/models/featured_work_list.rb +3 -5
- data/app/models/user_mailbox.rb +44 -0
- data/app/presenters/sufia/collection_presenter.rb +6 -8
- data/app/presenters/sufia/generic_file_presenter.rb +2 -2
- data/app/presenters/sufia/presenter_renderer.rb +2 -2
- data/app/presenters/sufia/version_list_presenter.rb +1 -1
- data/app/presenters/sufia/version_presenter.rb +3 -6
- data/app/search_builders/deposit_search_builder.rb +19 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +1 -2
- data/app/search_builders/sufia/search_builder.rb +1 -3
- data/app/uploaders/tinymce_asset_uploader.rb +0 -2
- data/app/views/_controls.html.erb +5 -5
- data/app/views/admin/stats/_deposits.html.erb +19 -0
- data/app/views/admin/stats/index.html.erb +2 -0
- data/app/views/batch_edits/edit.html.erb +2 -2
- data/app/views/collections/_edit_actions.html.erb +3 -3
- data/app/views/collections/_form_for_select_collection.html.erb +2 -2
- data/app/views/collections/_sort_and_per_page.html.erb +12 -9
- data/app/views/collections/_view_type_group.html.erb +1 -1
- data/app/views/collections/edit.html.erb +5 -5
- data/app/views/collections/show.html.erb +7 -6
- data/app/views/homepage/_announcement.html.erb +5 -0
- data/app/views/homepage/_home.html.erb +1 -0
- data/app/views/my/_sort_and_per_page.html.erb +14 -10
- data/app/views/my/index.html.erb +1 -1
- data/app/views/pages/show.html.erb +0 -2
- data/app/views/single_use_links/new_download.html.erb +1 -1
- data/app/views/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +2 -2
- data/config/initializers/simple_form.rb +1 -1
- data/config/initializers/simple_form_bootstrap.rb +1 -1
- data/config/locales/sufia.en.yml +4 -0
- data/config/routes.rb +2 -3
- data/lib/generators/sufia/admin_stat_generator.rb +0 -3
- data/lib/generators/sufia/install_generator.rb +8 -9
- data/lib/generators/sufia/templates/catalog_controller.rb +2 -3
- data/lib/generators/sufia/templates/config/action_dispatch_http_upload_monkey_patch.rb +1 -0
- data/lib/generators/sufia/upgrade400_generator.rb +9 -9
- data/lib/generators/sufia/upgrade600_generator.rb +1 -4
- data/lib/sufia.rb +2 -2
- data/lib/sufia/arkivo/actor.rb +1 -1
- data/lib/sufia/arkivo/create_subscription_job.rb +30 -30
- data/lib/sufia/arkivo/metadata_munger.rb +7 -7
- data/lib/sufia/arkivo/schema_validator.rb +1 -1
- data/lib/sufia/single_use_error.rb +0 -1
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero/config.rb +13 -13
- data/spec/actors/generic_file/actor_spec.rb +17 -18
- data/spec/controllers/admin_stats_controller_spec.rb +56 -5
- data/spec/controllers/api/zotero_controller_spec.rb +10 -9
- data/spec/controllers/authorities_controller_spec.rb +8 -8
- data/spec/controllers/batch_controller_spec.rb +19 -20
- data/spec/controllers/batch_edits_controller_spec.rb +8 -9
- data/spec/controllers/catalog_controller_spec.rb +7 -9
- data/spec/controllers/collections_controller_spec.rb +30 -32
- data/spec/controllers/content_blocks_controller_spec.rb +4 -4
- data/spec/controllers/dashboard_controller_spec.rb +12 -12
- data/spec/controllers/depositors_controller_spec.rb +8 -8
- data/spec/controllers/downloads_controller_spec.rb +10 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +4 -4
- data/spec/controllers/featured_works_controller_spec.rb +11 -12
- data/spec/controllers/generic_files_controller_spec.rb +154 -125
- data/spec/controllers/homepage_controller_spec.rb +22 -15
- data/spec/controllers/mailbox_controller_spec.rb +20 -36
- data/spec/controllers/my/collections_controller_spec.rb +4 -5
- data/spec/controllers/my/files_controller_spec.rb +10 -11
- data/spec/controllers/my/highlights_controller_spec.rb +4 -5
- data/spec/controllers/my/shares_controller_spec.rb +12 -14
- data/spec/controllers/my_controller_spec.rb +1 -3
- data/spec/controllers/pages_controller_spec.rb +4 -4
- data/spec/controllers/single_use_links_controller_spec.rb +1 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -2
- data/spec/controllers/static_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +8 -9
- data/spec/controllers/transfers_controller_spec.rb +19 -19
- data/spec/controllers/users_controller_spec.rb +33 -35
- data/spec/factories/api_items.rb +2 -2
- data/spec/factories/content_blocks.rb +1 -1
- data/spec/factories/featured_works.rb +1 -1
- data/spec/factories/generic_files.rb +3 -3
- data/spec/factories/users.rb +7 -8
- data/spec/features/browse_dashboard_files_spec.rb +14 -18
- data/spec/features/browse_files_spec.rb +3 -4
- data/spec/features/catalog_search_spec.rb +3 -5
- data/spec/features/cloud_upload_spec.rb +2 -2
- data/spec/features/collection_spec.rb +21 -21
- data/spec/features/contact_form_spec.rb +10 -11
- data/spec/features/display_dashboard_spec.rb +5 -9
- data/spec/features/edit_file_spec.rb +8 -9
- data/spec/features/featured_item_spec.rb +1 -1
- data/spec/features/ingest_upload_files_spec.rb +5 -5
- data/spec/features/notifications_spec.rb +2 -6
- data/spec/features/ownership_transfer_spec.rb +2 -2
- data/spec/features/proxy_spec.rb +2 -2
- data/spec/features/search_spec.rb +3 -4
- data/spec/features/single_use_links_spec.rb +1 -1
- data/spec/features/users_spec.rb +4 -5
- data/spec/forms/collection_edit_form_spec.rb +2 -2
- data/spec/forms/generic_file_edit_form_spec.rb +6 -7
- data/spec/helpers/batch_edits_helper_spec.rb +9 -13
- data/spec/helpers/content_block_helper_spec.rb +3 -3
- data/spec/helpers/dashboard_helper_spec.rb +19 -24
- data/spec/helpers/generic_file_helper_spec.rb +5 -7
- data/spec/helpers/sufia_helper_spec.rb +43 -54
- data/spec/helpers/trophy_helper_spec.rb +5 -5
- data/spec/inputs/multi_value_with_help_input_spec.rb +1 -2
- data/spec/inputs/select_with_help_input_spec.rb +19 -15
- data/spec/javascripts/jasmine_spec.rb +4 -5
- data/spec/javascripts/support/jasmine_helper.rb +9 -9
- data/spec/jobs/active_fedora_id_based_job_spec.rb +7 -5
- data/spec/jobs/audit_job_spec.rb +7 -7
- data/spec/jobs/batch_update_job_spec.rb +5 -6
- data/spec/jobs/characterize_job_spec.rb +1 -1
- data/spec/jobs/content_depositor_change_event_job_spec.rb +1 -1
- data/spec/jobs/create_derivatives_job_spec.rb +5 -5
- data/spec/jobs/event_jobs_spec.rb +16 -16
- data/spec/jobs/import_url_job_spec.rb +36 -5
- data/spec/jobs/ingest_local_file_job_spec.rb +31 -20
- data/spec/jobs/sufia_resque_queue_spec.rb +1 -1
- data/spec/lib/sufia/analytics_spec.rb +0 -1
- data/spec/lib/sufia/arkivo/actor_spec.rb +6 -6
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +18 -18
- data/spec/lib/sufia/breadcrumbs_spec.rb +5 -6
- data/spec/lib/sufia/messages_spec.rb +11 -12
- data/spec/lib/sufia/readable_permissions_spec.rb +8 -10
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +6 -7
- data/spec/lib/sufia/user_stat_importer_spec.rb +30 -33
- data/spec/lib/sufia/writable_permissions_spec.rb +1 -3
- data/spec/lib/sufia/zotero/config_spec.rb +4 -6
- data/spec/models/ability_spec.rb +11 -9
- data/spec/models/batch_spec.rb +13 -13
- data/spec/models/characterization_spec.rb +2 -3
- data/spec/models/checksum_audit_log_spec.rb +18 -19
- data/spec/models/collection_spec.rb +11 -12
- data/spec/models/content_block_spec.rb +33 -22
- data/spec/models/download_spec.rb +3 -5
- data/spec/models/featured_work_list_spec.rb +3 -3
- data/spec/models/featured_work_spec.rb +12 -14
- data/spec/models/file_content_datastream_spec.rb +9 -7
- data/spec/models/file_download_stat_spec.rb +34 -40
- data/spec/models/file_usage_spec.rb +46 -52
- data/spec/models/file_view_stat_spec.rb +35 -41
- data/spec/models/fits_datastream_spec.rb +23 -25
- data/spec/models/generic_file/visibility_spec.rb +10 -5
- data/spec/models/generic_file_spec.rb +86 -88
- data/spec/models/geo_names_resource_spec.rb +3 -5
- data/spec/models/local_authority_spec.rb +30 -33
- data/spec/models/pageview_spec.rb +3 -3
- data/spec/models/proxy_deposit_request_spec.rb +3 -3
- data/spec/models/single_use_link_spec.rb +36 -36
- data/spec/models/solr_document_spec.rb +3 -6
- data/spec/models/trophy_spec.rb +8 -9
- data/spec/models/user_mailbox_spec.rb +62 -0
- data/spec/models/user_spec.rb +28 -29
- data/spec/presenters/presenter_renderer_spec.rb +1 -1
- data/spec/presenters/sufia/generic_file_presenter_spec.rb +5 -5
- data/spec/presenters/sufia/version_list_presenter_spec.rb +2 -2
- data/spec/presenters/sufia/version_presenter_spec.rb +1 -1
- data/spec/routing/featured_works_route_spec.rb +4 -4
- data/spec/routing/ownership_transfers_route_spec.rb +1 -1
- data/spec/routing/route_spec.rb +89 -89
- data/spec/services/generic_file_audit_service_spec.rb +8 -8
- data/spec/services/repository_audit_service_spec.rb +7 -3
- data/spec/spec_helper.rb +5 -4
- data/spec/support/features/session_helpers.rb +1 -1
- data/spec/support/input_support.rb +1 -2
- data/spec/support/rake.rb +1 -1
- data/spec/support/selectors.rb +1 -6
- data/spec/support/statistic_helper.rb +1 -1
- data/spec/support/uploaded_file_monkeypatch.rb +1 -1
- data/spec/tasks/rake_spec.rb +3 -5
- data/spec/views/admin/stats/index.html.erb_spec.rb +16 -16
- data/spec/views/batch/edit.html.erb_spec.rb +1 -3
- data/spec/views/batch_edits/check_all_spec.rb +5 -5
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -3
- data/spec/views/catalog/index.html.erb_spec.rb +1 -3
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +4 -5
- data/spec/views/collections/_form.html.erb_spec.rb +5 -3
- data/spec/views/collections/_show_descriptions.html.erb_spec.rb +7 -8
- data/spec/views/collections/_show_document_list.erb_spec.rb +4 -6
- data/spec/views/dashboard/index_spec.rb +14 -21
- data/spec/views/generic_file/_browse_everything.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/_permission_form.html.erb_spec.rb +8 -9
- data/spec/views/generic_file/edit.html.erb_spec.rb +7 -7
- data/spec/views/generic_file/show.html.erb_spec.rb +24 -25
- data/spec/views/generic_file/stats.html.erb_spec.rb +19 -19
- data/spec/views/homepage/_announcement.html.erb_spec.rb +51 -0
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +5 -9
- data/spec/views/homepage/_home_header.html.erb_spec.rb +2 -2
- data/spec/views/my/facet.html.erb_spec.rb +4 -4
- data/spec/views/single_use_links/new_download.html.erb_spec.rb +28 -0
- data/spec/views/single_use_links_viewer/show.html.erb_spec.rb +29 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +7 -8
- data/spec/views/users/_following_modal.html.erb_spec.rb +4 -5
- data/spec/views/users/_notify_number.html.erb_spec.rb +2 -5
- data/spec/views/users/_user_util_links.html.erb_spec.rb +5 -8
- data/spec/views/users/index.html.erb_spec.rb +4 -6
- data/spec/views/users/show.html.erb_spec.rb +4 -7
- data/tasks/sufia-dev.rake +19 -3
- metadata +20 -5
|
@@ -4,9 +4,9 @@ module API
|
|
|
4
4
|
# Zotero parlance is mapped to a GenericFile in Sufia.
|
|
5
5
|
class ItemsController < ApplicationController
|
|
6
6
|
skip_before_action :verify_authenticity_token
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
before_action :validate_item, only: [:create, :update]
|
|
8
|
+
before_action :authorize_token
|
|
9
|
+
before_action :my_load_and_authorize_resource, only: [:update, :destroy, :show]
|
|
10
10
|
|
|
11
11
|
attr_reader :item
|
|
12
12
|
|
|
@@ -66,9 +66,7 @@ module API
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
def authorize_token
|
|
69
|
-
unless valid_token?
|
|
70
|
-
return render plain: "invalid user token: #{token}", status: :unauthorized
|
|
71
|
-
end
|
|
69
|
+
render plain: "invalid user token: #{token}", status: :unauthorized unless valid_token?
|
|
72
70
|
end
|
|
73
71
|
|
|
74
72
|
def valid_token?
|
|
@@ -3,22 +3,22 @@ require 'oauth'
|
|
|
3
3
|
module API
|
|
4
4
|
# Adds the ability to authenticate against Zotero's OAuth endpoint
|
|
5
5
|
class ZoteroController < ApplicationController
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
before_action :authenticate_user!
|
|
7
|
+
before_action :authorize_user!
|
|
8
|
+
before_action :validate_params, only: :callback
|
|
9
9
|
|
|
10
10
|
def initiate
|
|
11
11
|
request_token = client.get_request_token(oauth_callback: callback_url)
|
|
12
12
|
session[:request_token] = request_token
|
|
13
13
|
current_user.zotero_token = request_token
|
|
14
14
|
current_user.save
|
|
15
|
-
redirect_to request_token.authorize_url(
|
|
15
|
+
redirect_to request_token.authorize_url(identity: '1', oauth_callback: callback_url)
|
|
16
16
|
rescue OAuth::Unauthorized
|
|
17
17
|
redirect_to root_url, alert: 'Invalid Zotero client key pair'
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def callback
|
|
21
|
-
access_token = current_token.get_access_token(
|
|
21
|
+
access_token = current_token.get_access_token(oauth_verifier: params['oauth_verifier'])
|
|
22
22
|
# parse userID and API key out of token and store in user instance
|
|
23
23
|
current_user.zotero_userid = access_token.params[:userID]
|
|
24
24
|
current_user.save
|
|
@@ -8,7 +8,11 @@ class AuthoritiesController < ApplicationController
|
|
|
8
8
|
if params[:term] == "location"
|
|
9
9
|
GeoNamesResource.find_location(s)
|
|
10
10
|
else
|
|
11
|
-
|
|
11
|
+
begin
|
|
12
|
+
LocalAuthority.entries_by_term(params[:model], params[:term], s)
|
|
13
|
+
rescue
|
|
14
|
+
[]
|
|
15
|
+
end
|
|
12
16
|
end
|
|
13
17
|
render json: hits
|
|
14
18
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class BatchEditsController < ApplicationController
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
include Hydra::BatchEditBehavior
|
|
3
|
+
include GenericFileHelper
|
|
4
|
+
include Sufia::BatchEditsControllerBehavior
|
|
5
5
|
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Module to gather information about the deposits in the system
|
|
2
|
+
#
|
|
3
|
+
module Sufia::Admin::DepositorStats
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
# we are using blacklight facet queries for some of our searches so we have to include them when we are included
|
|
7
|
+
included do
|
|
8
|
+
include Blacklight::Base
|
|
9
|
+
copy_blacklight_config_from(CatalogController)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Gather information about the depositors in the system
|
|
13
|
+
#
|
|
14
|
+
# @param [Hash] deposit_stats
|
|
15
|
+
# @option deposit_stats [String] :start_date optional string to specify the start date to gather the stats from
|
|
16
|
+
# @option deposit_stats [String] :end_date optional string to specify the end date to gather the stats from
|
|
17
|
+
#
|
|
18
|
+
def depositors(deposit_stats)
|
|
19
|
+
start_datetime = DateTime.parse(deposit_stats[:start_date]) unless deposit_stats[:start_date].blank?
|
|
20
|
+
end_datetime = DateTime.parse(deposit_stats[:end_date]).end_of_day unless deposit_stats[:end_date].blank?
|
|
21
|
+
|
|
22
|
+
query = GenericFile.build_date_query(start_datetime, end_datetime) unless start_datetime.blank?
|
|
23
|
+
sb = DepositSearchBuilder.new([:include_depositor_facet], self)
|
|
24
|
+
facet_results = repository.search(sb.merge(q: query).query)
|
|
25
|
+
facets = facet_results["facet_counts"]["facet_fields"]["depositor_ssim"]
|
|
26
|
+
depositors = []
|
|
27
|
+
|
|
28
|
+
# facet results come back in an array where the first item is the user and the second item is the count
|
|
29
|
+
# [ abc123, 55, ccczzz, 205 ]
|
|
30
|
+
# in the loop we are stepping through the array by twos to get the entire pair
|
|
31
|
+
# The item at i is the key and the item at i+1 is the number of files
|
|
32
|
+
(0...facets.length).step(2).each do |i|
|
|
33
|
+
depositor = {}
|
|
34
|
+
depositor[:key] = facets[i]
|
|
35
|
+
depositor[:deposits] = facets[i + 1]
|
|
36
|
+
depositor[:user] = User.find_by_user_key(depositor[:key])
|
|
37
|
+
depositors << depositor
|
|
38
|
+
end
|
|
39
|
+
depositors
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
module Sufia
|
|
2
|
+
module Admin
|
|
3
|
+
module StatsBehavior
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
included do
|
|
7
|
+
include Sufia::Admin::DepositorStats
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def index
|
|
11
|
+
# total user count
|
|
12
|
+
@users_count = ::User.count
|
|
13
|
+
|
|
14
|
+
# The most recent users to join
|
|
15
|
+
@users_stats = params.fetch(:users_stats, {})
|
|
16
|
+
@recent_users = recent_users
|
|
17
|
+
|
|
18
|
+
# Query Solr for top depositors
|
|
19
|
+
@active_users = top_depositors
|
|
20
|
+
|
|
21
|
+
# Count of documents by permissions
|
|
22
|
+
@files_count = document_by_permission
|
|
23
|
+
|
|
24
|
+
# Query Solr for top file formats
|
|
25
|
+
@top_formats = top_formats
|
|
26
|
+
|
|
27
|
+
@deposit_stats = params.fetch(:deposit_stats, {})
|
|
28
|
+
@depositors = depositors(@deposit_stats)
|
|
29
|
+
render 'index'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def top_depositors_count
|
|
35
|
+
count = params[:dep_count].to_i
|
|
36
|
+
count.in?(5..20) ? count : 5
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def document_by_permission
|
|
40
|
+
return document_by_date_by_permission if @users_stats[:file_start_date]
|
|
41
|
+
|
|
42
|
+
files_count = {}
|
|
43
|
+
files_count[:total] = ::GenericFile.count
|
|
44
|
+
files_count[:public] = ::GenericFile.where_public.count
|
|
45
|
+
files_count[:registered] = ::GenericFile.where_registered.count
|
|
46
|
+
files_count[:private] = files_count[:total] - (files_count[:registered] + files_count[:public])
|
|
47
|
+
files_count
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def document_by_date_by_permission
|
|
51
|
+
start_date = DateTime.parse(@users_stats[:file_start_date])
|
|
52
|
+
end_date = DateTime.parse(@users_stats[:file_end_date]).end_of_day unless @users_stats[:file_end_date].blank?
|
|
53
|
+
files_count = {}
|
|
54
|
+
files_count[:total] = ::GenericFile.find_by_date_created(start_date, end_date).count
|
|
55
|
+
files_count[:public] = ::GenericFile.find_by_date_created(start_date, end_date).merge(::GenericFile.where_public).count
|
|
56
|
+
files_count[:registered] = ::GenericFile.find_by_date_created(start_date, end_date).merge(::GenericFile.where_registered).count
|
|
57
|
+
files_count[:private] = files_count[:total] - (files_count[:registered] + files_count[:public])
|
|
58
|
+
files_count
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def top_depositors
|
|
62
|
+
depositor_key = Solrizer.solr_name('depositor', :stored_searchable, type: :string)
|
|
63
|
+
top_data(depositor_key, top_depositors_count)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def top_formats
|
|
67
|
+
format_key = Solrizer.solr_name('file_format', Solrizer::Descriptor.new(:string, :indexed, :multivalued))
|
|
68
|
+
top_data(format_key, 5)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def top_data(key, limit)
|
|
72
|
+
query_url = "#{ActiveFedora.solr_config[:url]}/terms?terms.fl=#{key}&terms.sort=count&terms.limit=#{limit}&wt=json&omitHeader=true"
|
|
73
|
+
# Parse JSON response (looks like {"terms":{"depositor_tesim":["mjg36",3]}} for depositor)
|
|
74
|
+
json = open(query_url).read
|
|
75
|
+
begin
|
|
76
|
+
tuples = JSON.parse(json)['terms'][key]
|
|
77
|
+
rescue
|
|
78
|
+
[]
|
|
79
|
+
end
|
|
80
|
+
# Change to hash where keys = logins and values = counts
|
|
81
|
+
Hash[*tuples]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def recent_users
|
|
85
|
+
# no dates return the top 5
|
|
86
|
+
return ::User.order('created_at DESC').limit(5) if @users_stats[:start_date].blank?
|
|
87
|
+
|
|
88
|
+
start_date = DateTime.parse @users_stats[:start_date]
|
|
89
|
+
end_date = DateTime.parse(@users_stats[:end_date]).end_of_day unless @users_stats[:end_date].blank?
|
|
90
|
+
::User.recent_users start_date, end_date
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
@@ -3,13 +3,13 @@ module Sufia
|
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
include Hydra::Controller::ControllerBehavior
|
|
5
5
|
|
|
6
|
-
included do
|
|
6
|
+
included do
|
|
7
7
|
layout "sufia-one-column"
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
before_action :has_access?
|
|
10
10
|
ActiveSupport::Deprecation.deprecate_methods(BatchController, :initialize_fields)
|
|
11
11
|
class_attribute :edit_form_class
|
|
12
|
-
self.edit_form_class = Sufia::Forms::BatchEditForm
|
|
12
|
+
self.edit_form_class = Sufia::Forms::BatchEditForm
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def edit
|
|
@@ -34,22 +34,20 @@ module Sufia
|
|
|
34
34
|
|
|
35
35
|
protected
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
|
43
|
-
def initialize_fields(file)
|
|
44
|
-
file.initialize_fields
|
|
45
|
-
end
|
|
37
|
+
def edit_form
|
|
38
|
+
generic_file = ::GenericFile.new(creator: [current_user.name], title: @batch.generic_files.map(&:label))
|
|
39
|
+
edit_form_class.new(generic_file)
|
|
40
|
+
end
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
file
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
end
|
|
42
|
+
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
|
43
|
+
def initialize_fields(file)
|
|
44
|
+
file.initialize_fields
|
|
45
|
+
end
|
|
52
46
|
|
|
47
|
+
def uploading_on_behalf_of?(batch)
|
|
48
|
+
file = batch.generic_files.first
|
|
49
|
+
return false if file.nil? || file.on_behalf_of.blank?
|
|
50
|
+
current_user.user_key != file.on_behalf_of
|
|
51
|
+
end
|
|
53
52
|
end
|
|
54
53
|
end
|
|
55
|
-
|
|
@@ -5,37 +5,36 @@ module Sufia
|
|
|
5
5
|
|
|
6
6
|
included do
|
|
7
7
|
layout "sufia-one-column"
|
|
8
|
-
|
|
8
|
+
before_action :build_breadcrumbs, only: :edit
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def edit
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
12
|
+
super
|
|
13
|
+
@generic_file = ::GenericFile.new
|
|
14
|
+
@generic_file.depositor = current_user.user_key
|
|
15
|
+
@terms = terms - [:title, :format, :resource_type]
|
|
16
|
+
|
|
17
|
+
h = {}
|
|
18
|
+
@names = []
|
|
19
|
+
permissions = []
|
|
20
|
+
|
|
21
|
+
# For each of the files in the batch, set the attributes to be the concatination of all the attributes
|
|
22
|
+
batch.each do |doc_id|
|
|
23
|
+
gf = ::GenericFile.load_instance_from_solr(doc_id)
|
|
24
|
+
terms.each do |key|
|
|
25
|
+
h[key] ||= []
|
|
26
|
+
h[key] = (h[key] + gf.send(key)).uniq
|
|
27
|
+
end
|
|
28
|
+
@names << gf.to_s
|
|
29
|
+
permissions = (permissions + gf.permissions).uniq
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
initialize_fields(h, @generic_file)
|
|
33
|
+
|
|
34
|
+
@generic_file.permissions_attributes = [{ type: 'group', name: 'public', access: 'read' }]
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def after_update
|
|
38
|
-
|
|
39
38
|
respond_to do |format|
|
|
40
39
|
format.json { head :no_content }
|
|
41
40
|
format.html { redirect_to_return_controller }
|
|
@@ -54,47 +53,46 @@ module Sufia
|
|
|
54
53
|
|
|
55
54
|
def update
|
|
56
55
|
case params["update_type"]
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
when "update"
|
|
57
|
+
super
|
|
58
|
+
when "delete_all"
|
|
59
|
+
destroy_batch
|
|
61
60
|
end
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
protected
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
def destroy_batch
|
|
66
|
+
batch.each do |doc_id|
|
|
67
|
+
gf = ::GenericFile.find(doc_id)
|
|
68
|
+
gf.destroy
|
|
69
|
+
end
|
|
70
|
+
after_update
|
|
70
71
|
end
|
|
71
|
-
after_update
|
|
72
|
-
end
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def terms
|
|
83
|
-
Forms::BatchEditForm.terms
|
|
84
|
-
end
|
|
73
|
+
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
|
74
|
+
def initialize_fields(attributes, file)
|
|
75
|
+
terms.each do |key|
|
|
76
|
+
# if value is empty, we create an one element array to loop over for output
|
|
77
|
+
file[key] = attributes[key].empty? ? [''] : attributes[key]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
end
|
|
81
|
+
def terms
|
|
82
|
+
Forms::BatchEditForm.terms
|
|
83
|
+
end
|
|
90
84
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
else
|
|
95
|
-
redirect_to sufia.dashboard_index_path
|
|
85
|
+
def generic_file_params
|
|
86
|
+
file_params = params[:generic_file] || ActionController::Parameters.new
|
|
87
|
+
Forms::BatchEditForm.model_attributes(file_params)
|
|
96
88
|
end
|
|
97
|
-
end
|
|
98
89
|
|
|
90
|
+
def redirect_to_return_controller
|
|
91
|
+
if params[:return_controller]
|
|
92
|
+
redirect_to sufia.url_for(controller: params[:return_controller], only_path: true)
|
|
93
|
+
else
|
|
94
|
+
redirect_to sufia.dashboard_index_path
|
|
95
|
+
end
|
|
96
|
+
end
|
|
99
97
|
end
|
|
100
98
|
end
|
|
@@ -11,9 +11,7 @@ module Sufia
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def default_trail
|
|
14
|
-
if user_signed_in?
|
|
15
|
-
add_breadcrumb I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path
|
|
16
|
-
end
|
|
14
|
+
add_breadcrumb I18n.t('sufia.dashboard.title'), sufia.dashboard_index_path if user_signed_in?
|
|
17
15
|
end
|
|
18
16
|
|
|
19
17
|
def trail_from_referer
|
|
@@ -37,9 +35,8 @@ module Sufia
|
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
def add_breadcrumb_for_action
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
end
|
|
38
|
+
return unless /edit|stats/ =~ action_name && controller_name == "generic_files"
|
|
39
|
+
add_breadcrumb I18n.t("sufia.generic_file.browse_view"), sufia.generic_file_path(params["id"])
|
|
43
40
|
end
|
|
44
41
|
end
|
|
45
42
|
end
|
|
@@ -6,9 +6,9 @@ module Sufia
|
|
|
6
6
|
included do
|
|
7
7
|
include Sufia::Breadcrumbs
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
before_action :filter_docs_with_read_access!, except: :show
|
|
10
|
+
before_action :has_access?, except: :show
|
|
11
|
+
before_action :build_breadcrumbs, only: [:edit, :show]
|
|
12
12
|
|
|
13
13
|
self.search_params_logic += [:add_access_controls_to_solr_params, :add_advanced_parse_q_to_solr]
|
|
14
14
|
|
|
@@ -32,50 +32,50 @@ module Sufia
|
|
|
32
32
|
|
|
33
33
|
protected
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
def presenter
|
|
36
|
+
@presenter ||= presenter_class.new(@collection)
|
|
37
|
+
end
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
def presenter_class
|
|
40
|
+
Sufia::CollectionPresenter
|
|
41
|
+
end
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
def collection_member_search_builder_class
|
|
44
|
+
::SearchBuilder
|
|
45
|
+
end
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
def collection_params
|
|
48
|
+
form_class.model_attributes(
|
|
49
|
+
params.require(:collection).permit(:title, :description, :members, part_of: [],
|
|
50
|
+
contributor: [], creator: [], publisher: [], date_created: [], subject: [],
|
|
51
|
+
language: [], rights: [], resource_type: [], identifier: [], based_near: [],
|
|
52
|
+
tag: [], related_url: [])
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
def query_collection_members
|
|
57
|
+
flash[:notice] = nil if flash[:notice] == "Select something first"
|
|
58
|
+
params[:q] = params[:cq]
|
|
59
|
+
super
|
|
60
|
+
end
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
def after_destroy(id)
|
|
63
|
+
respond_to do |format|
|
|
64
|
+
format.html { redirect_to sufia.dashboard_collections_path, notice: 'Collection was successfully deleted.' }
|
|
65
|
+
format.json { render json: { id: id }, status: :destroyed, location: @collection }
|
|
66
|
+
end
|
|
66
67
|
end
|
|
67
|
-
end
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
def form
|
|
70
|
+
@form ||= form_class.new(@collection)
|
|
71
|
+
end
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
def form_class
|
|
74
|
+
Sufia::Forms::CollectionEditForm
|
|
75
|
+
end
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
def _prefixes
|
|
78
|
+
@_prefixes ||= super + ['catalog']
|
|
79
|
+
end
|
|
80
80
|
end
|
|
81
81
|
end
|