geoblacklight_admin 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -3
  3. data/Rakefile +30 -12
  4. data/app/assets/javascripts/geoblacklight_admin.js +1 -0
  5. data/app/assets/stylesheets/geoblacklight_admin/_core.scss +5 -0
  6. data/app/assets/stylesheets/geoblacklight_admin/modules/_chosen.scss +425 -0
  7. data/app/controllers/admin/admin_controller.rb +4 -2
  8. data/app/controllers/admin/advanced_search_controller.rb +123 -103
  9. data/app/controllers/admin/api_controller.rb +123 -108
  10. data/app/controllers/admin/bookmarks_controller.rb +4 -4
  11. data/app/controllers/admin/bulk_actions_controller.rb +9 -4
  12. data/app/controllers/admin/concerns/upload_util.rb +2 -0
  13. data/app/controllers/admin/document_accesses_controller.rb +10 -4
  14. data/app/controllers/admin/document_assets_controller.rb +14 -11
  15. data/app/controllers/admin/document_downloads_controller.rb +12 -10
  16. data/app/controllers/admin/documents_controller.rb +16 -8
  17. data/app/controllers/admin/elements_controller.rb +6 -5
  18. data/app/controllers/admin/form_elements_controller.rb +4 -4
  19. data/app/controllers/admin/ids_controller.rb +107 -87
  20. data/app/controllers/admin/import_documents_controller.rb +1 -1
  21. data/app/controllers/admin/imports_controller.rb +7 -3
  22. data/app/controllers/admin/mappings_controller.rb +6 -4
  23. data/app/controllers/admin/notifications_controller.rb +1 -1
  24. data/app/controllers/admin/search_controller.rb +1 -1
  25. data/app/controllers/admin/users_controller.rb +1 -1
  26. data/app/helpers/form_input_helper.rb +4 -4
  27. data/app/helpers/geoblacklight_admin_helper.rb +1 -1
  28. data/app/jobs/export_job.rb +2 -1
  29. data/app/models/admin/bookmark.rb +18 -0
  30. data/app/models/api_search_builder.rb +3 -1
  31. data/app/models/document/bbox_validator.rb +9 -5
  32. data/app/models/document/date_range_validator.rb +13 -10
  33. data/app/models/document/geom_validator.rb +4 -2
  34. data/app/models/document.rb +15 -7
  35. data/app/models/element.rb +9 -7
  36. data/app/models/form_control.rb +2 -0
  37. data/app/models/form_element.rb +2 -0
  38. data/app/models/form_feature.rb +2 -0
  39. data/app/models/form_group.rb +2 -0
  40. data/app/models/form_header.rb +2 -0
  41. data/app/models/geoblacklight_admin/schema.rb +5 -2
  42. data/app/models/geoblacklight_admin.rb +2 -0
  43. data/app/models/import/csv_duplicates_validator.rb +2 -1
  44. data/app/models/import/csv_header_validator.rb +2 -1
  45. data/app/models/import.rb +4 -7
  46. data/app/models/user.rb +1 -1
  47. data/app/services/export_csv_service.rb +5 -1
  48. data/app/views/admin/advanced_search/facets.json.jbuilder +9 -8
  49. data/app/views/admin/advanced_search/index.json.jbuilder +8 -7
  50. data/app/views/admin/api/_field.json.jbuilder +1 -1
  51. data/app/views/admin/api/fetch.json.jbuilder +8 -7
  52. data/app/views/admin/api/index.json.jbuilder +8 -7
  53. data/app/views/admin/bookmarks/index.html.erb +2 -2
  54. data/app/views/admin/bulk_actions/index.html.erb +3 -3
  55. data/app/views/admin/bulk_actions/show.html.erb +1 -1
  56. data/app/views/admin/document_accesses/_form.html.erb +1 -1
  57. data/app/views/admin/document_accesses/destroy_all.html.erb +2 -2
  58. data/app/views/admin/document_accesses/edit.html.erb +1 -1
  59. data/app/views/admin/document_accesses/import.html.erb +2 -2
  60. data/app/views/admin/document_accesses/index.html.erb +9 -9
  61. data/app/views/admin/document_accesses/new.html.erb +1 -1
  62. data/app/views/admin/document_downloads/_form.html.erb +1 -1
  63. data/app/views/admin/document_downloads/destroy_all.html.erb +1 -1
  64. data/app/views/admin/document_downloads/edit.html.erb +2 -3
  65. data/app/views/admin/document_downloads/import.html.erb +1 -1
  66. data/app/views/admin/document_downloads/index.html.erb +9 -9
  67. data/app/views/admin/document_downloads/new.html.erb +1 -1
  68. data/app/views/admin/document_downloads/show.html.erb +2 -2
  69. data/app/views/admin/documents/_document_bookmark.html.erb +1 -1
  70. data/app/views/admin/documents/_form_nav.html.erb +1 -1
  71. data/app/views/admin/documents/_json_btaa_aardvark.jbuilder +1 -3
  72. data/app/views/admin/documents/edit.html.erb +1 -1
  73. data/app/views/admin/documents/features/_multiple_download_links.html.erb +2 -2
  74. data/app/views/admin/documents/index.html.erb +2 -4
  75. data/app/views/admin/documents/versions.html.erb +1 -1
  76. data/app/views/admin/elements/_element.json.jbuilder +4 -1
  77. data/app/views/admin/elements/_form.html.erb +1 -1
  78. data/app/views/admin/elements/edit.html.erb +2 -2
  79. data/app/views/admin/elements/index.html.erb +3 -3
  80. data/app/views/admin/elements/index.json.jbuilder +2 -0
  81. data/app/views/admin/elements/new.html.erb +1 -1
  82. data/app/views/admin/elements/show.html.erb +6 -6
  83. data/app/views/admin/elements/show.json.jbuilder +2 -0
  84. data/app/views/admin/form_elements/_form.html.erb +1 -1
  85. data/app/views/admin/form_elements/_form_element.json.jbuilder +2 -0
  86. data/app/views/admin/form_elements/edit.html.erb +2 -2
  87. data/app/views/admin/form_elements/index.html.erb +1 -1
  88. data/app/views/admin/form_elements/index.json.jbuilder +2 -0
  89. data/app/views/admin/form_elements/new.html.erb +1 -1
  90. data/app/views/admin/form_elements/show.html.erb +2 -2
  91. data/app/views/admin/form_elements/show.json.jbuilder +2 -0
  92. data/app/views/admin/ids/fetch.json.jbuilder +8 -7
  93. data/app/views/admin/ids/index.json.jbuilder +3 -2
  94. data/app/views/admin/import_documents/show.html.haml +1 -1
  95. data/app/views/admin/imports/_import.json.jbuilder +2 -1
  96. data/app/views/admin/imports/_show_failed_tab.html.erb +2 -2
  97. data/app/views/admin/imports/_show_success_tab.html.erb +1 -1
  98. data/app/views/admin/imports/edit.html.erb +3 -3
  99. data/app/views/admin/imports/index.html.erb +3 -3
  100. data/app/views/admin/layouts/application.html.erb +4 -4
  101. data/app/views/admin/mappings/_form.html.erb +1 -1
  102. data/app/views/admin/mappings/_mapping.json.jbuilder +2 -1
  103. data/app/views/admin/mappings/edit.html.erb +2 -2
  104. data/app/views/admin/mappings/new.html.erb +1 -1
  105. data/app/views/admin/mappings/show.html.erb +2 -2
  106. data/app/views/admin/notifications/index.html.erb +3 -3
  107. data/app/views/admin/search/index.html.erb +2 -2
  108. data/app/views/admin/shared/_navbar.html.erb +8 -3
  109. data/app/views/catalog/_show_gbl_admin.html.erb +3 -0
  110. data/config/routes.rb +37 -33
  111. data/db/migrate/20230316183001_add_geoblacklight_admin_gem.rb +408 -0
  112. data/db/seeds.rb +7 -5
  113. data/lib/generators/geoblacklight_admin/config_generator.rb +43 -31
  114. data/lib/generators/geoblacklight_admin/install_generator.rb +2 -3
  115. data/lib/generators/geoblacklight_admin/jobs_generator.rb +3 -2
  116. data/lib/generators/geoblacklight_admin/models_generator.rb +0 -1
  117. data/lib/generators/geoblacklight_admin/templates/_show_sidebar.html.erb +19 -0
  118. data/lib/generators/geoblacklight_admin/templates/_user_util_links.html.erb +1 -1
  119. data/lib/generators/geoblacklight_admin/templates/config/database.yml +9 -5
  120. data/lib/generators/geoblacklight_admin/templates/config/initializers/geoblacklight_admin.rb +1 -2
  121. data/lib/generators/geoblacklight_admin/templates/config/initializers/pagy.rb +150 -68
  122. data/lib/generators/geoblacklight_admin/templates/config/settings.yml +241 -0
  123. data/lib/generators/geoblacklight_admin/templates/package.json +1 -0
  124. data/lib/generators/geoblacklight_admin/views_generator.rb +0 -1
  125. data/lib/geoblacklight_admin/engine.rb +5 -6
  126. data/lib/geoblacklight_admin/version.rb +1 -1
  127. data/lib/geoblacklight_admin.rb +1 -1
  128. data/lib/tasks/geoblacklight_admin.rake +10 -6
  129. metadata +79 -48
  130. data/.editorconfig +0 -18
  131. data/.gitignore +0 -75
  132. data/.standard.yml +0 -4
  133. data/Gemfile +0 -59
  134. data/LICENSE +0 -21
  135. data/app/assets/images/.keep +0 -0
  136. data/app/controllers/admin/concerns/.keep +0 -0
  137. data/app/models/bookmark.rb +0 -17
  138. data/app/models/concerns/.keep +0 -0
  139. data/db/migrate/20230316183001_add_geoblacklight_admin.rb +0 -399
  140. data/geoblacklight_admin.gemspec +0 -67
  141. data/lib/generators/geoblacklight_admin/templates/.env.development.example +0 -28
  142. data/lib/generators/geoblacklight_admin/templates/.solr_wrapper.yml +0 -7
  143. data/lib/generators/geoblacklight_admin/templates/solr/snapshots/.keep +0 -0
  144. data/lib/tasks/.keep +0 -0
  145. data/spec/test_app_templates/lib/generators/test_app_generator.rb +0 -35
  146. data/template.rb +0 -16
@@ -0,0 +1,408 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddGeoblacklightAdminGem < ActiveRecord::Migration[6.1]
4
+ def change
5
+ # These are extensions that must be enabled in order to support this database
6
+ enable_extension 'pgcrypto'
7
+ enable_extension 'plpgsql'
8
+
9
+ create_function :kithe_models_friendlier_id_gen, sql_definition: <<-'SQL'
10
+ CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
11
+ RETURNS text
12
+ LANGUAGE plpgsql
13
+ AS $function$
14
+ DECLARE
15
+ new_id_int bigint;
16
+ new_id_str character varying := '';
17
+ done bool;
18
+ tries integer;
19
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
20
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
21
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
22
+ alphabet_length integer := array_length(alphabet, 1);
23
+
24
+ BEGIN
25
+ done := false;
26
+ tries := 0;
27
+ WHILE (NOT done) LOOP
28
+ tries := tries + 1;
29
+ IF (tries > 3) THEN
30
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
31
+ END IF;
32
+
33
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
34
+
35
+ -- convert bigint to a Base-36 alphanumeric string
36
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
37
+ -- https://gist.github.com/btbytes/7159902
38
+ WHILE new_id_int != 0 LOOP
39
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
40
+ new_id_int := new_id_int / alphabet_length;
41
+ END LOOP;
42
+
43
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
44
+ END LOOP;
45
+ RETURN new_id_str;
46
+ END;
47
+ $function$
48
+ SQL
49
+
50
+ create_table 'blazer_audits', force: :cascade do |t|
51
+ t.bigint 'user_id'
52
+ t.bigint 'query_id'
53
+ t.text 'statement'
54
+ t.string 'data_source'
55
+ t.datetime 'created_at'
56
+ t.index ['query_id'], name: 'index_blazer_audits_on_query_id'
57
+ t.index ['user_id'], name: 'index_blazer_audits_on_user_id'
58
+ end
59
+
60
+ create_table 'blazer_checks', force: :cascade do |t|
61
+ t.bigint 'creator_id'
62
+ t.bigint 'query_id'
63
+ t.string 'state'
64
+ t.string 'schedule'
65
+ t.text 'emails'
66
+ t.text 'slack_channels'
67
+ t.string 'check_type'
68
+ t.text 'message'
69
+ t.datetime 'last_run_at'
70
+ t.datetime 'created_at', precision: 6, null: false
71
+ t.datetime 'updated_at', precision: 6, null: false
72
+ t.index ['creator_id'], name: 'index_blazer_checks_on_creator_id'
73
+ t.index ['query_id'], name: 'index_blazer_checks_on_query_id'
74
+ end
75
+
76
+ create_table 'blazer_dashboard_queries', force: :cascade do |t|
77
+ t.bigint 'dashboard_id'
78
+ t.bigint 'query_id'
79
+ t.integer 'position'
80
+ t.datetime 'created_at', precision: 6, null: false
81
+ t.datetime 'updated_at', precision: 6, null: false
82
+ t.index ['dashboard_id'], name: 'index_blazer_dashboard_queries_on_dashboard_id'
83
+ t.index ['query_id'], name: 'index_blazer_dashboard_queries_on_query_id'
84
+ end
85
+
86
+ create_table 'blazer_dashboards', force: :cascade do |t|
87
+ t.bigint 'creator_id'
88
+ t.string 'name'
89
+ t.datetime 'created_at', precision: 6, null: false
90
+ t.datetime 'updated_at', precision: 6, null: false
91
+ t.index ['creator_id'], name: 'index_blazer_dashboards_on_creator_id'
92
+ end
93
+
94
+ create_table 'blazer_queries', force: :cascade do |t|
95
+ t.bigint 'creator_id'
96
+ t.string 'name'
97
+ t.text 'description'
98
+ t.text 'statement'
99
+ t.string 'data_source'
100
+ t.string 'status'
101
+ t.datetime 'created_at', precision: 6, null: false
102
+ t.datetime 'updated_at', precision: 6, null: false
103
+ t.index ['creator_id'], name: 'index_blazer_queries_on_creator_id'
104
+ end
105
+
106
+ create_table 'blazer_uploads', force: :cascade do |t|
107
+ t.bigint 'creator_id'
108
+ t.string 'table'
109
+ t.text 'description'
110
+ t.datetime 'created_at', precision: 6, null: false
111
+ t.datetime 'updated_at', precision: 6, null: false
112
+ t.index ['creator_id'], name: 'index_blazer_uploads_on_creator_id'
113
+ end
114
+
115
+ create_table 'bookmarks', force: :cascade do |t|
116
+ t.integer 'user_id', null: false
117
+ t.string 'user_type'
118
+ t.string 'document_id'
119
+ t.string 'document_type'
120
+ t.binary 'title'
121
+ t.datetime 'created_at', precision: 6, null: false
122
+ t.datetime 'updated_at', precision: 6, null: false
123
+ t.index ['document_id'], name: 'index_bookmarks_on_document_id'
124
+ t.index ['user_id'], name: 'index_bookmarks_on_user_id'
125
+ end
126
+
127
+ create_table 'bulk_action_document_transitions', force: :cascade do |t|
128
+ t.string 'to_state', null: false
129
+ t.text 'metadata', default: '{}'
130
+ t.integer 'sort_key', null: false
131
+ t.integer 'bulk_action_document_id', null: false
132
+ t.boolean 'most_recent', null: false
133
+ t.datetime 'created_at', precision: 6, null: false
134
+ t.datetime 'updated_at', precision: 6, null: false
135
+ t.index %w[bulk_action_document_id most_recent],
136
+ name: 'index_bulk_action_document_transitions_parent_most_recent', unique: true, where: 'most_recent'
137
+ t.index %w[bulk_action_document_id sort_key], name: 'index_bulk_action_document_transitions_parent_sort',
138
+ unique: true
139
+ end
140
+
141
+ create_table 'bulk_action_documents', force: :cascade do |t|
142
+ t.string 'friendlier_id', null: false
143
+ t.integer 'version', null: false
144
+ t.bigint 'bulk_action_id', null: false
145
+ t.datetime 'created_at', precision: 6, null: false
146
+ t.datetime 'updated_at', precision: 6, null: false
147
+ t.uuid 'document_id'
148
+ t.index ['bulk_action_id'], name: 'index_bulk_action_documents_on_bulk_action_id'
149
+ end
150
+
151
+ create_table 'bulk_action_transitions', force: :cascade do |t|
152
+ t.string 'to_state', null: false
153
+ t.text 'metadata', default: '{}'
154
+ t.integer 'sort_key', null: false
155
+ t.integer 'bulk_action_id', null: false
156
+ t.boolean 'most_recent', null: false
157
+ t.datetime 'created_at', precision: 6, null: false
158
+ t.datetime 'updated_at', precision: 6, null: false
159
+ t.index %w[bulk_action_id most_recent], name: 'index_bulk_action_transitions_parent_most_recent',
160
+ unique: true, where: 'most_recent'
161
+ t.index %w[bulk_action_id sort_key], name: 'index_bulk_action_transitions_parent_sort', unique: true
162
+ end
163
+
164
+ create_table 'bulk_actions', force: :cascade do |t|
165
+ t.string 'name'
166
+ t.string 'scope', null: false
167
+ t.string 'field_name', null: false
168
+ t.string 'field_value', null: false
169
+ t.text 'notes'
170
+ t.datetime 'created_at', precision: 6, null: false
171
+ t.datetime 'updated_at', precision: 6, null: false
172
+ end
173
+
174
+ create_table 'document_accesses', force: :cascade do |t|
175
+ t.string 'friendlier_id', null: false
176
+ t.string 'institution_code', null: false
177
+ t.text 'access_url', null: false
178
+ t.datetime 'created_at', precision: 6, null: false
179
+ t.datetime 'updated_at', precision: 6, null: false
180
+ end
181
+
182
+ create_table 'document_downloads', force: :cascade do |t|
183
+ t.string 'friendlier_id'
184
+ t.string 'label'
185
+ t.string 'value'
186
+ t.integer 'position'
187
+ t.datetime 'created_at', precision: 6, null: false
188
+ t.datetime 'updated_at', precision: 6, null: false
189
+ end
190
+
191
+ create_table 'document_transitions', force: :cascade do |t|
192
+ t.string 'to_state', null: false
193
+ t.text 'metadata', default: '{}'
194
+ t.integer 'sort_key', null: false
195
+ t.uuid 'kithe_model_id', null: false
196
+ t.boolean 'most_recent', null: false
197
+ t.datetime 'created_at', precision: 6, null: false
198
+ t.datetime 'updated_at', precision: 6, null: false
199
+ t.index %w[kithe_model_id most_recent], name: 'index_document_transitions_parent_most_recent', unique: true,
200
+ where: 'most_recent'
201
+ t.index %w[kithe_model_id sort_key], name: 'index_document_transitions_parent_sort', unique: true
202
+ end
203
+
204
+ create_table 'elements', force: :cascade do |t|
205
+ t.string 'label', null: false
206
+ t.string 'solr_field', null: false
207
+ t.string 'field_definition'
208
+ t.string 'field_type', null: false
209
+ t.boolean 'required', default: false, null: false
210
+ t.boolean 'repeatable', default: false, null: false
211
+ t.boolean 'formable', default: true, null: false
212
+ t.string 'placeholder_text'
213
+ t.string 'data_entry_hint'
214
+ t.string 'test_fixture_example'
215
+ t.string 'controlled_vocabulary'
216
+ t.string 'js_behaviors'
217
+ t.text 'html_attributes'
218
+ t.boolean 'display_only_on_persisted', default: false, null: false
219
+ t.boolean 'importable', default: true, null: false
220
+ t.boolean 'import_deliminated', default: false, null: false
221
+ t.string 'import_transformation_method'
222
+ t.boolean 'exportable', default: true, null: false
223
+ t.string 'export_transformation_method'
224
+ t.boolean 'indexable', default: true, null: false
225
+ t.string 'index_transformation_method'
226
+ t.string 'validation_method'
227
+ t.datetime 'created_at', precision: 6, null: false
228
+ t.datetime 'updated_at', precision: 6, null: false
229
+ t.integer 'position'
230
+ end
231
+
232
+ create_table 'form_elements', force: :cascade do |t|
233
+ t.string 'type', null: false
234
+ t.string 'label'
235
+ t.string 'element_solr_field'
236
+ t.integer 'position'
237
+ t.datetime 'created_at', precision: 6, null: false
238
+ t.datetime 'updated_at', precision: 6, null: false
239
+ end
240
+
241
+ create_table 'import_document_transitions', force: :cascade do |t|
242
+ t.string 'to_state', null: false
243
+ t.text 'metadata', default: '{}'
244
+ t.integer 'sort_key', null: false
245
+ t.integer 'import_document_id', null: false
246
+ t.boolean 'most_recent', null: false
247
+ t.datetime 'created_at', precision: 6, null: false
248
+ t.datetime 'updated_at', precision: 6, null: false
249
+ t.index %w[import_document_id most_recent], name: 'index_import_document_transitions_parent_most_recent',
250
+ unique: true, where: 'most_recent'
251
+ t.index %w[import_document_id sort_key], name: 'index_import_document_transitions_parent_sort', unique: true
252
+ end
253
+
254
+ create_table 'import_documents', force: :cascade do |t|
255
+ t.string 'friendlier_id', null: false
256
+ t.string 'title', null: false
257
+ t.json 'json_attributes', default: '{}'
258
+ t.bigint 'import_id', null: false
259
+ t.datetime 'created_at', precision: 6, null: false
260
+ t.datetime 'updated_at', precision: 6, null: false
261
+ t.index ['import_id'], name: 'index_import_documents_on_import_id'
262
+ end
263
+
264
+ create_table 'import_transitions', force: :cascade do |t|
265
+ t.string 'to_state', null: false
266
+ t.text 'metadata', default: '{}'
267
+ t.integer 'sort_key', null: false
268
+ t.integer 'import_id', null: false
269
+ t.boolean 'most_recent', null: false
270
+ t.datetime 'created_at', precision: 6, null: false
271
+ t.datetime 'updated_at', precision: 6, null: false
272
+ t.index %w[import_id most_recent], name: 'index_import_transitions_parent_most_recent', unique: true,
273
+ where: 'most_recent'
274
+ t.index %w[import_id sort_key], name: 'index_import_transitions_parent_sort', unique: true
275
+ end
276
+
277
+ create_table 'imports', force: :cascade do |t|
278
+ t.string 'name', null: false
279
+ t.string 'source'
280
+ t.text 'description'
281
+ t.string 'filename'
282
+ t.integer 'row_count'
283
+ t.text 'headers', default: [], array: true
284
+ t.string 'encoding'
285
+ t.string 'content_type'
286
+ t.string 'extension'
287
+ t.boolean 'validity', default: false, null: false
288
+ t.text 'validation_result'
289
+ t.datetime 'created_at', precision: 6, null: false
290
+ t.datetime 'updated_at', precision: 6, null: false
291
+ t.string 'type'
292
+ end
293
+
294
+ create_table 'kithe_derivatives', force: :cascade do |t|
295
+ t.string 'key', null: false
296
+ t.jsonb 'file_data'
297
+ t.uuid 'asset_id', null: false
298
+ t.datetime 'created_at', null: false
299
+ t.datetime 'updated_at', null: false
300
+ t.index %w[asset_id key], name: 'index_kithe_derivatives_on_asset_id_and_key', unique: true
301
+ t.index ['asset_id'], name: 'index_kithe_derivatives_on_asset_id'
302
+ end
303
+
304
+ create_table 'kithe_model_contains', id: false, force: :cascade do |t|
305
+ t.uuid 'containee_id'
306
+ t.uuid 'container_id'
307
+ t.index ['containee_id'], name: 'index_kithe_model_contains_on_containee_id'
308
+ t.index ['container_id'], name: 'index_kithe_model_contains_on_container_id'
309
+ end
310
+
311
+ create_table 'kithe_models', id: :uuid, default: -> { 'public.gen_random_uuid()' }, force: :cascade do |t|
312
+ t.string 'title', null: false
313
+ t.string 'type', null: false
314
+ t.integer 'position'
315
+ t.jsonb 'json_attributes'
316
+ t.datetime 'created_at', null: false
317
+ t.datetime 'updated_at', null: false
318
+ t.uuid 'parent_id'
319
+ t.string 'friendlier_id', default: lambda {
320
+ "kithe_models_friendlier_id_gen('2821109907456'::bigint, '101559956668415'::bigint)"
321
+ }, null: false
322
+ t.jsonb 'file_data'
323
+ t.uuid 'representative_id'
324
+ t.uuid 'leaf_representative_id'
325
+ t.integer 'kithe_model_type', null: false
326
+ t.bigint 'import_id'
327
+ t.string 'publication_state', default: 'draft'
328
+ t.index ['friendlier_id'], name: 'index_kithe_models_on_friendlier_id', unique: true
329
+ t.index ['import_id'], name: 'index_kithe_models_on_import_id'
330
+ t.index ['leaf_representative_id'], name: 'index_kithe_models_on_leaf_representative_id'
331
+ t.index ['parent_id'], name: 'index_kithe_models_on_parent_id'
332
+ t.index ['representative_id'], name: 'index_kithe_models_on_representative_id'
333
+ end
334
+
335
+ create_table 'mappings', force: :cascade do |t|
336
+ t.string 'source_header'
337
+ t.string 'destination_field'
338
+ t.boolean 'delimited'
339
+ t.string 'transformation_method'
340
+ t.bigint 'import_id', null: false
341
+ t.datetime 'created_at', precision: 6, null: false
342
+ t.datetime 'updated_at', precision: 6, null: false
343
+ t.index ['import_id'], name: 'index_mappings_on_import_id'
344
+ end
345
+
346
+ create_table 'notifications', force: :cascade do |t|
347
+ t.string 'recipient_type', null: false
348
+ t.bigint 'recipient_id', null: false
349
+ t.string 'type', null: false
350
+ t.jsonb 'params'
351
+ t.datetime 'read_at'
352
+ t.datetime 'created_at', precision: 6, null: false
353
+ t.datetime 'updated_at', precision: 6, null: false
354
+ t.index ['read_at'], name: 'index_notifications_on_read_at'
355
+ t.index %w[recipient_type recipient_id], name: 'index_notifications_on_recipient'
356
+ end
357
+
358
+ create_table 'users', force: :cascade do |t|
359
+ t.string 'email', default: '', null: false
360
+ t.string 'encrypted_password', default: '', null: false
361
+ t.string 'reset_password_token'
362
+ t.datetime 'reset_password_sent_at'
363
+ t.datetime 'remember_created_at'
364
+ t.datetime 'created_at', precision: 6, null: false
365
+ t.datetime 'updated_at', precision: 6, null: false
366
+ t.string 'invitation_token'
367
+ t.datetime 'invitation_created_at'
368
+ t.datetime 'invitation_sent_at'
369
+ t.datetime 'invitation_accepted_at'
370
+ t.integer 'invitation_limit'
371
+ t.string 'invited_by_type'
372
+ t.bigint 'invited_by_id'
373
+ t.integer 'invitations_count', default: 0
374
+ t.boolean 'admin', default: false, null: false
375
+ t.index ['email'], name: 'index_users_on_email', unique: true
376
+ t.index ['invitation_token'], name: 'index_users_on_invitation_token', unique: true
377
+ t.index ['invitations_count'], name: 'index_users_on_invitations_count'
378
+ t.index ['invited_by_id'], name: 'index_users_on_invited_by_id'
379
+ t.index %w[invited_by_type invited_by_id], name: 'index_users_on_invited_by_type_and_invited_by_id'
380
+ t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true
381
+ end
382
+
383
+ create_table 'versions', force: :cascade do |t|
384
+ t.string 'item_type', null: false
385
+ t.uuid 'item_id', null: false
386
+ t.string 'event', null: false
387
+ t.string 'whodunnit'
388
+ t.text 'object'
389
+ t.datetime 'created_at'
390
+ t.text 'object_changes'
391
+ t.index %w[item_type item_id], name: 'index_versions_on_item_type_and_item_id'
392
+ end
393
+
394
+ add_foreign_key 'bulk_action_document_transitions', 'bulk_action_documents'
395
+ add_foreign_key 'bulk_action_documents', 'bulk_actions'
396
+ add_foreign_key 'bulk_action_transitions', 'bulk_actions'
397
+ add_foreign_key 'import_document_transitions', 'import_documents'
398
+ add_foreign_key 'import_documents', 'imports'
399
+ add_foreign_key 'import_transitions', 'imports'
400
+ add_foreign_key 'kithe_derivatives', 'kithe_models', column: 'asset_id'
401
+ add_foreign_key 'kithe_model_contains', 'kithe_models', column: 'containee_id'
402
+ add_foreign_key 'kithe_model_contains', 'kithe_models', column: 'container_id'
403
+ add_foreign_key 'kithe_models', 'kithe_models', column: 'leaf_representative_id'
404
+ add_foreign_key 'kithe_models', 'kithe_models', column: 'parent_id'
405
+ add_foreign_key 'kithe_models', 'kithe_models', column: 'representative_id'
406
+ add_foreign_key 'mappings', 'imports'
407
+ end
408
+ end
data/db/seeds.rb CHANGED
@@ -1,4 +1,6 @@
1
- require "csv"
1
+ # frozen_string_literal: true
2
+
3
+ require 'csv'
2
4
 
3
5
  # frozen_string_literal: true
4
6
  # This file should contain all the record creation needed to seed the database with its default values.
@@ -10,17 +12,17 @@ require "csv"
10
12
  # Character.create(name: 'Luke', movie: movies.first)
11
13
 
12
14
  # Elements
13
- CSV.foreach(File.expand_path("seeds_elements.csv", File.dirname(__FILE__)), headers: true) do |row|
15
+ CSV.foreach(File.expand_path('seeds_elements.csv', File.dirname(__FILE__)), headers: true) do |row|
14
16
  hash = row.to_hash
15
17
  # YES, I'm calling eval - It's hard to seed a serialized field via a CSV file
16
- hash["html_attributes"] = eval(hash["html_attributes"]) if hash["html_attributes"].present?
18
+ hash['html_attributes'] = eval(hash['html_attributes']) if hash['html_attributes'].present?
17
19
  Element.create!(hash)
18
20
  end
19
21
 
20
22
  # FormElements
21
- CSV.foreach(File.expand_path("seeds_form_elements.csv", File.dirname(__FILE__)), headers: true) do |row|
23
+ CSV.foreach(File.expand_path('seeds_form_elements.csv', File.dirname(__FILE__)), headers: true) do |row|
22
24
  FormElement.create!(row.to_hash)
23
25
  end
24
26
 
25
27
  # Users
26
- User.create(email: "admin@geoblacklight.org", password: "123456", password_confirmation: "123456", admin: true)
28
+ User.create(email: 'admin@geoblacklight.org', password: '123456', password_confirmation: '123456', admin: true)