sufia 7.0.0.beta3 → 7.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +10 -0
- data/.rubocop_todo.yml +66 -7
- data/app/controllers/concerns/sufia/batch_uploads_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/collections_controller_behavior.rb +0 -1
- data/app/controllers/concerns/sufia/contact_form_controller_behavior.rb +6 -3
- data/app/controllers/concerns/sufia/controller.rb +0 -7
- data/app/controllers/concerns/sufia/file_sets_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/uploads_controller_behavior.rb +18 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +1 -25
- data/app/controllers/concerns/sufia/works_controller_behavior.rb +31 -32
- data/app/controllers/curation_concerns/audits_controller.rb +0 -1
- data/app/controllers/sufia/resource_sync_controller.rb +41 -0
- data/app/controllers/sufia/trophies_controller.rb +17 -0
- data/app/controllers/sufia/uploads_controller.rb +1 -12
- data/app/helpers/sufia/sufia_helper_behavior.rb +15 -3
- data/app/helpers/trophy_helper.rb +1 -1
- data/app/models/concerns/sufia/user.rb +0 -12
- data/app/models/contact_form.rb +2 -2
- data/app/models/local_authority.rb +5 -2
- data/app/presenters/sufia/user_profile_presenter.rb +29 -0
- data/app/services/sufia/query_service.rb +1 -1
- data/app/views/collections/_edit_actions.html.erb +2 -1
- data/app/views/collections/_show_actions.html.erb +2 -1
- data/app/views/collections/_work_action_menu.html.erb +1 -1
- data/app/views/contact_form/new.html.erb +1 -1
- data/app/views/curation_concerns/base/_form_progress.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_contents.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_proxy_rights.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +1 -0
- data/app/views/my/_work_action_menu.html.erb +1 -1
- data/app/views/sufia/homepage/_featured_fields.html.erb +1 -5
- data/app/views/sufia/homepage/_home_header.html.erb +1 -1
- data/app/views/transfers/new.html.erb +1 -1
- data/app/views/users/_activity.html.erb +1 -1
- data/app/views/users/_contributions.html.erb +5 -5
- data/app/views/users/_edit_primary.html.erb +2 -2
- data/app/views/users/_profile_actions.html.erb +1 -1
- data/app/views/users/_profile_tabs.html.erb +2 -2
- data/app/views/users/show.html.erb +2 -5
- data/config/locales/sufia.en.yml +1 -1
- data/config/routes.rb +7 -8
- data/{lib/generators/sufia/templates/migrations/acts_as_follower_migration.rb → db/migrate/20160328222155_acts_as_follower_migration.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_social_to_users.rb → db/migrate/20160328222156_add_social_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_ldap_attrs_to_user.rb → db/migrate/20160328222157_add_ldap_attrs_to_user.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_avatars_to_users.rb → db/migrate/20160328222158_add_avatars_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_local_authorities.rb → db/migrate/20160328222160_create_local_authorities.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_trophies.rb → db/migrate/20160328222161_create_trophies.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_linkedin_to_users.rb → db/migrate/20160328222162_add_linkedin_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_tinymce_assets.rb → db/migrate/20160328222163_create_tinymce_assets.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_content_blocks.rb → db/migrate/20160328222164_create_content_blocks.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_featured_works.rb → db/migrate/20160328222165_create_featured_works.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_external_key_to_content_blocks.rb → db/migrate/20160328222166_add_external_key_to_content_blocks.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_proxy_deposit_rights.rb → db/migrate/20160328222226_create_proxy_deposit_rights.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_proxy_deposit_requests.rb → db/migrate/20160328222227_create_proxy_deposit_requests.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_file_view_stats.rb → db/migrate/20160328222228_create_file_view_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_file_download_stats.rb → db/migrate/20160328222229_create_file_download_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_orcid_to_users.rb → db/migrate/20160328222230_add_orcid_to_users.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_user_stats.rb → db/migrate/20160328222231_create_user_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_work_view_stats.rb → db/migrate/20160328222232_create_work_view_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_works_to_user_stats.rb → db/migrate/20160328222233_add_works_to_user_stats.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_trophy_generic_file_id_to_work_id.rb → db/migrate/20160328222236_change_trophy_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_proxy_deposit_generic_file_id_to_work_id.rb → db/migrate/20160328222237_change_proxy_deposit_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_audit_log_generic_file_id_to_file_set_id.rb → db/migrate/20160328222238_change_audit_log_generic_file_id_to_file_set_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_proxy_deposit_request_generic_file_id_to_work_id.rb → db/migrate/20160328222239_change_proxy_deposit_request_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/create_uploaded_files.rb → db/migrate/20160401142419_create_uploaded_files.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/change_featured_work_generic_file_id_to_work_id.rb → db/migrate/20160510000007_change_featured_work_generic_file_id_to_work_id.rb} +0 -0
- data/{lib/generators/sufia/templates/migrations/add_arkivo_to_users.rb → db/migrate/20160516190435_add_arkivo_to_users.rb} +0 -0
- data/lib/generators/sufia/arkivo_api_generator.rb +1 -8
- data/lib/generators/sufia/config_generator.rb +3 -11
- data/lib/generators/sufia/install_generator.rb +12 -46
- data/lib/generators/sufia/templates/catalog_controller.rb +10 -10
- data/lib/generators/sufia/templates/config/sufia.rb +11 -14
- data/lib/generators/sufia/upgrade700_generator.rb +1 -16
- data/lib/sufia.rb +4 -8
- data/lib/sufia/configuration.rb +132 -0
- data/lib/sufia/engine.rb +6 -46
- data/lib/sufia/resource_sync.rb +11 -0
- data/lib/sufia/resource_sync/capability_list_writer.rb +31 -0
- data/lib/sufia/resource_sync/resource_list_writer.rb +77 -0
- data/lib/sufia/resource_sync/source_description_writer.rb +30 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/actors/{create_with_files_actor_spec.rb → sufia/create_with_files_actor_spec.rb} +0 -0
- data/spec/controllers/{admin_stats_controller_spec.rb → admin/stats_controller_spec.rb} +0 -0
- data/spec/controllers/batch_edits_controller_spec.rb +5 -9
- data/spec/controllers/contact_form_controller_spec.rb +88 -0
- data/spec/controllers/{file_sets_controller_spec.rb → curation_concerns/file_sets_controller_spec.rb} +1 -2
- data/spec/controllers/{generic_works_controller_spec.rb → curation_concerns/generic_works_controller_spec.rb} +1 -1
- data/spec/controllers/depositors_controller_spec.rb +1 -1
- data/spec/controllers/featured_works_controller_spec.rb +1 -1
- data/spec/controllers/mailbox_controller_spec.rb +1 -1
- data/spec/controllers/my/highlights_controller_spec.rb +15 -11
- data/spec/controllers/stats_controller_spec.rb +1 -1
- data/spec/controllers/{homepage_controller_spec.rb → sufia/homepage_controller_spec.rb} +1 -1
- data/spec/controllers/sufia/resource_sync_controller_spec.rb +52 -0
- data/spec/controllers/sufia/trophies_controller_spec.rb +27 -0
- data/spec/controllers/transfers_controller_spec.rb +7 -7
- data/spec/controllers/users_controller_spec.rb +22 -60
- data/spec/features/browse_catalog_spec.rb +1 -1
- data/spec/features/collection_spec.rb +6 -7
- data/spec/features/contact_form_spec.rb +2 -89
- data/spec/features/search_spec.rb +7 -7
- data/spec/features/users_spec.rb +1 -1
- data/spec/forms/curation_concerns/{work_form_spec.rb → generic_work_form_spec.rb} +0 -0
- data/spec/forms/sufia/{batch_edit_form_spec.rb → forms/batch_edit_form_spec.rb} +0 -0
- data/spec/forms/sufia/{batch_upload_form_spec.rb → forms/batch_upload_form_spec.rb} +0 -0
- data/spec/forms/sufia/{collection_form_spec.rb → forms/collection_form_spec.rb} +0 -0
- data/spec/helpers/blacklight_helper_spec.rb +91 -0
- data/spec/helpers/dashboard_helper_spec.rb +2 -2
- data/spec/helpers/sufia_helper_spec.rb +7 -12
- data/spec/helpers/trophy_helper_spec.rb +1 -1
- data/spec/javascripts/jasmine_spec.rb +1 -1
- data/spec/lib/sufia/resource_sync/capability_list_writer_spec.rb +26 -0
- data/spec/lib/sufia/resource_sync/resource_list_writer_spec.rb +24 -0
- data/spec/lib/sufia/resource_sync/source_description_writer_spec.rb +21 -0
- data/spec/models/featured_work_spec.rb +1 -1
- data/spec/models/generic_work_spec.rb +7 -10
- data/spec/models/local_authority_spec.rb +3 -11
- data/spec/models/{ability_spec.rb → sufia/ability_spec.rb} +0 -0
- data/spec/models/sufia/download_spec.rb +13 -0
- data/spec/models/sufia/pageview_spec.rb +13 -0
- data/spec/models/sufia/uploaded_file_spec.rb +1 -1
- data/spec/models/{user_usage_stats_spec.rb → sufia/user_usage_stats_spec.rb} +0 -0
- data/spec/models/trophy_spec.rb +5 -7
- data/spec/models/user_spec.rb +12 -12
- data/spec/presenters/{file_usage_spec.rb → sufia/file_usage_spec.rb} +4 -4
- data/spec/presenters/{presenter_renderer_spec.rb → sufia/presenter_renderer_spec.rb} +0 -0
- data/spec/presenters/sufia/user_profile_presenter_spec.rb +23 -0
- data/spec/presenters/{work_usage_spec.rb → sufia/work_usage_spec.rb} +4 -4
- data/spec/requests/legacy_routing_spec.rb +1 -1
- data/spec/routing/ownership_transfers_route_spec.rb +2 -2
- data/spec/routing/route_spec.rb +19 -16
- data/spec/services/{collection_member_service_spec.rb → sufia/collection_member_service_spec.rb} +0 -0
- data/spec/services/{collection_size_service_spec.rb → sufia/collection_size_service_spec.rb} +0 -0
- data/spec/services/{file_set_csv_service_spec.rb → sufia/file_set_csv_service_spec.rb} +0 -0
- data/spec/services/{repository_audit_service_spec.rb → sufia/repository_audit_service_spec.rb} +0 -0
- data/spec/services/{statistics → sufia/statistics}/collections/over_time_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/depositors/summary_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/file_sets/by_format_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/system_stats_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/by_depositor_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/by_resource_type_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/count_spec.rb +0 -0
- data/spec/services/{statistics → sufia/statistics}/works/over_time_spec.rb +0 -0
- data/spec/spec_helper.rb +12 -15
- data/spec/tasks/rake_spec.rb +0 -28
- data/spec/views/_toolbar.html.erb_spec.rb +1 -1
- data/spec/views/admin/stats/index.html.erb_spec.rb +2 -4
- data/spec/views/batch_edits/edit.html.erb_spec.rb +1 -2
- data/spec/views/catalog/_index_list_default.html.erb_spec.rb +14 -19
- data/spec/views/catalog/index.html.erb_spec.rb +1 -1
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +9 -10
- data/spec/views/collections/_form.html.erb_spec.rb +2 -2
- data/spec/views/collections/_form_for_select_collection.html.erb_spec.rb +1 -2
- data/spec/views/collections/edit.html.erb_spec.rb +1 -1
- data/spec/views/collections/show.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/base/_form.html.erb_spec.rb +11 -33
- data/spec/views/curation_concerns/base/_form_progress.html.erb_spec.rb +3 -3
- data/spec/views/curation_concerns/base/_relationships.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/base/edit.html.erb_spec.rb +1 -1
- data/spec/views/curation_concerns/file_sets/_versioning.html.erb_spec.rb +1 -3
- data/spec/views/curation_concerns/permissions/confirm.html.erb_spec.rb +1 -1
- data/spec/views/dashboard/index_spec.rb +2 -4
- data/spec/views/homepage/_announcement.html.erb_spec.rb +1 -2
- data/spec/views/homepage/_featured_works.html.erb_spec.rb +9 -2
- data/spec/views/homepage/_home_header.html.erb_spec.rb +1 -1
- data/spec/views/my/_list_collections.html.erb_spec.rb +1 -1
- data/spec/views/my/_list_works.html.erb_spec.rb +1 -1
- data/spec/views/sufia/batch_uploads/_form.html.erb_spec.rb +4 -4
- data/spec/views/users/edit.html.erb_spec.rb +0 -3
- data/spec/views/users/show.html.erb_spec.rb +9 -7
- data/sufia.gemspec +1 -0
- metadata +124 -96
- data/app/controllers/directory_controller.rb +0 -30
- data/lib/generators/sufia/abstract_migration_generator.rb +0 -31
- data/lib/generators/sufia/cached_stats_generator.rb +0 -24
- data/lib/generators/sufia/cached_work_stats_generator.rb +0 -24
- data/lib/generators/sufia/citation_config_generator.rb +0 -22
- data/lib/generators/sufia/minimagick_config_generator.rb +0 -18
- data/lib/generators/sufia/orcid_field_generator.rb +0 -19
- data/lib/generators/sufia/proxies_generator.rb +0 -24
- data/lib/generators/sufia/usagestats_generator.rb +0 -18
- data/lib/generators/sufia/user_stats_generator.rb +0 -31
- data/spec/models/download_spec.rb +0 -17
- data/spec/models/pageview_spec.rb +0 -17
- data/tasks/migrate.rake +0 -20
@@ -1,30 +0,0 @@
|
|
1
|
-
class DirectoryController < ApplicationController
|
2
|
-
# Stub method. Override this in your application if you want directory lookups
|
3
|
-
def user
|
4
|
-
# render json: User.directory_attributes(params[:uid])
|
5
|
-
render json: ''
|
6
|
-
end
|
7
|
-
|
8
|
-
# Stub method. Override this in your application if you want directory lookups
|
9
|
-
def user_attribute
|
10
|
-
# if params[:attribute] == "groups"
|
11
|
-
# res = User.groups(params[:uid])
|
12
|
-
# else
|
13
|
-
# res = User.directory_attributes(params[:uid], params[:attribute])
|
14
|
-
# end
|
15
|
-
# render json: res
|
16
|
-
render json: ''
|
17
|
-
end
|
18
|
-
|
19
|
-
# Stub method. Override this in your application if you want directory lookups
|
20
|
-
def user_groups
|
21
|
-
# render json: User.groups(params[:uid])
|
22
|
-
render json: []
|
23
|
-
end
|
24
|
-
|
25
|
-
# Stub method. Override this in your application if you want directory lookups
|
26
|
-
def group
|
27
|
-
# render json: Group.exists?(params[:cn])
|
28
|
-
render json: false
|
29
|
-
end
|
30
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
require 'rails/generators'
|
3
|
-
require 'rails/generators/migration'
|
4
|
-
|
5
|
-
class Sufia::AbstractMigrationGenerator < Rails::Generators::Base
|
6
|
-
include Rails::Generators::Migration
|
7
|
-
|
8
|
-
# Implement the required interface for Rails::Generators::Migration.
|
9
|
-
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
|
10
|
-
def self.next_migration_number(path)
|
11
|
-
if @prev_migration_nr
|
12
|
-
@prev_migration_nr += 1
|
13
|
-
else
|
14
|
-
last_migration = Dir[File.join(path, '*.rb')].sort.last
|
15
|
-
@prev_migration_nr = if last_migration
|
16
|
-
last_migration.sub(File.join(path, '/'), '').to_i + 1
|
17
|
-
else
|
18
|
-
Time.zone.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
19
|
-
end
|
20
|
-
end
|
21
|
-
@prev_migration_nr.to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
def better_migration_template(file)
|
27
|
-
migration_template "migrations/#{file}", "db/migrate/#{file}"
|
28
|
-
rescue Rails::Generators::Error => e
|
29
|
-
say_status("error", e.message, :red)
|
30
|
-
end
|
31
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'abstract_migration_generator'
|
2
|
-
|
3
|
-
class Sufia::CachedStatsGenerator < Sufia::AbstractMigrationGenerator
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This generator adds the ability to cache usage stats to your application:
|
8
|
-
1. Creates several database migrations if they do not exist in /db/migrate
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING STATS CACHING-RELATED TABLES", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Setup the database migrations
|
16
|
-
def copy_migrations
|
17
|
-
[
|
18
|
-
'create_file_view_stats.rb',
|
19
|
-
'create_file_download_stats.rb'
|
20
|
-
].each do |file|
|
21
|
-
better_migration_template file
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'abstract_migration_generator'
|
2
|
-
|
3
|
-
class Sufia::CachedWorkStatsGenerator < Sufia::AbstractMigrationGenerator
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This generator adds the ability to cache usage stats to your application:
|
8
|
-
1. Creates several database migrations if they do not exist in /db/migrate
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING WORK STATS CACHING-RELATED TABLES", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Setup the database migrations
|
16
|
-
def copy_migrations
|
17
|
-
[
|
18
|
-
'create_work_view_stats.rb',
|
19
|
-
'add_works_to_user_stats.rb'
|
20
|
-
].each do |file|
|
21
|
-
better_migration_template file
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
class Sufia::CitationConfigGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This Generator makes the following changes to your application:
|
8
|
-
1. Updates existing sufia.rb initializer to include a citation configuration
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING CITATIONS OPTION TO SUFIA CONFIG", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
def inject_config_initializer
|
16
|
-
inject_into_file 'config/initializers/sufia.rb', before: "# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)" do
|
17
|
-
"# Enables a link to the citations page for a generic_file.\n" \
|
18
|
-
"# Default is false\n" \
|
19
|
-
"# config.citations = false\n"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
class Sufia::MinimagickConfigGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This Generator makes the following changes to your application:
|
8
|
-
1. Creates new mini_magick.rb initializer configuring use of posix-spawn
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING MINIMAGICK CONFIG", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_configuration_file
|
16
|
-
copy_file 'config/mini_magick.rb', 'config/initializers/mini_magick.rb'
|
17
|
-
end
|
18
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require_relative 'abstract_migration_generator'
|
2
|
-
|
3
|
-
class Sufia::OrcidFieldGenerator < Sufia::AbstractMigrationGenerator
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This generator adds a field to hold users' ORCIDs to your application:
|
8
|
-
1. Creates a database migration if they do not exist in /db/migrate
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING ORCID FIELD TO USER MODEL", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Setup the database migration
|
16
|
-
def copy_migrations
|
17
|
-
better_migration_template 'add_orcid_to_users.rb'
|
18
|
-
end
|
19
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative 'abstract_migration_generator'
|
2
|
-
|
3
|
-
class Sufia::ProxiesGenerator < Sufia::AbstractMigrationGenerator
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This generator adds proxies and transfers to your application:
|
8
|
-
1. Creates several database migrations if they do not exist in /db/migrate
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING PROXY/TRANSFER-RELATED DATABASE TABLES", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Setup the database migrations
|
16
|
-
def copy_migrations
|
17
|
-
[
|
18
|
-
'create_proxy_deposit_rights.rb',
|
19
|
-
'create_proxy_deposit_requests.rb'
|
20
|
-
].each do |file|
|
21
|
-
better_migration_template file
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
|
3
|
-
class Sufia::UsagestatsGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
|
6
|
-
desc """
|
7
|
-
This generator makes the following changes to your application:
|
8
|
-
1. Generates usage stats config
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "GENERATING SUFIA USAGE STATS", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_configuration_file
|
16
|
-
copy_file 'config/analytics.yml', 'config/analytics.yml'
|
17
|
-
end
|
18
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require_relative 'abstract_migration_generator'
|
2
|
-
|
3
|
-
class Sufia::UserStatsGenerator < Sufia::AbstractMigrationGenerator
|
4
|
-
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
argument :model_name, type: :string, default: "user"
|
6
|
-
|
7
|
-
desc """
|
8
|
-
This generator adds usage stats methods to the user model in your application:
|
9
|
-
"""
|
10
|
-
|
11
|
-
def banner
|
12
|
-
say_status("info", "ADDING USER STATS-RELATED ABILITIES AND TABLES", :blue)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Setup the database migrations
|
16
|
-
def copy_migrations
|
17
|
-
better_migration_template 'create_user_stats.rb'
|
18
|
-
end
|
19
|
-
|
20
|
-
def add_stats_mixin_to_user_model
|
21
|
-
file_path = "app/models/#{model_name.underscore}.rb"
|
22
|
-
|
23
|
-
if File.exist?(file_path)
|
24
|
-
inject_into_file file_path, after: /include Sufia\:\:User.*$/ do
|
25
|
-
"\n include Sufia::UserUsageStats"
|
26
|
-
end
|
27
|
-
else
|
28
|
-
puts " \e[31mFailure\e[0m Sufia requires a user object. This generator assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails g sufia:user_stats client"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
describe Sufia::Download, type: :model do
|
2
|
-
before do
|
3
|
-
@download = described_class
|
4
|
-
end
|
5
|
-
|
6
|
-
it 'has an events metric' do
|
7
|
-
expect(@download.metrics).to be == Legato::ListParameter.new(:metrics, [:totalEvents])
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'has dimensions' do
|
11
|
-
expect(@download.dimensions).to be == Legato::ListParameter.new(:dimensions, [:eventCategory, :eventAction, :eventLabel, :date])
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'responds to :for_file' do
|
15
|
-
expect(@download).to respond_to(:for_file)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
describe Sufia::Pageview, type: :model do
|
2
|
-
before do
|
3
|
-
@pageview = described_class
|
4
|
-
end
|
5
|
-
|
6
|
-
it 'has a pageviews metric' do
|
7
|
-
expect(@pageview.metrics).to be == Legato::ListParameter.new(:metrics, [:pageviews])
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'has a date dimension' do
|
11
|
-
expect(@pageview.dimensions).to be == Legato::ListParameter.new(:dimensions, [:date])
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'responds to :for_path' do
|
15
|
-
expect(@pageview).to respond_to(:for_path)
|
16
|
-
end
|
17
|
-
end
|
data/tasks/migrate.rake
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
namespace :sufia do
|
2
|
-
namespace :migrate do
|
3
|
-
|
4
|
-
desc "Migrate proxy deposits"
|
5
|
-
task proxy_deposits: :environment do
|
6
|
-
ProxyDepositRequest.all.each do |pd|
|
7
|
-
pd.work_id = pd.work_id.delete "#{Sufia.config.redis_namespace}:"
|
8
|
-
pd.save
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
desc "Migrate audit logs"
|
13
|
-
task audit_logs: :environment do
|
14
|
-
ChecksumAuditLog.all.each do |cs|
|
15
|
-
cs.file_set_id = cs.file_set_id.delete "#{Sufia.config.redis_namespace}:"
|
16
|
-
cs.save
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|