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
|
@@ -18,18 +18,18 @@ module Sufia::HomepageController
|
|
|
18
18
|
@featured_researcher ||= ContentBlock.create(name: ContentBlock::RESEARCHER)
|
|
19
19
|
@marketing_text = ContentBlock.find_or_create_by(name: ContentBlock::MARKETING)
|
|
20
20
|
@featured_work_list = FeaturedWorkList.new
|
|
21
|
+
@announcement_text = ContentBlock.find_or_create_by(name: ContentBlock::ANNOUNCEMENT)
|
|
21
22
|
recent
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
protected
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def sort_field
|
|
32
|
-
"#{Solrizer.solr_name('system_create', :stored_sortable, type: :date)} desc"
|
|
33
|
-
end
|
|
27
|
+
def recent
|
|
28
|
+
# grab any recent documents
|
|
29
|
+
(_, @recent_documents) = search_results({ q: '', sort: sort_field, rows: 4 }, search_params_logic)
|
|
30
|
+
end
|
|
34
31
|
|
|
32
|
+
def sort_field
|
|
33
|
+
"#{Solrizer.solr_name('system_create', :stored_sortable, type: :date)} desc"
|
|
34
|
+
end
|
|
35
35
|
end
|
|
@@ -10,13 +10,13 @@ module Sufia
|
|
|
10
10
|
included do
|
|
11
11
|
include Blacklight::Configurable
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
copy_blacklight_config_from(CatalogController)
|
|
14
|
+
blacklight_config.search_builder_class = Sufia::MySearchBuilder
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
before_action :authenticate_user!
|
|
17
|
+
before_action :enforce_show_permissions, only: :show
|
|
18
|
+
before_action :enforce_viewing_context_for_show_requests, only: :show
|
|
19
|
+
before_action :find_collections_with_edit_access, only: :index
|
|
20
20
|
|
|
21
21
|
self.search_params_logic += [:add_access_controls_to_solr_params, :add_advanced_parse_q_to_solr]
|
|
22
22
|
|
|
@@ -33,12 +33,16 @@ module Sufia
|
|
|
33
33
|
(@response, @document_list) = search_results(params, search_params_logic)
|
|
34
34
|
@user = current_user
|
|
35
35
|
@events = @user.events(100)
|
|
36
|
-
@last_event_timestamp =
|
|
36
|
+
@last_event_timestamp = begin
|
|
37
|
+
@user.events.first[:timestamp].to_i || 0
|
|
38
|
+
rescue
|
|
39
|
+
0
|
|
40
|
+
end
|
|
37
41
|
@filters = params[:f] || []
|
|
38
42
|
|
|
39
43
|
# set up some parameters for allowing the batch controls to show appropiately
|
|
40
44
|
@max_batch_size = 80
|
|
41
|
-
count_on_page = @document_list.count {|doc| batch.index(doc.id)}
|
|
45
|
+
count_on_page = @document_list.count { |doc| batch.index(doc.id) }
|
|
42
46
|
@disable_select_all = @document_list.count > @max_batch_size
|
|
43
47
|
batch_size = batch.uniq.size
|
|
44
48
|
@result_set_size = @response.response["numFound"]
|
|
@@ -49,11 +53,10 @@ module Sufia
|
|
|
49
53
|
@batch_part_on_other_page = (@batch_size_on_other_page) > 0
|
|
50
54
|
|
|
51
55
|
respond_to do |format|
|
|
52
|
-
format.html {
|
|
56
|
+
format.html {}
|
|
53
57
|
format.rss { render layout: false }
|
|
54
58
|
format.atom { render layout: false }
|
|
55
59
|
end
|
|
56
60
|
end
|
|
57
|
-
|
|
58
61
|
end
|
|
59
62
|
end
|
|
@@ -2,19 +2,17 @@ module Sufia
|
|
|
2
2
|
module SingleUseLinksControllerBehavior
|
|
3
3
|
extend ActiveSupport::Concern
|
|
4
4
|
included do
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
before_filter :authorize_user!
|
|
5
|
+
before_action :authenticate_user!
|
|
6
|
+
before_action :authorize_user!
|
|
8
7
|
# Catch permission errors
|
|
9
8
|
rescue_from Hydra::AccessDenied, CanCan::AccessDenied do |exception|
|
|
10
|
-
if current_user
|
|
9
|
+
if current_user && current_user.persisted?
|
|
11
10
|
redirect_to root_url, alert: "You do not have sufficient privileges to create links to this document"
|
|
12
11
|
else
|
|
13
12
|
session["user_return_to"] = request.url
|
|
14
13
|
redirect_to new_user_session_url, alert: exception.message
|
|
15
14
|
end
|
|
16
15
|
end
|
|
17
|
-
|
|
18
16
|
end
|
|
19
17
|
|
|
20
18
|
def new_download
|
|
@@ -23,7 +21,7 @@ module Sufia
|
|
|
23
21
|
|
|
24
22
|
respond_to do |format|
|
|
25
23
|
format.html
|
|
26
|
-
format.js
|
|
24
|
+
format.js { render js: @link }
|
|
27
25
|
end
|
|
28
26
|
end
|
|
29
27
|
|
|
@@ -33,19 +31,18 @@ module Sufia
|
|
|
33
31
|
|
|
34
32
|
respond_to do |format|
|
|
35
33
|
format.html
|
|
36
|
-
format.js
|
|
34
|
+
format.js { render js: @link }
|
|
37
35
|
end
|
|
38
36
|
end
|
|
39
37
|
|
|
40
|
-
|
|
41
38
|
protected
|
|
42
|
-
def authorize_user!
|
|
43
|
-
authorize! :edit, asset
|
|
44
|
-
end
|
|
45
39
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
def authorize_user!
|
|
41
|
+
authorize! :edit, asset
|
|
42
|
+
end
|
|
49
43
|
|
|
44
|
+
def asset
|
|
45
|
+
@asset ||= ActiveFedora::Base.load_instance_from_solr(params[:id])
|
|
46
|
+
end
|
|
50
47
|
end
|
|
51
48
|
end
|
|
@@ -5,7 +5,7 @@ module Sufia
|
|
|
5
5
|
extend ActiveSupport::Concern
|
|
6
6
|
include Sufia::DownloadsControllerBehavior
|
|
7
7
|
included do
|
|
8
|
-
|
|
8
|
+
skip_before_action :load_file, except: :download
|
|
9
9
|
rescue_from Sufia::SingleUseError, with: :render_single_use_error
|
|
10
10
|
rescue_from CanCan::AccessDenied, with: :render_single_use_error
|
|
11
11
|
rescue_from ActiveRecord::RecordNotFound, with: :render_single_use_error
|
|
@@ -21,7 +21,7 @@ module Sufia
|
|
|
21
21
|
def show
|
|
22
22
|
raise not_found_exception unless single_use_link.path == sufia.polymorphic_path(@asset)
|
|
23
23
|
|
|
24
|
-
#show the file
|
|
24
|
+
# show the file
|
|
25
25
|
@presenter = presenter
|
|
26
26
|
|
|
27
27
|
# create a dowload link that is single use for the user since we do not just want to show metadata we want to access it too
|
|
@@ -31,28 +31,34 @@ module Sufia
|
|
|
31
31
|
|
|
32
32
|
protected
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
def content_options
|
|
35
|
+
super.tap do |options|
|
|
36
|
+
options[:disposition] = 'attachment' if action_name == 'download'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
def presenter
|
|
41
|
+
presenter_class.new(@asset)
|
|
42
|
+
end
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
def authorize_download!
|
|
45
|
+
authorize! :read, asset
|
|
46
|
+
end
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
def single_use_link
|
|
49
|
+
@single_use_link ||= SingleUseLink.find_by_downloadKey!(params[:id])
|
|
50
|
+
end
|
|
49
51
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
def not_found_exception
|
|
53
|
+
Sufia::SingleUseError.new('Single-Use Link Not Found')
|
|
54
|
+
end
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
def asset
|
|
57
|
+
@asset ||= ActiveFedora::Base.find(single_use_link.itemId)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def current_ability
|
|
61
|
+
@current_ability ||= SingleUseLinksViewerController::Ability.new current_user, single_use_link
|
|
62
|
+
end
|
|
57
63
|
end
|
|
58
|
-
end
|
|
64
|
+
end
|
|
@@ -5,11 +5,11 @@ module Sufia
|
|
|
5
5
|
included do
|
|
6
6
|
before_action :load_proxy_deposit_request, only: :create
|
|
7
7
|
load_and_authorize_resource :proxy_deposit_request, parent: false, except: :index
|
|
8
|
-
before_action :
|
|
8
|
+
before_action :authorize_depositor_by_id, only: [:new, :create]
|
|
9
9
|
# Catch permission errors
|
|
10
|
-
# TODO we should make this a module in Sufia
|
|
10
|
+
# TODO: we should make this a module in Sufia
|
|
11
11
|
rescue_from CanCan::AccessDenied do |exception|
|
|
12
|
-
if current_user
|
|
12
|
+
if current_user && current_user.persisted?
|
|
13
13
|
redirect_to root_url, alert: exception.message
|
|
14
14
|
else
|
|
15
15
|
session["user_return_to"] = request.url
|
|
@@ -32,7 +32,7 @@ module Sufia
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def index
|
|
35
|
-
@incoming = ProxyDepositRequest.where(receiving_user_id: current_user.id).reject
|
|
35
|
+
@incoming = ProxyDepositRequest.where(receiving_user_id: current_user.id).reject(&:deleted_file?)
|
|
36
36
|
@outgoing = ProxyDepositRequest.where(sending_user_id: current_user.id)
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -56,20 +56,20 @@ module Sufia
|
|
|
56
56
|
|
|
57
57
|
private
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
def authorize_depositor_by_id
|
|
60
|
+
@id = params[:id]
|
|
61
|
+
authorize! :transfer, @id
|
|
62
|
+
@proxy_deposit_request.generic_file_id = @id
|
|
63
|
+
rescue CanCan::AccessDenied
|
|
64
|
+
redirect_to root_url, alert: 'You are not authorized to transfer this file'
|
|
65
|
+
end
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
def load_proxy_deposit_request
|
|
68
|
+
@proxy_deposit_request = ProxyDepositRequest.new(proxy_deposit_request_params)
|
|
69
|
+
end
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
def proxy_deposit_request_params
|
|
72
|
+
params.require(:proxy_deposit_request).permit(:transfer_to)
|
|
73
|
+
end
|
|
74
74
|
end
|
|
75
75
|
end
|
|
@@ -5,27 +5,25 @@ module Sufia::UsersControllerBehavior
|
|
|
5
5
|
include Blacklight::Catalog::SearchContext
|
|
6
6
|
layout "sufia-one-column"
|
|
7
7
|
prepend_before_filter :find_user, except: [:index, :search, :notifications_number]
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
before_action :authenticate_user!, only: [:edit, :update, :follow, :unfollow, :toggle_trophy]
|
|
9
|
+
before_action :user_not_current_user, only: [:follow, :unfollow]
|
|
10
10
|
authorize_resource only: [:edit, :update, :toggle_trophy]
|
|
11
11
|
# Catch permission errors
|
|
12
12
|
rescue_from CanCan::AccessDenied, with: :deny_access
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def index
|
|
16
|
-
|
|
17
|
-
query = params[:uq].blank? ? nil : "%"+params[:uq].downcase+"%"
|
|
16
|
+
query = params[:uq].blank? ? nil : "%" + params[:uq].downcase + "%"
|
|
18
17
|
base = User.where(*base_query)
|
|
19
18
|
unless query.blank?
|
|
20
19
|
base = base.where("#{Devise.authentication_keys.first} like lower(?) OR display_name like lower(?)", query, query)
|
|
21
20
|
end
|
|
22
|
-
@users = base.references(:trophies).order(
|
|
21
|
+
@users = base.references(:trophies).order(sort_value).page(params[:page]).per(10)
|
|
23
22
|
|
|
24
23
|
respond_to do |format|
|
|
25
24
|
format.html
|
|
26
25
|
format.json { render json: @users.to_json }
|
|
27
26
|
end
|
|
28
|
-
|
|
29
27
|
end
|
|
30
28
|
|
|
31
29
|
# Display user profile
|
|
@@ -56,8 +54,8 @@ module Sufia::UsersControllerBehavior
|
|
|
56
54
|
redirect_to sufia.edit_profile_path(@user.to_param), alert: @user.errors.full_messages
|
|
57
55
|
return
|
|
58
56
|
end
|
|
59
|
-
# TODO this should be moved to TrophiesController
|
|
60
|
-
params.keys.select {|k,
|
|
57
|
+
# TODO: this should be moved to TrophiesController
|
|
58
|
+
params.keys.select { |k, _v| k.starts_with? 'remove_trophy_' }.each do |smash_trophy|
|
|
61
59
|
smash_trophy = smash_trophy.sub(/^remove_trophy_/, '')
|
|
62
60
|
current_user.trophies.where(generic_file_id: smash_trophy).destroy_all
|
|
63
61
|
end
|
|
@@ -70,21 +68,21 @@ module Sufia::UsersControllerBehavior
|
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
def toggle_trophy
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
71
|
+
unless current_user.can? :edit, params[:file_id]
|
|
72
|
+
redirect_to root_path, alert: "You do not have permissions to the file"
|
|
73
|
+
return false
|
|
74
|
+
end
|
|
75
|
+
# TODO: make sure current user has access to file
|
|
76
|
+
t = current_user.trophies.where(generic_file_id: params[:file_id]).first
|
|
77
|
+
if t
|
|
78
|
+
t.destroy
|
|
79
|
+
# TODO: do this better says Mike
|
|
80
|
+
return false if t.persisted?
|
|
81
|
+
else
|
|
82
|
+
t = current_user.trophies.create(generic_file_id: params[:file_id])
|
|
83
|
+
return false unless t.persisted?
|
|
84
|
+
end
|
|
85
|
+
render json: t
|
|
88
86
|
end
|
|
89
87
|
|
|
90
88
|
# Follow a user
|
|
@@ -93,7 +91,7 @@ module Sufia::UsersControllerBehavior
|
|
|
93
91
|
current_user.follow(@user)
|
|
94
92
|
Sufia.queue.push(UserFollowEventJob.new(current_user.user_key, @user.user_key))
|
|
95
93
|
end
|
|
96
|
-
redirect_to sufia.profile_path(@user.to_param), notice: "You are following #{@user
|
|
94
|
+
redirect_to sufia.profile_path(@user.to_param), notice: "You are following #{@user}"
|
|
97
95
|
end
|
|
98
96
|
|
|
99
97
|
# Unfollow a user
|
|
@@ -102,43 +100,45 @@ module Sufia::UsersControllerBehavior
|
|
|
102
100
|
current_user.stop_following(@user)
|
|
103
101
|
Sufia.queue.push(UserUnfollowEventJob.new(current_user.user_key, @user.user_key))
|
|
104
102
|
end
|
|
105
|
-
redirect_to sufia.profile_path(@user.to_param), notice: "You are no longer following #{@user
|
|
103
|
+
redirect_to sufia.profile_path(@user.to_param), notice: "You are no longer following #{@user}"
|
|
106
104
|
end
|
|
107
105
|
|
|
108
106
|
protected
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
def user_params
|
|
109
|
+
params.require(:user).permit(:email, :login, :display_name, :address, :admin_area,
|
|
110
|
+
:department, :title, :office, :chat_id, :website, :affiliation,
|
|
111
|
+
:telephone, :avatar, :group_list, :groups_last_update, :facebook_handle,
|
|
112
|
+
:twitter_handle, :googleplus_handle, :linkedin_handle, :remove_avatar, :orcid)
|
|
113
|
+
end
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
# You can override base_query to return a list of arguments
|
|
116
|
+
def base_query
|
|
117
|
+
[nil]
|
|
118
|
+
end
|
|
121
119
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
def find_user
|
|
121
|
+
@user = User.from_url_component(params[:id])
|
|
122
|
+
redirect_to root_path, alert: "User '#{params[:id]}' does not exist" if @user.nil?
|
|
123
|
+
end
|
|
126
124
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
def user_not_current_user
|
|
126
|
+
redirect_to sufia.profile_path(@user.to_param), alert: "You cannot follow or unfollow yourself" if @user == current_user
|
|
127
|
+
end
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
def sort_value
|
|
130
|
+
sort = params[:sort].blank? ? "name" : params[:sort]
|
|
131
|
+
case sort
|
|
132
|
+
when "name"
|
|
133
|
+
"display_name"
|
|
134
|
+
when "name desc"
|
|
135
|
+
"display_name DESC"
|
|
136
|
+
else
|
|
137
|
+
sort
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
140
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
def deny_access(_exception)
|
|
142
|
+
redirect_to sufia.profile_path(@user.to_param), alert: "Permission denied: cannot access this page."
|
|
143
|
+
end
|
|
144
144
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class ContentBlocksController < ApplicationController
|
|
2
2
|
load_and_authorize_resource except: :index
|
|
3
|
-
|
|
3
|
+
before_action :load_featured_researchers, only: :index
|
|
4
4
|
authorize_resource only: :index
|
|
5
5
|
|
|
6
6
|
def index
|
|
@@ -16,18 +16,17 @@ class ContentBlocksController < ApplicationController
|
|
|
16
16
|
redirect_to :back
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
protected
|
|
19
|
+
protected
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def update_params
|
|
26
|
-
params.require(:content_block).permit([:value, :external_key])
|
|
27
|
-
end
|
|
21
|
+
def create_params
|
|
22
|
+
params.require(:content_block).permit([:name, :value, :external_key])
|
|
23
|
+
end
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
def update_params
|
|
26
|
+
params.require(:content_block).permit([:value, :external_key])
|
|
27
|
+
end
|
|
32
28
|
|
|
29
|
+
def load_featured_researchers
|
|
30
|
+
@content_blocks = ContentBlock.recent_researchers.page(params[:page])
|
|
31
|
+
end
|
|
33
32
|
end
|