decidim-apartment 0.2.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 +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +167 -0
- data/Rakefile +405 -0
- data/app/commands/decidim/apartment/create_tenant_command.rb +94 -0
- data/app/commands/decidim/apartment/noop_settings_tab_command.rb +13 -0
- data/app/commands/decidim/apartment/performance/create_seed_tentant.rb +194 -0
- data/app/controllers/decidim/apartment/tenants_controller.rb +29 -0
- data/app/forms/decidim/apartment/admin/organization_settings_form.rb +44 -0
- data/app/forms/decidim/apartment/tenant_form.rb +35 -0
- data/app/helpers/decidim/apartment/dashboard_helper.rb +17 -0
- data/app/models/decidim/apartment/distribution_host.rb +21 -0
- data/app/models/decidim/apartment/distribution_key.rb +91 -0
- data/app/overrides/apartment_edit_organization.rb +21 -0
- data/app/overrides/apartment_system_asset.rb +10 -0
- data/app/packs/entrypoints/apartment_system_styles.scss +1 -0
- data/app/packs/stylesheets/decidim/apartment/system/_apartment_system_styles.scss +95 -0
- data/app/services/active_storage/service/apartment_disk_storage_service.rb +14 -0
- data/app/services/active_storage/service/apartment_s3_storage_service.rb +24 -0
- data/app/views/decidim/apartment/dashboard/_apartment.html.erb +55 -0
- data/app/views/decidim/apartment/dashboard/show.html.erb +3 -0
- data/app/views/decidim/apartment/organizations/_organizations_list.html.erb +45 -0
- data/app/views/decidim/apartment/organizations/index.html.erb +9 -0
- data/app/views/decidim/apartment/organizations/new.html.erb +11 -0
- data/config/assets.rb +15 -0
- data/config/locales/decidim_apartment.en.yml +58 -0
- data/config/locales/decidim_apartment_toggle.en.yml +15 -0
- data/db/migrate/20250814075441_add_apartment_distribution_key.rb +15 -0
- data/db/migrate/20260907100000_add_apartment_distribution_hosts.rb +32 -0
- data/lib/decidim/apartment/active_storage_wrap.rb +51 -0
- data/lib/decidim/apartment/allowed_hosts.rb +78 -0
- data/lib/decidim/apartment/cache_namespace.rb +38 -0
- data/lib/decidim/apartment/config_registry.rb +102 -0
- data/lib/decidim/apartment/configuration.rb +11 -0
- data/lib/decidim/apartment/convert/attachment_integrity.rb +130 -0
- data/lib/decidim/apartment/convert/constraint_graph_pruner.rb +183 -0
- data/lib/decidim/apartment/convert/errors.rb +9 -0
- data/lib/decidim/apartment/convert/host_gate.rb +76 -0
- data/lib/decidim/apartment/convert/org_distribution_report.rb +106 -0
- data/lib/decidim/apartment/convert/org_metrics.rb +164 -0
- data/lib/decidim/apartment/convert/organization_converter.rb +154 -0
- data/lib/decidim/apartment/convert/organization_pruner.rb +210 -0
- data/lib/decidim/apartment/convert/organization_resolver.rb +386 -0
- data/lib/decidim/apartment/convert/paper_trail_report.rb +127 -0
- data/lib/decidim/apartment/convert/preflight.rb +140 -0
- data/lib/decidim/apartment/convert/schema_cloner.rb +157 -0
- data/lib/decidim/apartment/convert/storage_preconditions.rb +43 -0
- data/lib/decidim/apartment/convert/storage_relocator.rb +118 -0
- data/lib/decidim/apartment/convert/table_registry.rb +109 -0
- data/lib/decidim/apartment/convert.rb +20 -0
- data/lib/decidim/apartment/demo/blob.rb +31 -0
- data/lib/decidim/apartment/demo/city.rb +107 -0
- data/lib/decidim/apartment/demo/education.rb +83 -0
- data/lib/decidim/apartment/demo/foss.rb +153 -0
- data/lib/decidim/apartment/demo/homepage.rb +39 -0
- data/lib/decidim/apartment/demo/localized.rb +27 -0
- data/lib/decidim/apartment/demo/provision.rb +107 -0
- data/lib/decidim/apartment/demo/runner.rb +66 -0
- data/lib/decidim/apartment/demo/system_admin.rb +24 -0
- data/lib/decidim/apartment/demo.rb +19 -0
- data/lib/decidim/apartment/elevator.rb +20 -0
- data/lib/decidim/apartment/engine.rb +140 -0
- data/lib/decidim/apartment/excluded_model_pin.rb +40 -0
- data/lib/decidim/apartment/host_registry.rb +71 -0
- data/lib/decidim/apartment/import/confirm_prompt.rb +46 -0
- data/lib/decidim/apartment/import/database_restorer.rb +105 -0
- data/lib/decidim/apartment/import/dump_host_extractor.rb +67 -0
- data/lib/decidim/apartment/import/dump_preview.rb +96 -0
- data/lib/decidim/apartment/import/dump_transformer.rb +87 -0
- data/lib/decidim/apartment/import/errors.rb +9 -0
- data/lib/decidim/apartment/import/provision_tenant.rb +50 -0
- data/lib/decidim/apartment/import/schema_auditor.rb +118 -0
- data/lib/decidim/apartment/import/storage_migrator.rb +71 -0
- data/lib/decidim/apartment/import/tenant_context.rb +226 -0
- data/lib/decidim/apartment/import/tenant_importer.rb +73 -0
- data/lib/decidim/apartment/import/verifier.rb +58 -0
- data/lib/decidim/apartment/import.rb +15 -0
- data/lib/decidim/apartment/ops/attribute_cryptor.rb +68 -0
- data/lib/decidim/apartment/ops/ciphertext_rewriter.rb +230 -0
- data/lib/decidim/apartment/ops/encrypted_attribute_catalog.rb +106 -0
- data/lib/decidim/apartment/ops/encrypted_attribute_registry.rb +74 -0
- data/lib/decidim/apartment/ops/postgres_permissions.rb +179 -0
- data/lib/decidim/apartment/ops/secret_key_preflight.rb +94 -0
- data/lib/decidim/apartment/ops/secret_key_rotation.rb +226 -0
- data/lib/decidim/apartment/ops/storage_transfer.rb +188 -0
- data/lib/decidim/apartment/overrides/active_job_with_tenant.rb +38 -0
- data/lib/decidim/apartment/overrides/core_seeds.rb +31 -0
- data/lib/decidim/apartment/overrides/create_organization_command.rb +69 -0
- data/lib/decidim/apartment/overrides/dashboard_controller.rb +30 -0
- data/lib/decidim/apartment/overrides/decidim_seed.rb +16 -0
- data/lib/decidim/apartment/overrides/organizations_controller_overrides.rb +75 -0
- data/lib/decidim/apartment/overrides/postgresql_enable_extension.rb +15 -0
- data/lib/decidim/apartment/overrides/postgresql_schema_adapter.rb +34 -0
- data/lib/decidim/apartment/overrides/postgresql_schema_import.rb +35 -0
- data/lib/decidim/apartment/overrides/postgresql_schema_search_path.rb +15 -0
- data/lib/decidim/apartment/overrides/postgresql_schema_statements.rb +17 -0
- data/lib/decidim/apartment/overrides/seeds.rb +52 -0
- data/lib/decidim/apartment/overrides/tenant_init_without_database.rb +19 -0
- data/lib/decidim/apartment/overrides/update_organization_command.rb +38 -0
- data/lib/decidim/apartment/postgres_extensions.rb +198 -0
- data/lib/decidim/apartment/rake_replace.rb +21 -0
- data/lib/decidim/apartment/schema_search_path.rb +43 -0
- data/lib/decidim/apartment/system_organization.rb +67 -0
- data/lib/decidim/apartment/test/factories.rb +11 -0
- data/lib/decidim/apartment/test/seeds/association_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/association_2.jpeg +0 -0
- data/lib/decidim/apartment/test/seeds/association_3.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/association_4.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/bg_Dusty Grass.png +0 -0
- data/lib/decidim/apartment/test/seeds/bg_Hyper Blue.png +0 -0
- data/lib/decidim/apartment/test/seeds/bg_Moonwalker.png +0 -0
- data/lib/decidim/apartment/test/seeds/bg_Neon Green.png +0 -0
- data/lib/decidim/apartment/test/seeds/bg_Visual Blue.png +0 -0
- data/lib/decidim/apartment/test/seeds/bg_hinehouse.png +0 -0
- data/lib/decidim/apartment/test/seeds/city_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/city_2.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/city_3.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/city_4.webp +0 -0
- data/lib/decidim/apartment/test/seeds/city_5.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/debian.jpeg +0 -0
- data/lib/decidim/apartment/test/seeds/democratic_school_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/drupal.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/foss.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/immich.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/kid_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/kid_2.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/montessori_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/montessori_2.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/neighboor_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/neighbor_2.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/neighbor_3.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_cubes-3_4_2_0-0_0_1__hsla(240, 7_, 18_, 1.00)_hsla(47, 81_, 61_, 1.00).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_cubes-3_4_2_0-0_55_1__hsla(240, 7_, 18_, 1.00)_hsla(47, 81_, 61_, 1.00)(1).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_cubes-3_4_2_0-0_55_1__hsla(240, 7_, 18_, 1.00)_hsla(47, 81_, 61_, 1.00).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_diamonds-1_1_10_0-0_0_1__hsla(240, 7_, 18_, 1.00)_hsla(174, 100_, 29_, 1.00).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_diamonds-1_1_2_0-0_0_1__hsla(240, 7_, 18_, 1.00)_hsla(174, 100_, 29_, 1.00).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_diamonds-1_5_10_0-0_0_1__hsla(240, 7_, 18_, 1.00)_hsla(174, 100_, 29_, 1.00).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_diamonds-1_5_2_0-0_0_1__hsla(240, 7_, 18_, 1.00)_hsla(174, 100_, 29_, 1.00).png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_new_01.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_new_02.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_new_03.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_01.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_02.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_03.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_04.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_05.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_06.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_07.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_08.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_09.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_10.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_11.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_12.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_13.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_14.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_15.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_16.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_01.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_02.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_03.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_04.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_05.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_06.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_07.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_08.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_09.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_10.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_11.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_12.png +0 -0
- data/lib/decidim/apartment/test/seeds/pattern_squares_and_circles_13.png +0 -0
- data/lib/decidim/apartment/test/seeds/rails.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/school_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/school_3.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/school_4.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/school_5.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/silverstripe.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/street_1.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/street_2.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/street_3.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/urban_agri_1.webp +0 -0
- data/lib/decidim/apartment/test/seeds/urban_agri_2.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/urban_agri_3.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/urban_agri_4.jpg +0 -0
- data/lib/decidim/apartment/test/seeds/world-map-colors.png +0 -0
- data/lib/decidim/apartment/version.rb +44 -0
- data/lib/decidim/apartment.rb +69 -0
- data/lib/tasks/decidim_apartment_check_install.rake +58 -0
- data/lib/tasks/decidim_apartment_convert.rake +60 -0
- data/lib/tasks/decidim_apartment_gem_manager.rake +62 -0
- data/lib/tasks/decidim_apartment_import.rake +39 -0
- data/lib/tasks/decidim_apartment_install_extension.rake +49 -0
- data/lib/tasks/decidim_apartment_performance_seed.rake +12 -0
- data/lib/tasks/decidim_apartment_rotate.rake +17 -0
- data/lib/tasks/decidim_apartment_storage.rake +27 -0
- data/lib/tasks/decidim_download_your_data_tasks.rake +121 -0
- data/lib/tasks/decidim_mailers.rake +38 -0
- data/lib/tasks/decidim_meetings.rake +30 -0
- data/lib/tasks/decidim_metrics_tasks.rake +29 -0
- data/lib/tasks/decidim_open_data_tasks.rake +24 -0
- data/lib/tasks/decidim_participatory_processes.rake +20 -0
- data/lib/tasks/decidim_reminders_tasks.rake +24 -0
- metadata +361 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
# This holds the decidim-apartment version.
|
|
5
|
+
module Apartment
|
|
6
|
+
MODULE_NAME = "decidim_apartment"
|
|
7
|
+
|
|
8
|
+
def self.version
|
|
9
|
+
"0.2.0" # DO NOT UPDATE MANUALLY
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.decidim_version
|
|
13
|
+
["~> 0.29", ">= 0.29.0"].freeze
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.toggle_available?
|
|
17
|
+
Decidim::Toggle.gem_present?("decidim-apartment")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.geo_available?
|
|
21
|
+
Gem.loaded_specs.has_key?("decidim-decidim_geo")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.sidekiq_available?
|
|
25
|
+
Gem.loaded_specs.has_key?("sidekiq")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.good_job_available?
|
|
29
|
+
Gem.loaded_specs.has_key?("good_job")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# PostGIS types and pg_dump schema cloning require SQL-based tenant creation.
|
|
33
|
+
# Without geo/postgis, ros-apartment loads db/schema.rb per tenant.
|
|
34
|
+
def self.use_sql?
|
|
35
|
+
geo_available? || postgis_adapter?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.postgis_adapter?
|
|
39
|
+
ActiveRecord::Base.connection_db_config.adapter.to_s.match?(/postgis/i)
|
|
40
|
+
rescue StandardError
|
|
41
|
+
false
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "apartment"
|
|
4
|
+
require "apartment/elevators/generic"
|
|
5
|
+
require "decidim/core/seeds"
|
|
6
|
+
require "decidim/toggle"
|
|
7
|
+
|
|
8
|
+
require_relative "apartment/configuration"
|
|
9
|
+
require_relative "apartment/config_registry"
|
|
10
|
+
require_relative "apartment/ops/encrypted_attribute_registry"
|
|
11
|
+
require_relative "apartment/excluded_model_pin"
|
|
12
|
+
require_relative "apartment/version"
|
|
13
|
+
require_relative "apartment/host_registry"
|
|
14
|
+
require_relative "apartment/allowed_hosts"
|
|
15
|
+
require_relative "apartment/schema_search_path"
|
|
16
|
+
require_relative "apartment/postgres_extensions"
|
|
17
|
+
require_relative "apartment/cache_namespace"
|
|
18
|
+
require_relative "apartment/active_storage_wrap"
|
|
19
|
+
|
|
20
|
+
require_relative "apartment/overrides/create_organization_command"
|
|
21
|
+
require_relative "apartment/overrides/update_organization_command"
|
|
22
|
+
|
|
23
|
+
require_relative "apartment/overrides/organizations_controller_overrides"
|
|
24
|
+
require_relative "apartment/overrides/active_job_with_tenant"
|
|
25
|
+
require_relative "apartment/overrides/dashboard_controller"
|
|
26
|
+
require_relative "apartment/overrides/seeds"
|
|
27
|
+
require_relative "apartment/overrides/core_seeds"
|
|
28
|
+
require_relative "apartment/overrides/decidim_seed"
|
|
29
|
+
require_relative "apartment/overrides/postgresql_schema_adapter"
|
|
30
|
+
require_relative "apartment/overrides/postgresql_schema_import"
|
|
31
|
+
require_relative "apartment/overrides/postgresql_schema_statements"
|
|
32
|
+
require_relative "apartment/overrides/postgresql_schema_search_path"
|
|
33
|
+
require_relative "apartment/overrides/postgresql_enable_extension"
|
|
34
|
+
require_relative "apartment/overrides/tenant_init_without_database"
|
|
35
|
+
|
|
36
|
+
require_relative "apartment/demo"
|
|
37
|
+
require_relative "apartment/elevator"
|
|
38
|
+
require_relative "apartment/system_organization"
|
|
39
|
+
require_relative "apartment/engine"
|
|
40
|
+
|
|
41
|
+
module Decidim
|
|
42
|
+
##
|
|
43
|
+
# Main module configuration
|
|
44
|
+
module Apartment
|
|
45
|
+
def self.config
|
|
46
|
+
@config ||= Configuration.new
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.configure
|
|
50
|
+
yield(config)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.config_registry
|
|
54
|
+
@config_registry ||= ConfigRegistry.new
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.register_apartment_config(&)
|
|
58
|
+
config_registry.register(&)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.encrypted_attribute_registry
|
|
62
|
+
@encrypted_attribute_registry ||= Ops::EncryptedAttributeRegistry.new
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.register_encrypted_attribute(&)
|
|
66
|
+
encrypted_attribute_registry.tap { |registry| yield registry }
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
desc "Check if Decidim Apartment is installed in your Rails application"
|
|
5
|
+
task check_install: :environment do
|
|
6
|
+
raise "ros-apartment is not installed" unless Gem.loaded_specs.has_key?("ros-apartment")
|
|
7
|
+
|
|
8
|
+
system("bundle exec rails decidim_apartment:install:migrations")
|
|
9
|
+
begin
|
|
10
|
+
result = system("bundle exec rails db:migrate:status | grep -q down")
|
|
11
|
+
raise "Migrations are not installed. Run bundle exec rails db:migrate" if result
|
|
12
|
+
rescue StandardError
|
|
13
|
+
raise "Migrations are not installed. Run bundle exec rails db:migrate"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
raise "schema.rb is not generated" unless Rails.root.join("db/schema.rb").exist?
|
|
17
|
+
|
|
18
|
+
is_ruby = Rails.application.config.active_record.schema_format == :ruby
|
|
19
|
+
raise "Rails.application.config.active_record.schema_format is not supported, use ruby instead" unless is_ruby
|
|
20
|
+
|
|
21
|
+
assert_runtime_search_path!
|
|
22
|
+
assert_runtime_storage!
|
|
23
|
+
assert_runtime_cache_namespace!
|
|
24
|
+
|
|
25
|
+
puts "Decidim Apartment is installed in your Rails application"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def assert_runtime_search_path!
|
|
30
|
+
path = ActiveRecord::Base.connection.schema_search_path.to_s
|
|
31
|
+
return if Decidim::Apartment::SchemaSearchPath.schema_names(path).include?("public")
|
|
32
|
+
|
|
33
|
+
raise "public is not in the live schema_search_path (got #{path.inspect})"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def assert_runtime_storage!
|
|
37
|
+
return if Rails.env.test?
|
|
38
|
+
|
|
39
|
+
service = ActiveStorage::Blob.service
|
|
40
|
+
name = service.class.name
|
|
41
|
+
return if name.include?("Apartment")
|
|
42
|
+
|
|
43
|
+
raise "Active Storage service must be ApartmentDiskStorage or ApartmentS3Storage (got #{name})"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def assert_runtime_cache_namespace!
|
|
47
|
+
store = Rails.application.config.cache_store
|
|
48
|
+
return if store.blank? || store == :null_store
|
|
49
|
+
|
|
50
|
+
config = Array(store)
|
|
51
|
+
return if config.first == :null_store
|
|
52
|
+
|
|
53
|
+
options = config.find { |item| item.is_a?(Hash) }
|
|
54
|
+
namespace = options && options[:namespace]
|
|
55
|
+
return if namespace.respond_to?(:call)
|
|
56
|
+
|
|
57
|
+
raise "cache_store namespace must be a Proc including Apartment::Tenant.current"
|
|
58
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
namespace :convert do
|
|
5
|
+
desc "Preflight: organizations, copyable tables, unscoped tables"
|
|
6
|
+
task preflight: :environment do
|
|
7
|
+
require "decidim/apartment/convert"
|
|
8
|
+
Decidim::Apartment::Convert::Preflight.call
|
|
9
|
+
rescue Decidim::Apartment::Convert::ConvertError => e
|
|
10
|
+
abort e.message
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "Clone public data into tenant for ORG_ID (Tenant.create + SchemaCloner)"
|
|
14
|
+
task clone: :environment do
|
|
15
|
+
require "decidim/apartment/convert"
|
|
16
|
+
org_id = ENV.fetch("ORG_ID") { abort "ORG_ID is required" }
|
|
17
|
+
Apartment::Tenant.switch("public") do
|
|
18
|
+
org = Decidim::Organization.find(org_id)
|
|
19
|
+
Decidim::Apartment::Convert::OrganizationConverter.clone_for!(org)
|
|
20
|
+
end
|
|
21
|
+
rescue Decidim::Apartment::Convert::ConvertError, ActiveRecord::RecordNotFound => e
|
|
22
|
+
abort e.message
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "Prune other organizations from tenant schema (ORG_ID, TARGET_TENANT)"
|
|
26
|
+
task prune: :environment do
|
|
27
|
+
require "decidim/apartment/convert"
|
|
28
|
+
org_id = ENV.fetch("ORG_ID") { abort "ORG_ID is required" }
|
|
29
|
+
target = ENV.fetch("TARGET_TENANT") { abort "TARGET_TENANT is required" }
|
|
30
|
+
Decidim::Apartment::Import::ConfirmPrompt.ask(
|
|
31
|
+
"Prune other organizations from #{target} (keep org #{org_id})? [y/N]"
|
|
32
|
+
)
|
|
33
|
+
Decidim::Apartment::Convert::OrganizationPruner.call(target_schema: target, keep_org_id: org_id)
|
|
34
|
+
rescue Decidim::Apartment::Convert::ConvertError => e
|
|
35
|
+
abort e.message
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
desc "Convert one organization: Tenant.create → clone → prune (ORG_ID)"
|
|
39
|
+
task organization: :environment do
|
|
40
|
+
require "decidim/apartment/convert"
|
|
41
|
+
org_id = ENV.fetch("ORG_ID") { abort "ORG_ID is required" }
|
|
42
|
+
Decidim::Apartment::Convert::OrganizationConverter.call(org_id: org_id)
|
|
43
|
+
rescue Decidim::Apartment::Convert::ConvertError => e
|
|
44
|
+
abort e.message
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc "Convert every organization in public (weeks-long migration: one org per invocation)"
|
|
48
|
+
task run: :environment do
|
|
49
|
+
require "decidim/apartment/convert"
|
|
50
|
+
Apartment::Tenant.switch("public") do
|
|
51
|
+
Decidim::Organization.order(:id).pluck(:id).each do |org_id|
|
|
52
|
+
puts "=== convert organization #{org_id} ==="
|
|
53
|
+
Decidim::Apartment::Convert::OrganizationConverter.call(org_id: org_id)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
rescue Decidim::Apartment::Convert::ConvertError => e
|
|
57
|
+
abort e.message
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "decidim/gem_manager"
|
|
4
|
+
|
|
5
|
+
def install_decidim_apartment_npm
|
|
6
|
+
decidim_apartment_npm_dependencies.each do |type, packages|
|
|
7
|
+
puts "install NPM packages. You can also do this manually with this command:"
|
|
8
|
+
puts "npm i --legacy-peer-deps --save-#{type} #{packages.join(" ")}"
|
|
9
|
+
decidim_apartment_system! "npm i --legacy-peer-deps --save-#{type} #{packages.join(" ")}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def decidim_apartment_npm_dependencies
|
|
14
|
+
@decidim_apartment_npm_dependencies ||= begin
|
|
15
|
+
package_json = JSON.parse(File.read(decidim_apartment_path.join("package.json")))
|
|
16
|
+
|
|
17
|
+
{
|
|
18
|
+
prod: package_json["dependencies"].map { |package, version| "#{package}@#{version}" },
|
|
19
|
+
dev: package_json["devDependencies"].map { |package, version| "#{package}@#{version}" }
|
|
20
|
+
}.freeze
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def decidim_apartment_path
|
|
25
|
+
return unless Gem.loaded_specs.has_key?(decidim_apartment_name)
|
|
26
|
+
|
|
27
|
+
@decidim_apartment_path ||= Pathname.new(decidim_apartment.full_gem_path)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def decidim_apartment
|
|
31
|
+
@decidim_apartment ||= Gem.loaded_specs[decidim_apartment_name]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def rails_app_path
|
|
35
|
+
@rails_app_path ||= Rails.root
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def decidim_apartment_system!(command)
|
|
39
|
+
system("cd #{rails_app_path} && #{command}") || abort("\n== Command #{command} failed ==")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def decidim_apartment_name
|
|
43
|
+
"decidim_apartment"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
namespace :decidim_apartment do
|
|
47
|
+
namespace :webpacker do
|
|
48
|
+
desc "Installs Decidim Apartment node deps in Rails instance application"
|
|
49
|
+
task install: :environment do
|
|
50
|
+
raise "Decidim gem is not installed" if decidim_path.nil?
|
|
51
|
+
|
|
52
|
+
install_decidim_geo_npm
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc "Adds Decidim Apartment dependencies in package.json"
|
|
56
|
+
task upgrade: :environment do
|
|
57
|
+
raise "Decidim gem is not installed" if decidim_path.nil?
|
|
58
|
+
|
|
59
|
+
install_decidim_geo_npm
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
namespace :import do
|
|
5
|
+
desc "Import a tenant dump (preflight, confirm, database, storage, verify)"
|
|
6
|
+
task tenant: :environment do
|
|
7
|
+
require "decidim/apartment/import"
|
|
8
|
+
Decidim::Apartment::Import::TenantImporter.run(mode: :full)
|
|
9
|
+
rescue Decidim::Apartment::Import::ImportError => e
|
|
10
|
+
abort e.message
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc "Import tenant database from a SQL dump"
|
|
14
|
+
task database: :environment do
|
|
15
|
+
require "decidim/apartment/import"
|
|
16
|
+
Decidim::Apartment::Import::TenantImporter.run(mode: :database)
|
|
17
|
+
rescue Decidim::Apartment::Import::ImportError => e
|
|
18
|
+
abort e.message
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "Import tenant ActiveStorage blobs from a source folder to S3"
|
|
22
|
+
task storage: :environment do
|
|
23
|
+
require "decidim/apartment/import"
|
|
24
|
+
Decidim::Apartment::Import::TenantImporter.run(mode: :storage)
|
|
25
|
+
rescue Decidim::Apartment::Import::ImportError => e
|
|
26
|
+
abort e.message
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Verify a tenant import (read-only)"
|
|
30
|
+
task verify: :environment do
|
|
31
|
+
require "decidim/apartment/import"
|
|
32
|
+
context = Decidim::Apartment::Import::TenantContext.build!(mode: :verify)
|
|
33
|
+
Decidim::Apartment::Import::TenantContext.new(mode: :verify).print_summary!(context)
|
|
34
|
+
Decidim::Apartment::Import::Verifier.call(context: context)
|
|
35
|
+
rescue Decidim::Apartment::Import::ImportError => e
|
|
36
|
+
abort e.message
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# @see https://github.com/rails-on-services/apartment?tab=readme-ov-file#1-ensure-the-extensions-schema-is-created-when-the-database-is-created
|
|
4
|
+
namespace :decidim_apartment do
|
|
5
|
+
desc "Install needed pg extensions into public"
|
|
6
|
+
task install_pg_extension: :environment do
|
|
7
|
+
Decidim::Apartment::PostgresExtensions.prepare!
|
|
8
|
+
installer = Decidim::Apartment::PostgresExtensions.new
|
|
9
|
+
if installer.ready?
|
|
10
|
+
puts "✓ Decidim Apartment: public extensions are ready"
|
|
11
|
+
puts " with extensions: #{Decidim::Apartment::PostgresExtensions::REQUIRED.join(", ")}."
|
|
12
|
+
puts " Run `\\dx` in a psql console to check extensions."
|
|
13
|
+
else
|
|
14
|
+
puts "✗ Decidim Apartment: public extensions are NOT ready"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def decidim_apartment_reinvoke_pg_extensions!
|
|
20
|
+
Rake::Task["decidim_apartment:install_pg_extension"].reenable
|
|
21
|
+
Rake::Task["decidim_apartment:install_pg_extension"].invoke
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# After db:create the new DB exists; install extensions there.
|
|
25
|
+
Rake::Task["db:create"].enhance do
|
|
26
|
+
decidim_apartment_reinvoke_pg_extensions!
|
|
27
|
+
end
|
|
28
|
+
Rake::Task["db:schema:dump"].enhance do
|
|
29
|
+
decidim_apartment_reinvoke_pg_extensions!
|
|
30
|
+
end
|
|
31
|
+
Rake::Task["db:test:purge"].enhance do
|
|
32
|
+
decidim_apartment_reinvoke_pg_extensions!
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Rails 8 db:migrate on an empty DB calls load_schema in-process before after-hooks.
|
|
36
|
+
# schema.rb has enable_extension — extensions must exist first.
|
|
37
|
+
# ponytail: rake prerequisite; do not patch DatabaseTasks
|
|
38
|
+
Rake::Task["db:migrate"].enhance(["decidim_apartment:install_pg_extension"])
|
|
39
|
+
Rake::Task["db:schema:load"].enhance(["decidim_apartment:install_pg_extension"])
|
|
40
|
+
|
|
41
|
+
# Migrations call enable_extension into the first search_path schema unless
|
|
42
|
+
# relocated after the run.
|
|
43
|
+
# ponytail: rake reenable after db:migrate; invoke is once
|
|
44
|
+
Rake::Task["db:migrate"].enhance do
|
|
45
|
+
decidim_apartment_reinvoke_pg_extensions!
|
|
46
|
+
end
|
|
47
|
+
Rake::Task["db:schema:load"].enhance do
|
|
48
|
+
decidim_apartment_reinvoke_pg_extensions!
|
|
49
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
desc "Seed the database for performance testings"
|
|
5
|
+
task performance_seed: :environment do
|
|
6
|
+
user_count = (ENV["PERF_USER_COUNT"].presence || "40").to_i
|
|
7
|
+
tenant_count = (ENV["PERF_TENANT_COUNT"].presence || "3").to_i
|
|
8
|
+
host = ENV["PERF_HOST"].presence || "localhost"
|
|
9
|
+
|
|
10
|
+
Decidim::Apartment::Performance::CreateSeedTentant.call(user_count, tenant_count, host)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
desc "Rotate AttributeEncryptor ciphertext (SECRET_KEY_BASE_FROM, optional SECRET_KEY_BASE_TO, DISTRIBUTION_KEY, YES=1)"
|
|
5
|
+
task rotate: :environment do
|
|
6
|
+
require "decidim/apartment/import/confirm_prompt"
|
|
7
|
+
require "decidim/apartment/ops/encrypted_attribute_registry"
|
|
8
|
+
require "decidim/apartment/ops/encrypted_attribute_catalog"
|
|
9
|
+
require "decidim/apartment/ops/attribute_cryptor"
|
|
10
|
+
require "decidim/apartment/ops/ciphertext_rewriter"
|
|
11
|
+
require "decidim/apartment/ops/secret_key_preflight"
|
|
12
|
+
require "decidim/apartment/ops/secret_key_rotation"
|
|
13
|
+
|
|
14
|
+
result = Decidim::Apartment::Ops::SecretKeyRotation.call
|
|
15
|
+
exit result.exit_code
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
namespace :storage do
|
|
5
|
+
desc "Upload tenant local disk blobs to ApartmentS3Storage (TENANT, optional DISK_ROOT)"
|
|
6
|
+
task to_s3: :environment do
|
|
7
|
+
require "decidim/apartment/import"
|
|
8
|
+
require "decidim/apartment/convert"
|
|
9
|
+
require "decidim/apartment/ops/storage_transfer"
|
|
10
|
+
tenant = ENV.fetch("TENANT") { abort "TENANT is required" }
|
|
11
|
+
Decidim::Apartment::Ops::StorageTransfer.to_s3(tenant: tenant)
|
|
12
|
+
rescue Decidim::Apartment::Import::ImportError => e
|
|
13
|
+
abort e.message
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "Download tenant S3 blobs to local DISK_ROOT (TENANT, optional DISK_ROOT)"
|
|
17
|
+
task to_local: :environment do
|
|
18
|
+
require "decidim/apartment/import"
|
|
19
|
+
require "decidim/apartment/convert"
|
|
20
|
+
require "decidim/apartment/ops/storage_transfer"
|
|
21
|
+
tenant = ENV.fetch("TENANT") { abort "TENANT is required" }
|
|
22
|
+
Decidim::Apartment::Ops::StorageTransfer.to_local(tenant: tenant)
|
|
23
|
+
rescue Decidim::Apartment::Import::ImportError => e
|
|
24
|
+
abort e.message
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :decidim_apartment do
|
|
4
|
+
# RightToBeForgotten ------
|
|
5
|
+
#
|
|
6
|
+
# Load a single CSV file with user_ids list, and deletes all
|
|
7
|
+
# User records that exists and are not deleted in DB
|
|
8
|
+
#
|
|
9
|
+
# cmd: $ RAILS_ENV=<environment> bundle exec rails decidim:right_to_be_forgotten [FILE_PATH=<relative path to CSV file>]
|
|
10
|
+
#
|
|
11
|
+
# CSV file must be located within project root path
|
|
12
|
+
#
|
|
13
|
+
desc "Deletes User records by ID using a CSV file"
|
|
14
|
+
task right_to_be_forgotten: :environment do
|
|
15
|
+
Decidim::Apartment::DistributionKey.all.each do |distribution_key|
|
|
16
|
+
distribution_key.switch do
|
|
17
|
+
puts "=> decidim:right_to_be_forgotten for #[key=#{distribution_key.key},host=#{distribution_key.host}]"
|
|
18
|
+
|
|
19
|
+
log = ActiveSupport::Logger.new(Rails.root.join("log/right_to_be_forgotten.log"))
|
|
20
|
+
begin
|
|
21
|
+
path = ENV["FILE_PATH"].presence || "tmp/forgotten_users.csv" # Good file
|
|
22
|
+
file_path = Rails.root.join(path)
|
|
23
|
+
csv_data = CSV.read(file_path, headers: false)
|
|
24
|
+
users_count = csv_data.size
|
|
25
|
+
puts "RightToBeForgotten: ------------------- #{Time.current}"
|
|
26
|
+
log.info "RightToBeForgotten: ------------------- #{Time.current}"
|
|
27
|
+
csv_data.each.with_index(1) do |row, index|
|
|
28
|
+
# Each row, first element must be ID, others are useless
|
|
29
|
+
user_id = row.first.presence || ""
|
|
30
|
+
next unless user_id =~ /^\d+$/ # ID must be numeric only
|
|
31
|
+
|
|
32
|
+
if (user = Decidim::User.find_by(id: user_id))
|
|
33
|
+
if user.deleted?
|
|
34
|
+
puts " #{index}/#{users_count} - [#{user_id}] User already deleted"
|
|
35
|
+
log.info " #{index}/#{users_count} - [#{user_id}] User already deleted"
|
|
36
|
+
else
|
|
37
|
+
puts " #{index}/#{users_count} !! [#{user_id}] DELETING USER"
|
|
38
|
+
log.info " #{index}/#{users_count} !! [#{user_id}] DELETING USER"
|
|
39
|
+
Decidim::DestroyAccount.call(Decidim::DeleteAccountForm.from_params({}).with_context({ current_user: user })) # Delete user!
|
|
40
|
+
end
|
|
41
|
+
else
|
|
42
|
+
puts " #{index}/#{users_count} - [#{user_id}] User not found"
|
|
43
|
+
log.info " #{index}/#{users_count} - [#{user_id}] User not found"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
rescue CSV::MalformedCSVError
|
|
47
|
+
puts " ERROR: [Malformed CSV] #{path}"
|
|
48
|
+
log.info " ERROR: [Malformed CSV] #{path}"
|
|
49
|
+
rescue Errno::ENOENT
|
|
50
|
+
puts " ERROR: [File not found] #{path}"
|
|
51
|
+
log.info " ERROR: [File not found] #{path}"
|
|
52
|
+
rescue StandardError => e
|
|
53
|
+
puts " ERROR: [Unexpected error] #{e.message}"
|
|
54
|
+
log.info " ERROR: [Unexpected error] #{e.message}"
|
|
55
|
+
ensure
|
|
56
|
+
puts "RightToBeForgotten: Log file created at log/right_to_be_forgotten.log"
|
|
57
|
+
puts "RightToBeForgotten: --------------- END #{Time.current}"
|
|
58
|
+
log.info "RightToBeForgotten: --------------- END #{Time.current}"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
desc "Checks and notifies users to update their newsletter notifications settings"
|
|
65
|
+
task check_users_newsletter_opt_in: :environment do
|
|
66
|
+
Decidim::Apartment::DistributionKey.all.each do |distribution_key|
|
|
67
|
+
distribution_key.switch do
|
|
68
|
+
puts "=> decidim:check_users_newsletter_opt_in for #[key=#{distribution_key.key},host=#{distribution_key.host}]"
|
|
69
|
+
|
|
70
|
+
print %(
|
|
71
|
+
> This will send an email to all the users that have marked the newsletter by default. This should only be run if you were using Decidim before v0.11
|
|
72
|
+
If you have any doubts regarding this feature, please check the releases notes for this version https://github.com/decidim/decidim/releases/tag/v0.12
|
|
73
|
+
Are you sure you want to do that? [y/N]: )
|
|
74
|
+
input = $stdin.gets.chomp
|
|
75
|
+
if input.casecmp("y").zero?
|
|
76
|
+
puts %( Continue...)
|
|
77
|
+
Decidim::User.where(newsletter_notifications_at: ...Time.zone.parse("2018-05-25 00:00 +02:00")).find_each(&:newsletter_opt_in_notify)
|
|
78
|
+
else
|
|
79
|
+
puts %( Execution cancelled...)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
desc "Deletes all download your data files previous to `Decidim.download_your_data_expiry_time` from now."
|
|
86
|
+
task delete_download_your_data_files: :environment do
|
|
87
|
+
Decidim::Apartment::DistributionKey.all.each do |distribution_key|
|
|
88
|
+
distribution_key.switch do
|
|
89
|
+
puts "=> decidim:delete_download_your_data_files for #[key=#{distribution_key.key},host=#{distribution_key.host}]"
|
|
90
|
+
|
|
91
|
+
puts "DELETE DOWNLOAD YOUR DATA FILES: -------------- START"
|
|
92
|
+
attachments = ActiveStorage::Attachment.joins(:blob).where(
|
|
93
|
+
name: "download_your_data_file",
|
|
94
|
+
record_type: "Decidim::UserBaseEntity"
|
|
95
|
+
).where(active_storage_blobs: { created_at: ...Decidim.download_your_data_expiry_time.ago })
|
|
96
|
+
attachments.each do |attachment|
|
|
97
|
+
delete_download_your_data_file attachment
|
|
98
|
+
end
|
|
99
|
+
puts "DELETE DOWNLOAD YOUR DATA FILES: --------------- END"
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def delete_download_your_data_file(attachment)
|
|
105
|
+
puts "------"
|
|
106
|
+
puts "!! deleting: #{attachment.filename}"
|
|
107
|
+
attachment.purge
|
|
108
|
+
puts "ok----"
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
Rake::Task["decidim:check_users_newsletter_opt_in"].enhance do
|
|
112
|
+
Rake::Task["decidim_apartment:check_users_newsletter_opt_in"].invoke
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
Rake::Task["decidim:right_to_be_forgotten"].enhance do
|
|
116
|
+
Rake::Task["decidim_apartment:right_to_be_forgotten"].invoke
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
Rake::Task["decidim:delete_download_your_data_files"].enhance do
|
|
120
|
+
Rake::Task["decidim_apartment:delete_download_your_data_files"].invoke
|
|
121
|
+
end
|