geoblacklight_admin 0.8.0 → 0.10.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/app/controllers/admin/document_distributions_controller.rb +23 -10
- data/app/controllers/admin/document_licensed_accesses_controller.rb +169 -0
- data/app/controllers/admin/documents_controller.rb +12 -12
- data/app/controllers/admin/elements_controller.rb +1 -1
- data/app/controllers/admin/import_distributions_controller.rb +2 -1
- data/app/controllers/admin/imports_controller.rb +2 -1
- data/app/indexers/document_indexer.rb +2 -2
- data/app/javascript/controllers/results_controller.js +5 -15
- data/app/jobs/bulk_action_run_document_job.rb +12 -2
- data/app/jobs/destroy_document_distributions_job.rb +80 -0
- data/app/jobs/export_job.rb +40 -30
- data/app/jobs/export_json_bulk_job.rb +1 -1
- data/app/jobs/export_json_job.rb +1 -1
- data/app/jobs/import_document_job.rb +12 -1
- data/app/jobs/import_run_job.rb +5 -0
- data/app/models/asset.rb +13 -3
- data/app/models/document/controlled_lists.rb +3 -2
- data/app/models/document/date_validator.rb +14 -12
- data/app/models/document.rb +21 -107
- data/app/models/{document_access.rb → document_licensed_access.rb} +8 -6
- data/app/models/geoblacklight_admin/schema.rb +0 -10
- data/app/models/import_document.rb +5 -0
- data/app/services/export_csv_document_distributions_service.rb +8 -4
- data/app/services/export_csv_document_licensed_access_links_service.rb +27 -0
- data/app/services/export_csv_service.rb +5 -1
- data/app/views/admin/document_assets/_assets_table.html.erb +4 -0
- data/app/views/admin/document_assets/index.html.erb +3 -1
- data/app/views/admin/document_distributions/destroy_all.html.erb +4 -1
- data/app/views/admin/document_distributions/index.html.erb +5 -7
- data/app/views/admin/document_licensed_accesses/_document_licensed_access.json.jbuilder +4 -0
- data/app/views/admin/{document_accesses → document_licensed_accesses}/_form.html.erb +4 -5
- data/app/views/admin/{document_accesses → document_licensed_accesses}/destroy_all.html.erb +7 -7
- data/app/views/admin/document_licensed_accesses/edit.html.erb +5 -0
- data/app/views/admin/{document_accesses → document_licensed_accesses}/import.html.erb +12 -9
- data/app/views/admin/document_licensed_accesses/index.html.erb +78 -0
- data/app/views/admin/document_licensed_accesses/index.json.jbuilder +3 -0
- data/app/views/admin/document_licensed_accesses/new.html.erb +8 -0
- data/app/views/admin/documents/_form_control.html.erb +0 -10
- data/app/views/admin/documents/_form_nav.html.erb +3 -12
- data/app/views/admin/documents/_form_nav_kithe.html.erb +0 -4
- data/app/views/admin/documents/_result_selected_options.html.erb +14 -18
- data/app/views/admin/documents/admin.html.erb +1 -1
- data/app/views/admin/documents/features/_document_references.html.erb +18 -20
- data/app/views/admin/documents/features/_licensed_access.html.erb +3 -0
- data/app/views/admin/elements/index.html.erb +0 -18
- data/app/views/admin/import_distributions/_form.html.erb +1 -1
- data/app/views/admin/import_distributions/_show_queued_tab.html.erb +36 -0
- data/app/views/admin/import_distributions/index.html.erb +3 -3
- data/app/views/admin/import_distributions/new.html.erb +3 -1
- data/app/views/admin/import_distributions/show.html.erb +5 -0
- data/app/views/admin/imports/_form.html.erb +1 -1
- data/app/views/admin/imports/_show_queued_tab.html.erb +31 -0
- data/app/views/admin/imports/index.html.erb +3 -3
- data/app/views/admin/imports/new.html.erb +3 -1
- data/app/views/admin/imports/show.html.erb +6 -0
- data/app/views/admin/notifications/_notification.html.haml +0 -1
- data/app/views/admin/notifications/update.js.erb +1 -1
- data/app/views/admin/shared/_navbar.html.erb +8 -7
- data/config/routes.rb +2 -25
- data/db/migrate/20240321000000_rename_document_accesses_to_document_licensed_accesses.rb +5 -0
- data/db/seeds_form_elements.csv +1 -2
- data/db/seeds_form_elements.numbers +0 -0
- data/lib/generators/geoblacklight_admin/config_generator.rb +4 -26
- data/lib/generators/geoblacklight_admin/templates/config/initializers/mime_types.rb +1 -1
- data/lib/geoblacklight_admin/version.rb +1 -1
- metadata +32 -30
- data/app/controllers/admin/document_accesses_controller.rb +0 -169
- data/app/controllers/admin/document_downloads_controller.rb +0 -129
- data/app/models/document_download.rb +0 -39
- data/app/services/export_csv_document_access_links_service.rb +0 -47
- data/app/services/export_csv_document_downloads_service.rb +0 -47
- data/app/views/admin/document_accesses/_document_access.json.jbuilder +0 -4
- data/app/views/admin/document_accesses/edit.html.erb +0 -5
- data/app/views/admin/document_accesses/index.html.erb +0 -78
- data/app/views/admin/document_accesses/index.json.jbuilder +0 -3
- data/app/views/admin/document_accesses/new.html.erb +0 -6
- data/app/views/admin/document_accesses/show.html.erb +0 -19
- data/app/views/admin/document_accesses/show.json.jbuilder +0 -3
- data/app/views/admin/document_downloads/_document_download.json.jbuilder +0 -4
- data/app/views/admin/document_downloads/_form.html.erb +0 -15
- data/app/views/admin/document_downloads/destroy_all.html.erb +0 -70
- data/app/views/admin/document_downloads/edit.html.erb +0 -5
- data/app/views/admin/document_downloads/import.html.erb +0 -74
- data/app/views/admin/document_downloads/index.html.erb +0 -72
- data/app/views/admin/document_downloads/index.json.jbuilder +0 -3
- data/app/views/admin/document_downloads/new.html.erb +0 -5
- data/app/views/admin/document_downloads/show.html.erb +0 -24
- data/app/views/admin/document_downloads/show.json.jbuilder +0 -3
- data/app/views/admin/documents/features/_institutional_access_links.html.erb +0 -3
- data/app/views/admin/documents/features/_multiple_download_links.html.erb +0 -30
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geoblacklight_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Larson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_storage_validations
|
@@ -458,6 +458,20 @@ dependencies:
|
|
458
458
|
- - "~>"
|
459
459
|
- !ruby/object:Gem::Version
|
460
460
|
version: '2.6'
|
461
|
+
- !ruby/object:Gem::Dependency
|
462
|
+
name: rubyzip
|
463
|
+
requirement: !ruby/object:Gem::Requirement
|
464
|
+
requirements:
|
465
|
+
- - "~>"
|
466
|
+
- !ruby/object:Gem::Version
|
467
|
+
version: '2.3'
|
468
|
+
type: :runtime
|
469
|
+
prerelease: false
|
470
|
+
version_requirements: !ruby/object:Gem::Requirement
|
471
|
+
requirements:
|
472
|
+
- - "~>"
|
473
|
+
- !ruby/object:Gem::Version
|
474
|
+
version: '2.3'
|
461
475
|
- !ruby/object:Gem::Dependency
|
462
476
|
name: byebug
|
463
477
|
requirement: !ruby/object:Gem::Requirement
|
@@ -819,12 +833,11 @@ files:
|
|
819
833
|
- app/controllers/admin/assets_controller.rb
|
820
834
|
- app/controllers/admin/bookmarks_controller.rb
|
821
835
|
- app/controllers/admin/bulk_actions_controller.rb
|
822
|
-
- app/controllers/admin/document_accesses_controller.rb
|
823
836
|
- app/controllers/admin/document_assets_controller.rb
|
824
837
|
- app/controllers/admin/document_data_dictionaries_controller.rb
|
825
838
|
- app/controllers/admin/document_data_dictionary_entries_controller.rb
|
826
839
|
- app/controllers/admin/document_distributions_controller.rb
|
827
|
-
- app/controllers/admin/
|
840
|
+
- app/controllers/admin/document_licensed_accesses_controller.rb
|
828
841
|
- app/controllers/admin/documents_controller.rb
|
829
842
|
- app/controllers/admin/elements_controller.rb
|
830
843
|
- app/controllers/admin/form_elements_controller.rb
|
@@ -856,6 +869,7 @@ files:
|
|
856
869
|
- app/jobs/bulk_action_revert_job.rb
|
857
870
|
- app/jobs/bulk_action_run_document_job.rb
|
858
871
|
- app/jobs/bulk_action_run_job.rb
|
872
|
+
- app/jobs/destroy_document_distributions_job.rb
|
859
873
|
- app/jobs/export_job.rb
|
860
874
|
- app/jobs/export_json_bulk_job.rb
|
861
875
|
- app/jobs/export_json_job.rb
|
@@ -896,12 +910,11 @@ files:
|
|
896
910
|
- app/models/document/date_validator.rb
|
897
911
|
- app/models/document/geom_validator.rb
|
898
912
|
- app/models/document/reference.rb
|
899
|
-
- app/models/document_access.rb
|
900
913
|
- app/models/document_data_dictionary.rb
|
901
914
|
- app/models/document_data_dictionary/csv_header_validator.rb
|
902
915
|
- app/models/document_data_dictionary_entry.rb
|
903
916
|
- app/models/document_distribution.rb
|
904
|
-
- app/models/
|
917
|
+
- app/models/document_licensed_access.rb
|
905
918
|
- app/models/document_state_machine.rb
|
906
919
|
- app/models/document_thumbnail_state_machine.rb
|
907
920
|
- app/models/document_thumbnail_transition.rb
|
@@ -942,9 +955,8 @@ files:
|
|
942
955
|
- app/models/reference_type.rb
|
943
956
|
- app/models/user.rb
|
944
957
|
- app/notifications/export_notification.rb
|
945
|
-
- app/services/export_csv_document_access_links_service.rb
|
946
958
|
- app/services/export_csv_document_distributions_service.rb
|
947
|
-
- app/services/
|
959
|
+
- app/services/export_csv_document_licensed_access_links_service.rb
|
948
960
|
- app/services/export_csv_service.rb
|
949
961
|
- app/services/export_json_service.rb
|
950
962
|
- app/services/geoblacklight_admin/image_service.rb
|
@@ -981,16 +993,6 @@ files:
|
|
981
993
|
- app/views/admin/bulk_actions/new.html.erb
|
982
994
|
- app/views/admin/bulk_actions/show.html.erb
|
983
995
|
- app/views/admin/bulk_actions/show.json.jbuilder
|
984
|
-
- app/views/admin/document_accesses/_document_access.json.jbuilder
|
985
|
-
- app/views/admin/document_accesses/_form.html.erb
|
986
|
-
- app/views/admin/document_accesses/destroy_all.html.erb
|
987
|
-
- app/views/admin/document_accesses/edit.html.erb
|
988
|
-
- app/views/admin/document_accesses/import.html.erb
|
989
|
-
- app/views/admin/document_accesses/index.html.erb
|
990
|
-
- app/views/admin/document_accesses/index.json.jbuilder
|
991
|
-
- app/views/admin/document_accesses/new.html.erb
|
992
|
-
- app/views/admin/document_accesses/show.html.erb
|
993
|
-
- app/views/admin/document_accesses/show.json.jbuilder
|
994
996
|
- app/views/admin/document_assets/_assets_table.html.erb
|
995
997
|
- app/views/admin/document_assets/_form.html.erb
|
996
998
|
- app/views/admin/document_assets/display_attach_form.html.erb
|
@@ -1020,16 +1022,14 @@ files:
|
|
1020
1022
|
- app/views/admin/document_distributions/new.html.erb
|
1021
1023
|
- app/views/admin/document_distributions/show.html.erb
|
1022
1024
|
- app/views/admin/document_distributions/show.json.jbuilder
|
1023
|
-
- app/views/admin/
|
1024
|
-
- app/views/admin/
|
1025
|
-
- app/views/admin/
|
1026
|
-
- app/views/admin/
|
1027
|
-
- app/views/admin/
|
1028
|
-
- app/views/admin/
|
1029
|
-
- app/views/admin/
|
1030
|
-
- app/views/admin/
|
1031
|
-
- app/views/admin/document_downloads/show.html.erb
|
1032
|
-
- app/views/admin/document_downloads/show.json.jbuilder
|
1025
|
+
- app/views/admin/document_licensed_accesses/_document_licensed_access.json.jbuilder
|
1026
|
+
- app/views/admin/document_licensed_accesses/_form.html.erb
|
1027
|
+
- app/views/admin/document_licensed_accesses/destroy_all.html.erb
|
1028
|
+
- app/views/admin/document_licensed_accesses/edit.html.erb
|
1029
|
+
- app/views/admin/document_licensed_accesses/import.html.erb
|
1030
|
+
- app/views/admin/document_licensed_accesses/index.html.erb
|
1031
|
+
- app/views/admin/document_licensed_accesses/index.json.jbuilder
|
1032
|
+
- app/views/admin/document_licensed_accesses/new.html.erb
|
1033
1033
|
- app/views/admin/documents/_document.html.erb
|
1034
1034
|
- app/views/admin/documents/_document_bookmark.html.erb
|
1035
1035
|
- app/views/admin/documents/_document_fields.html.erb
|
@@ -1053,8 +1053,7 @@ files:
|
|
1053
1053
|
- app/views/admin/documents/edit.html.erb
|
1054
1054
|
- app/views/admin/documents/features/_assets.html.erb
|
1055
1055
|
- app/views/admin/documents/features/_document_references.html.erb
|
1056
|
-
- app/views/admin/documents/features/
|
1057
|
-
- app/views/admin/documents/features/_multiple_download_links.html.erb
|
1056
|
+
- app/views/admin/documents/features/_licensed_access.html.erb
|
1058
1057
|
- app/views/admin/documents/fetch.json_aardvark.jbuilder
|
1059
1058
|
- app/views/admin/documents/fetch.json_btaa_aardvark.jbuilder
|
1060
1059
|
- app/views/admin/documents/fetch.json_file.jbuilder
|
@@ -1089,6 +1088,7 @@ files:
|
|
1089
1088
|
- app/views/admin/import_distributions/_form.html.erb
|
1090
1089
|
- app/views/admin/import_distributions/_import_distribution.json.jbuilder
|
1091
1090
|
- app/views/admin/import_distributions/_show_failed_tab.html.erb
|
1091
|
+
- app/views/admin/import_distributions/_show_queued_tab.html.erb
|
1092
1092
|
- app/views/admin/import_distributions/_show_success_tab.html.erb
|
1093
1093
|
- app/views/admin/import_distributions/edit.html.erb
|
1094
1094
|
- app/views/admin/import_distributions/index.html.erb
|
@@ -1100,6 +1100,7 @@ files:
|
|
1100
1100
|
- app/views/admin/imports/_form.html.erb
|
1101
1101
|
- app/views/admin/imports/_import.json.jbuilder
|
1102
1102
|
- app/views/admin/imports/_show_failed_tab.html.erb
|
1103
|
+
- app/views/admin/imports/_show_queued_tab.html.erb
|
1103
1104
|
- app/views/admin/imports/_show_success_tab.html.erb
|
1104
1105
|
- app/views/admin/imports/edit.html.erb
|
1105
1106
|
- app/views/admin/imports/index.html.erb
|
@@ -1166,6 +1167,7 @@ files:
|
|
1166
1167
|
- db/import_references_schema_support.numbers
|
1167
1168
|
- db/migrate/20230316183001_add_geoblacklight_admin_gem.rb
|
1168
1169
|
- db/migrate/20231106215104_bulk_action_sti.rb
|
1170
|
+
- db/migrate/20240321000000_rename_document_accesses_to_document_licensed_accesses.rb
|
1169
1171
|
- db/migrate/20240619171628_create_document_thumbnail_statesman.rb
|
1170
1172
|
- db/migrate/20241009200524_create_admin_reference_types.rb
|
1171
1173
|
- db/migrate/20241010161420_create_document_references.rb
|
@@ -1,169 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Admin::DocumentAccessesController
|
4
|
-
#
|
5
|
-
# This controller manages the CRUD operations for DocumentAccess objects
|
6
|
-
# within the admin namespace. It provides actions to list, show, create,
|
7
|
-
# update, and destroy document access records. It also includes custom
|
8
|
-
# actions for importing and destroying all document access links.
|
9
|
-
#
|
10
|
-
# Actions:
|
11
|
-
# - index: Lists all document accesses, optionally filtered by document_id.
|
12
|
-
# - show: Displays a specific document access.
|
13
|
-
# - new: Renders a form for creating a new document access.
|
14
|
-
# - edit: Renders a form for editing an existing document access.
|
15
|
-
# - create: Creates a new document access.
|
16
|
-
# - update: Updates an existing document access.
|
17
|
-
# - destroy: Deletes a specific document access.
|
18
|
-
# - destroy_all: Deletes all document access links provided in the params.
|
19
|
-
# - import: Imports document access links from a file provided in the params.
|
20
|
-
#
|
21
|
-
# Before Actions:
|
22
|
-
# - set_document: Sets the @document instance variable if document_id is present.
|
23
|
-
# - set_document_access: Sets the @document_access instance variable for specific actions.
|
24
|
-
#
|
25
|
-
# Private Methods:
|
26
|
-
# - set_document: Finds and sets the document based on the document_id parameter.
|
27
|
-
# - set_document_access: Finds and sets the document access based on the id parameter.
|
28
|
-
# - document_access_params: Permits only trusted parameters for document access.
|
29
|
-
module Admin
|
30
|
-
class DocumentAccessesController < Admin::AdminController
|
31
|
-
before_action :set_document
|
32
|
-
before_action :set_document_access, only: %i[show edit update destroy]
|
33
|
-
|
34
|
-
# GET /documents/#id/access
|
35
|
-
# GET /documents/#id/access.json
|
36
|
-
# Lists all document accesses, optionally filtered by document_id.
|
37
|
-
def index
|
38
|
-
if params[:document_id]
|
39
|
-
@document_accesses = DocumentAccess.where(friendlier_id: @document.friendlier_id).order(institution_code: :asc)
|
40
|
-
else
|
41
|
-
@pagy, @document_accesses = pagy(DocumentAccess.all.order(friendlier_id: :asc, updated_at: :desc), items: 20)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# GET /document_accesses/1
|
46
|
-
# GET /document_accesses/1.json
|
47
|
-
# Displays a specific document access.
|
48
|
-
def show
|
49
|
-
end
|
50
|
-
|
51
|
-
# GET /document_accesses/new
|
52
|
-
# Renders a form for creating a new document access.
|
53
|
-
def new
|
54
|
-
@document_access = DocumentAccess.new
|
55
|
-
end
|
56
|
-
|
57
|
-
# GET /document_accesses/1/edit
|
58
|
-
# Renders a form for editing an existing document access.
|
59
|
-
def edit
|
60
|
-
end
|
61
|
-
|
62
|
-
# POST /document_accesses
|
63
|
-
# POST /document_accesses.json
|
64
|
-
# Creates a new document access.
|
65
|
-
def create
|
66
|
-
@document_access = DocumentAccess.new(document_access_params)
|
67
|
-
logger.debug("DA Params: #{DocumentAccess.new(document_access_params).inspect}")
|
68
|
-
logger.debug("Document ACCESS: #{@document_access.inspect}")
|
69
|
-
|
70
|
-
respond_to do |format|
|
71
|
-
if @document_access.save
|
72
|
-
format.html do
|
73
|
-
redirect_to admin_document_document_accesses_path(@document), notice: "Document access was successfully created."
|
74
|
-
end
|
75
|
-
format.json { render :show, status: :created, location: @document_access }
|
76
|
-
else
|
77
|
-
format.html { render :new }
|
78
|
-
format.json { render json: @document_access.errors, status: :unprocessable_entity }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
# PATCH/PUT /document_accesses/1
|
84
|
-
# PATCH/PUT /document_accesses/1.json
|
85
|
-
# Updates an existing document access.
|
86
|
-
def update
|
87
|
-
respond_to do |format|
|
88
|
-
if @document_access.update(document_access_params)
|
89
|
-
format.html do
|
90
|
-
redirect_to admin_document_document_accesses_path(@document), notice: "Document access was successfully updated."
|
91
|
-
end
|
92
|
-
format.json { render :show, status: :ok, location: @document_access }
|
93
|
-
else
|
94
|
-
format.html { render :edit }
|
95
|
-
format.json { render json: @document_access.errors, status: :unprocessable_entity }
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
# DELETE /document_accesses/1
|
101
|
-
# DELETE /document_accesses/1.json
|
102
|
-
# Deletes a specific document access.
|
103
|
-
def destroy
|
104
|
-
@document_access.destroy
|
105
|
-
respond_to do |format|
|
106
|
-
format.html do
|
107
|
-
redirect_to admin_document_document_accesses_path(@document), notice: "Document access was successfully destroyed."
|
108
|
-
end
|
109
|
-
format.json { head :no_content }
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
# DELETE /document_accesses/destroy_all
|
114
|
-
# Deletes all document access links provided in the params.
|
115
|
-
def destroy_all
|
116
|
-
logger.debug("Destroy Access Links")
|
117
|
-
return unless params.dig(:document_access, :assets, :file)
|
118
|
-
|
119
|
-
respond_to do |format|
|
120
|
-
if DocumentAccess.destroy_all(params.dig(:document_access, :assets, :file))
|
121
|
-
format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links were created destroyed." }
|
122
|
-
else
|
123
|
-
format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links could not be destroyed." }
|
124
|
-
end
|
125
|
-
rescue => e
|
126
|
-
format.html { redirect_to admin_document_accesses_path, notice: "Document Access Links could not be destroyed. #{e}" }
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# GET /documents/#id/access/import
|
131
|
-
# POST /documents/#id/access/import
|
132
|
-
# Imports document access links from a file provided in the params.
|
133
|
-
def import
|
134
|
-
logger.debug("Import Action")
|
135
|
-
return unless params.dig(:document_access, :assets, :file)
|
136
|
-
|
137
|
-
respond_to do |format|
|
138
|
-
if DocumentAccess.import(params.dig(:document_access, :assets, :file))
|
139
|
-
format.html { redirect_to admin_document_accesses_path, notice: "Document access links were created successfully." }
|
140
|
-
else
|
141
|
-
format.html { redirect_to admin_document_accesses_path, notice: "Access URLs could not be created." }
|
142
|
-
end
|
143
|
-
rescue => e
|
144
|
-
format.html { redirect_to admin_document_accesses_path, notice: "Access URLs could not be created. #{e}" }
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
private
|
149
|
-
|
150
|
-
# Use callbacks to share common setup or constraints between actions.
|
151
|
-
# Finds and sets the document based on the document_id parameter.
|
152
|
-
def set_document
|
153
|
-
return unless params[:document_id] # If not nested
|
154
|
-
|
155
|
-
@document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:document_id])
|
156
|
-
end
|
157
|
-
|
158
|
-
# Finds and sets the document access based on the id parameter.
|
159
|
-
def set_document_access
|
160
|
-
@document_access = DocumentAccess.find(params[:id])
|
161
|
-
end
|
162
|
-
|
163
|
-
# Only allow a list of trusted parameters through.
|
164
|
-
# Permits only trusted parameters for document access.
|
165
|
-
def document_access_params
|
166
|
-
params.require(:document_access).permit(:friendlier_id, :institution_code, :access_url)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Admin::DocumentDownloadsController
|
4
|
-
module Admin
|
5
|
-
class DocumentDownloadsController < Admin::AdminController
|
6
|
-
before_action :set_document
|
7
|
-
before_action :set_document_download, only: %i[show edit update destroy]
|
8
|
-
|
9
|
-
# GET /document_downloads or /document_downloads.json
|
10
|
-
def index
|
11
|
-
@document_downloads = DocumentDownload.all
|
12
|
-
if params[:document_id]
|
13
|
-
@document_downloads = DocumentDownload.where(friendlier_id: @document.friendlier_id).order(position: :asc)
|
14
|
-
else
|
15
|
-
@pagy, @document_downloads = pagy(DocumentDownload.all.order(friendlier_id: :asc, updated_at: :desc), items: 20)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# GET /document_downloads/1 or /document_downloads/1.json
|
20
|
-
def show
|
21
|
-
end
|
22
|
-
|
23
|
-
# GET /document_downloads/new
|
24
|
-
def new
|
25
|
-
@document_download = DocumentDownload.new
|
26
|
-
end
|
27
|
-
|
28
|
-
# GET /document_downloads/1/edit
|
29
|
-
def edit
|
30
|
-
end
|
31
|
-
|
32
|
-
# POST /document_downloads or /document_downloads.json
|
33
|
-
def create
|
34
|
-
@document_download = DocumentDownload.new(document_download_params)
|
35
|
-
|
36
|
-
logger.debug("DD Params: #{DocumentDownload.new(document_download_params).inspect}")
|
37
|
-
logger.debug("Document DOWNLOAD: #{@document_download.inspect}")
|
38
|
-
|
39
|
-
respond_to do |format|
|
40
|
-
if @document_download.save
|
41
|
-
format.html do
|
42
|
-
redirect_to admin_document_document_downloads_path(@document_download.document),
|
43
|
-
notice: "Document download was successfully created."
|
44
|
-
end
|
45
|
-
format.json { render :show, status: :created, location: @document_download }
|
46
|
-
else
|
47
|
-
format.html { render :new, status: :unprocessable_entity }
|
48
|
-
format.json { render json: @document_download.errors, status: :unprocessable_entity }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# PATCH/PUT /document_downloads/1 or /document_downloads/1.json
|
54
|
-
def update
|
55
|
-
respond_to do |format|
|
56
|
-
if @document_download.update(document_download_params)
|
57
|
-
format.html do
|
58
|
-
redirect_to admin_document_document_downloads_path(@document_download.document),
|
59
|
-
notice: "Document download was successfully updated."
|
60
|
-
end
|
61
|
-
format.json { render :show, status: :ok, location: @document_download }
|
62
|
-
else
|
63
|
-
format.html { render :edit, status: :unprocessable_entity }
|
64
|
-
format.json { render json: @document_download.errors, status: :unprocessable_entity }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
# DELETE /document_downloads/1 or /document_downloads/1.json
|
70
|
-
def destroy
|
71
|
-
@document_download.destroy
|
72
|
-
|
73
|
-
respond_to do |format|
|
74
|
-
format.html { redirect_to admin_document_downloads_url, notice: "Document download was successfully destroyed." }
|
75
|
-
format.json { head :no_content }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def destroy_all
|
80
|
-
logger.debug("Destroy Downloads")
|
81
|
-
return unless params.dig(:document_download, :downloads, :file)
|
82
|
-
|
83
|
-
respond_to do |format|
|
84
|
-
if DocumentDownload.destroy_all(params.dig(:document_download, :downloads, :file))
|
85
|
-
format.html { redirect_to admin_document_downloads_path, notice: "Download Links were destroyed." }
|
86
|
-
else
|
87
|
-
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be destroyed." }
|
88
|
-
end
|
89
|
-
rescue => e
|
90
|
-
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be destroyed. #{e}" }
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# GET /documents/#id/downloads/import
|
95
|
-
# POST /documents/#id/downloads/import
|
96
|
-
def import
|
97
|
-
logger.debug("Import Downloads")
|
98
|
-
return unless params.dig(:document_download, :downloads, :file)
|
99
|
-
|
100
|
-
respond_to do |format|
|
101
|
-
if DocumentDownload.import(params.dig(:document_download, :downloads, :file))
|
102
|
-
format.html { redirect_to admin_document_downloads_path, notice: "Download Links were created successfully." }
|
103
|
-
else
|
104
|
-
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be created." }
|
105
|
-
end
|
106
|
-
rescue => e
|
107
|
-
format.html { redirect_to admin_document_downloads_path, notice: "Download Links could not be created. #{e}" }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
private
|
112
|
-
|
113
|
-
# Use callbacks to share common setup or constraints between actions.
|
114
|
-
def set_document
|
115
|
-
return unless params[:document_id] # If not nested
|
116
|
-
|
117
|
-
@document = Document.includes(:leaf_representative).find_by!(friendlier_id: params[:document_id])
|
118
|
-
end
|
119
|
-
|
120
|
-
def set_document_download
|
121
|
-
@document_download = DocumentDownload.find(params[:id])
|
122
|
-
end
|
123
|
-
|
124
|
-
# Only allow a list of trusted parameters through.
|
125
|
-
def document_download_params
|
126
|
-
params.require(:document_download).permit(:friendlier_id, :label, :value, :position)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "csv"
|
4
|
-
|
5
|
-
# DocumentDownload
|
6
|
-
class DocumentDownload < ApplicationRecord
|
7
|
-
belongs_to :document, inverse_of: :document_downloads, foreign_key: :friendlier_id, primary_key: :friendlier_id
|
8
|
-
after_save :reindex_document
|
9
|
-
|
10
|
-
# Validations
|
11
|
-
validates :label, :value, presence: true
|
12
|
-
|
13
|
-
def self.import(file)
|
14
|
-
logger.debug("CSV Import")
|
15
|
-
::CSV.foreach(file.path, headers: true) do |row|
|
16
|
-
logger.debug("CSV Row: #{row.to_hash}")
|
17
|
-
document_download = DocumentDownload.find_or_initialize_by(friendlier_id: row[0], label: row[1], value: row[2])
|
18
|
-
document_download.update!(row.to_hash)
|
19
|
-
end
|
20
|
-
true
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.destroy_all(file)
|
24
|
-
logger.debug("CSV Destroy")
|
25
|
-
::CSV.foreach(file.path, headers: true) do |row|
|
26
|
-
logger.debug("CSV Row: #{row.to_hash}")
|
27
|
-
DocumentDownload.destroy_by(id: row[0], friendlier_id: row[1])
|
28
|
-
end
|
29
|
-
true
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_csv
|
33
|
-
attributes.values
|
34
|
-
end
|
35
|
-
|
36
|
-
def reindex_document
|
37
|
-
document.save
|
38
|
-
end
|
39
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "csv"
|
4
|
-
|
5
|
-
# ExportCsvDocumentAccessLinksService
|
6
|
-
class ExportCsvDocumentAccessLinksService
|
7
|
-
def self.short_name
|
8
|
-
"Document Access Links"
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.call(document_ids)
|
12
|
-
ActionCable.server.broadcast("export_channel", {progress: 0})
|
13
|
-
|
14
|
-
document_ids = document_ids.flatten
|
15
|
-
total = document_ids.size
|
16
|
-
count = 0
|
17
|
-
slice_count = 100
|
18
|
-
csv_file = []
|
19
|
-
|
20
|
-
Rails.logger.debug { "\n\nExportCsvDocumentAccessLinksService: #{document_ids.inspect}\n\n" }
|
21
|
-
|
22
|
-
CSV.generate(headers: true) do |_csv|
|
23
|
-
csv_file << DocumentAccess.column_names
|
24
|
-
document_ids.each_slice(slice_count) do |slice|
|
25
|
-
# Broadcast progress percentage
|
26
|
-
count += slice_count
|
27
|
-
progress = ((count.to_f / total) * 100).round
|
28
|
-
progress = 100 if progress > 100
|
29
|
-
|
30
|
-
ActionCable.server.broadcast("export_channel", {progress: progress})
|
31
|
-
slice.each do |doc_id|
|
32
|
-
doc = Document.find_by(friendlier_id: doc_id)
|
33
|
-
|
34
|
-
Rails.logger.debug { "\n\nDocAccessLinks: #{doc.document_accesses.size}\n\n" }
|
35
|
-
|
36
|
-
doc.document_accesses.each do |access|
|
37
|
-
csv_file << access.to_csv
|
38
|
-
end
|
39
|
-
rescue NoMethodError
|
40
|
-
Rails.logger.debug { "\n\nExport Failed: #{doc_id.inspect}\n\n" }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
csv_file
|
46
|
-
end
|
47
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "csv"
|
4
|
-
|
5
|
-
# ExportCsvDocumentDownloadsService
|
6
|
-
class ExportCsvDocumentDownloadsService
|
7
|
-
def self.short_name
|
8
|
-
"Document Downloads"
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.call(document_ids)
|
12
|
-
ActionCable.server.broadcast("export_channel", {progress: 0})
|
13
|
-
|
14
|
-
document_ids = document_ids.flatten
|
15
|
-
total = document_ids.size
|
16
|
-
count = 0
|
17
|
-
slice_count = 100
|
18
|
-
csv_file = []
|
19
|
-
|
20
|
-
Rails.logger.debug { "\n\nExportCsvDocumentDownloadsService: #{document_ids.inspect}\n\n" }
|
21
|
-
|
22
|
-
CSV.generate(headers: true) do |_csv|
|
23
|
-
csv_file << DocumentDownload.column_names
|
24
|
-
document_ids.each_slice(slice_count) do |slice|
|
25
|
-
# Broadcast progress percentage
|
26
|
-
count += slice_count
|
27
|
-
progress = ((count.to_f / total) * 100).round
|
28
|
-
progress = 100 if progress > 100
|
29
|
-
|
30
|
-
ActionCable.server.broadcast("export_channel", {progress: progress})
|
31
|
-
slice.each do |doc_id|
|
32
|
-
doc = Document.find_by(friendlier_id: doc_id)
|
33
|
-
|
34
|
-
Rails.logger.debug { "\n\nDocDownloads: #{doc.document_downloads.size}\n\n" }
|
35
|
-
|
36
|
-
doc.document_downloads.each do |download|
|
37
|
-
csv_file << download.to_csv
|
38
|
-
end
|
39
|
-
rescue NoMethodError
|
40
|
-
Rails.logger.debug { "\n\nExport Failed: #{doc_id.inspect}\n\n" }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
csv_file
|
46
|
-
end
|
47
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
<%- @page_title = "GBL♦Admin - Document - Access Links" %>
|
2
|
-
|
3
|
-
<div class="row mb-2">
|
4
|
-
<div class="col">
|
5
|
-
<h1 style="width:100%;">
|
6
|
-
Document · Access Links
|
7
|
-
|
8
|
-
<% if params[:document_id] %>
|
9
|
-
<%= link_to '+ Import CSV', import_admin_document_document_accesses_path(@document), { class: 'btn btn-primary float-right' } %>
|
10
|
-
|
11
|
-
<%= link_to '+ New Access URL', new_admin_document_document_access_path(@document), { class: 'btn btn-primary float-right mr-2' } %>
|
12
|
-
<% else %>
|
13
|
-
<%= link_to '- Delete CSV', destroy_all_admin_document_accesses_path, { class: 'btn btn-danger float-right' } %>
|
14
|
-
<%= link_to '+ Import CSV', import_admin_document_accesses_path, { class: 'btn btn-primary float-right mr-4' } %>
|
15
|
-
<% end %>
|
16
|
-
</h1>
|
17
|
-
<% if params[:document_id] %>
|
18
|
-
<h2 class='h3'>
|
19
|
-
<%= link_to(@document.title, admin_document_path(@document)) %>
|
20
|
-
·
|
21
|
-
<%= @document_accesses.count %> urls
|
22
|
-
</h2>
|
23
|
-
<% else %>
|
24
|
-
<h2 class='h3'>Institutional Access Links</h2>
|
25
|
-
<% end %>
|
26
|
-
|
27
|
-
<% if @pagy %>
|
28
|
-
<h6>
|
29
|
-
<span class='float-left mt-3'>
|
30
|
-
<%== pagy_info(@pagy) %>
|
31
|
-
</span>
|
32
|
-
<span class='float-right'>
|
33
|
-
<%== pagy_bootstrap_nav(@pagy) %>
|
34
|
-
</span>
|
35
|
-
</h6>
|
36
|
-
<% end %>
|
37
|
-
|
38
|
-
|
39
|
-
<table class="table table-striped table-bordered sortable">
|
40
|
-
<thead class="thead-dark">
|
41
|
-
<tr>
|
42
|
-
<th class="header">id</th>
|
43
|
-
<th class="header">friendlier_id</th>
|
44
|
-
<th class="header">institution_code</th>
|
45
|
-
<th class="header">institution_name</th>
|
46
|
-
<th class="header" style="max-width:200px;">access_url</th>
|
47
|
-
<th class="header" colspan="2">Actions</th>
|
48
|
-
</tr>
|
49
|
-
</thead>
|
50
|
-
|
51
|
-
<tbody>
|
52
|
-
<% @document_accesses.each do |document_access| %>
|
53
|
-
<tr>
|
54
|
-
<td><%= document_access.id %></td>
|
55
|
-
<td><%= link_to document_access.friendlier_id, admin_document_path(document_access.document) %></td>
|
56
|
-
<td><%= document_access.institution_code %></td>
|
57
|
-
<td><%= b1g_institution_codes[document_access.institution_code] %></td>
|
58
|
-
<td><%= link_to(document_access.access_url, document_access.access_url) %></td>
|
59
|
-
<td><%= link_to 'Edit', edit_admin_document_document_access_path(document_access.document, document_access) %></td>
|
60
|
-
<td><%= link_to 'Destroy', admin_document_document_access_path(document_access.document, document_access), method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
61
|
-
</tr>
|
62
|
-
<% end %>
|
63
|
-
</tbody>
|
64
|
-
</table>
|
65
|
-
|
66
|
-
<% if @pagy %>
|
67
|
-
<h6>
|
68
|
-
<span class='float-left mt-3'>
|
69
|
-
<%== pagy_info(@pagy) %>
|
70
|
-
</span>
|
71
|
-
<span class='float-right'>
|
72
|
-
<%== pagy_bootstrap_nav(@pagy) %>
|
73
|
-
</span>
|
74
|
-
</h6>
|
75
|
-
<% end %>
|
76
|
-
</div>
|
77
|
-
</div>
|
78
|
-
</div>
|