decidim-voca 0.0.6 → 0.1.2
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/LICENSE.md +161 -161
- data/README.md +42 -133
- data/Rakefile +46 -39
- data/app/cells/decidim/footer_topics/show_overrides.erb +8 -0
- data/app/cells/decidim/meetings/dates_and_map/show_overrides.erb +23 -0
- data/app/commands/decidim/voca/admin/code_census/save_code_list.rb +34 -0
- data/app/commands/decidim/voca/code_census/confirm_code_authorization.rb +16 -0
- data/app/commands/decidim/voca/create_editor_file.rb +36 -0
- data/app/commands/decidim/voca/rack_attack_configurator.rb +244 -0
- data/app/commands/decidim/voca/sync_redis_routing.rb +120 -0
- data/app/commands/decidim/voca/user_fields_configurator.rb +40 -0
- data/app/controllers/decidim/voca/admin/application_controller.rb +4 -6
- data/app/controllers/decidim/voca/admin/code_census/code_lists_controller.rb +40 -0
- data/app/controllers/decidim/voca/application_controller.rb +4 -6
- data/app/controllers/decidim/voca/code_census/authorizations_controller.rb +53 -0
- data/app/controllers/decidim/voca/editor_files_controller.rb +47 -0
- data/app/controllers/decidim/voca/geolocation_controller.rb +32 -0
- data/app/forms/decidim/voca/admin/code_census/code_list_form.rb +21 -0
- data/app/forms/decidim/voca/admin/organization_config_form.rb +24 -0
- data/app/forms/decidim/voca/code_census/code_form.rb +41 -0
- data/app/forms/decidim/voca/editor_file_form.rb +18 -0
- data/app/jobs/decidim/voca/machine_translate_awesome_menu_label_job.rb +63 -0
- data/app/jobs/decidim/voca/machine_translate_component_setting_job.rb +58 -0
- data/app/jobs/decidim/voca/machine_translate_content_block_setting_job.rb +85 -0
- data/app/models/decidim/voca/conversation_uuid.rb +18 -0
- data/app/models/decidim/voca/editor_file.rb +18 -0
- data/app/models/decidim/voca/validation_code.rb +13 -0
- data/app/overrides/admin_add_machine_translation_flag.rb +36 -0
- data/app/overrides/insert_assets.rb +26 -0
- data/app/overrides/insert_weglot_scripts.rb +36 -0
- data/app/overrides/proposal_camera.rb +18 -0
- data/app/overrides/show_votes.rb +27 -0
- data/app/overrides/voca_footer.rb +52 -0
- data/app/packs/entrypoints/admin-decidim-voca.js +2 -0
- data/app/packs/entrypoints/admin-decidim-voca.scss +1 -0
- data/app/packs/entrypoints/decidim-voca-fixes.scss +1 -0
- data/app/packs/entrypoints/decidim-voca.js +1 -0
- data/app/packs/entrypoints/decidim-voca.scss +1 -0
- data/app/packs/images/voca-logo-primary-x3.png +0 -0
- data/app/packs/src/decidim/direct_uploads/upload_field.js +150 -0
- data/app/packs/src/decidim/voca/admin/voca.js +16 -0
- data/app/packs/src/decidim/voca/proposal_better_ux/use_camera_button.js +39 -0
- data/app/packs/src/decidim/voca/proposal_better_ux/utils/get_current_position.js +21 -0
- data/app/packs/src/decidim/voca/proposal_better_ux/utils/get_proposal_form.js +13 -0
- data/app/packs/src/decidim/voca/proposal_better_ux/utils/loading.js +23 -0
- data/app/packs/src/decidim/voca/proposal_better_ux/utils/locate_coordinates.js +23 -0
- data/app/packs/src/decidim/voca/proposal_custom_fields/custom_field_renderer_override.js +152 -0
- data/app/packs/src/decidim/voca/proposal_custom_fields/editor_budget_field.js +329 -0
- data/app/packs/src/decidim/voca/proposal_custom_fields/editor_upload_field.js +85 -0
- data/app/packs/src/decidim/voca/proposal_custom_fields/proposal_custom_fields.js +96 -0
- data/app/packs/src/decidim/voca/proposal_custom_fields/render_budget_field.js +76 -0
- data/app/packs/src/decidim/voca/proposal_fields/render_budget_field.js +76 -0
- data/app/packs/src/decidim/voca/questionnaire/scroll_questionnaire_steps_to_top.js +18 -0
- data/app/packs/src/decidim/voca/voca.js +4 -0
- data/app/packs/src/decidim/voca/weglot/index.js +13 -0
- data/app/packs/src/decidim/voca/weglot/start_weglot.js +112 -0
- data/app/packs/src/decidim/voca/weglot/switcher.js +92 -0
- data/app/packs/src/decidim/voca/weglot/wait_for_weglot.js +10 -0
- data/app/packs/stylesheets/decidim/voca/_custom_proposal_fields.scss +111 -0
- data/app/packs/stylesheets/decidim/voca/_decidim_voca.scss +5 -0
- data/app/packs/stylesheets/decidim/voca/_decidim_voca_fixes.scss +25 -0
- data/app/packs/stylesheets/decidim/voca/_primary_footer.scss +77 -0
- data/app/packs/stylesheets/decidim/voca/_proposal_camera.scss +14 -0
- data/app/packs/stylesheets/decidim/voca/_weglot.scss +61 -0
- data/app/packs/stylesheets/decidim/voca/admin/_decidim_voca.scss +5 -0
- data/app/packs/stylesheets/decidim/voca/admin/_full_machine_translation.scss +34 -0
- data/app/permissions/decidim/voca/admin/permissions.rb +31 -0
- data/app/permissions/decidim/voca/permissions.rb +17 -0
- data/app/views/decidim/voca/admin/code_census/authorizations/new.html.erb +33 -0
- data/app/views/decidim/voca/admin/code_census/code_lists/edit.html.erb +27 -0
- data/app/views/decidim/voca/code_census/authorizations/new.html.erb +24 -0
- data/app/views/decidim/voca/deepl/overrides/_admin_machine_translation_alert.html.erb +14 -0
- data/app/views/decidim/voca/rack_attack/_blocked.html.erb +151 -0
- data/app/views/decidim/voca/weglot/_js_configuration.html.erb +14 -0
- data/app/views/decidim/voca/weglot/_locale_switcher.html.erb +14 -0
- data/app/views/decidim/voca/weglot/_locale_switcher_mobile.erb +14 -0
- data/app/views/decidim/voca/weglot/_topbar_locale_switcher.html.erb +14 -0
- data/config/assets.rb +12 -0
- data/config/i18n-tasks.yml +14 -5
- data/config/locales/cs.yml +94 -0
- data/config/locales/custom_fields.cs.yml +30 -0
- data/config/locales/custom_fields.en.yml +41 -0
- data/config/locales/custom_fields.fr.yml +30 -0
- data/config/locales/custom_fields.it.yml +30 -0
- data/config/locales/en.yml +97 -4
- data/config/locales/fr.yml +102 -0
- data/config/locales/it.yml +94 -0
- data/lib/decidim/voca/awesome_menu_label_machine_translation.rb +73 -0
- data/lib/decidim/voca/awesome_menu_labels.rb +28 -0
- data/lib/decidim/voca/cache_namespace.rb +21 -0
- data/lib/decidim/voca/code_census/admin_engine.rb +22 -0
- data/lib/decidim/voca/code_census/engine.rb +29 -0
- data/lib/decidim/voca/code_census/workflow.rb +7 -0
- data/lib/decidim/voca/code_census.rb +4 -0
- data/lib/decidim/voca/component_setting_manifest.rb +27 -0
- data/lib/decidim/voca/component_setting_pending_locales.rb +33 -0
- data/lib/decidim/voca/component_translated_settings_machine_translation.rb +86 -0
- data/lib/decidim/voca/configuration.rb +23 -0
- data/lib/decidim/voca/content_block_setting_manifest.rb +67 -0
- data/lib/decidim/voca/content_block_translated_settings_machine_translation.rb +100 -0
- data/lib/decidim/voca/deepl/deepl_active_job_context.rb +27 -0
- data/lib/decidim/voca/deepl/deepl_context.rb +78 -0
- data/lib/decidim/voca/deepl/deepl_form_builder_overrides.rb +82 -0
- data/lib/decidim/voca/deepl/deepl_machine_translator.rb +61 -0
- data/lib/decidim/voca/deepl/deepl_middleware.rb +83 -0
- data/lib/decidim/voca/deepl/engine_config.rb +179 -0
- data/lib/decidim/voca/deepl/translation_bar_overrides.rb +20 -0
- data/lib/decidim/voca/deepl.rb +9 -0
- data/lib/decidim/voca/engine.rb +318 -11
- data/lib/decidim/voca/export/comment_serializer_localized_csv.rb +34 -0
- data/lib/decidim/voca/export/csv_with_locale_transformer.rb +53 -0
- data/lib/decidim/voca/export/proposal_serializer_localized_csv.rb +45 -0
- data/lib/decidim/voca/export/user_answers_serializer_localized_csv.rb +54 -0
- data/lib/decidim/voca/good_job_settings.rb +74 -0
- data/lib/decidim/voca/installation.rb +33 -0
- data/lib/decidim/voca/machine_translation/translate_string.rb +121 -0
- data/lib/decidim/voca/machine_translation_human_source.rb +29 -0
- data/lib/decidim/voca/machine_translation_resource_job_voca.rb +65 -0
- data/lib/decidim/voca/organization_voca_extensions.rb +31 -0
- data/lib/decidim/voca/overrides/csv_export_serializers.rb +51 -0
- data/lib/decidim/voca/overrides/meetings/dates_and_map_cell_overrides.rb +20 -0
- data/lib/decidim/voca/overrides/menu_breadcrumb_last_activity_cache.rb +31 -0
- data/lib/decidim/voca/overrides/mod_secure/conversation_controller_overrides.rb +19 -0
- data/lib/decidim/voca/overrides/mod_secure/conversation_sanitize.rb +29 -0
- data/lib/decidim/voca/overrides/mod_secure/conversation_uuid.rb +34 -0
- data/lib/decidim/voca/overrides/mod_secure/user_conversations_redirect_overrides.rb +53 -0
- data/lib/decidim/voca/overrides/mod_secure/user_profile_verification_override.rb +31 -0
- data/lib/decidim/voca/overrides/newsletter_helper_overrides.rb +30 -0
- data/lib/decidim/voca/overrides/resource_presenter_overrides.rb +30 -0
- data/lib/decidim/voca/overrides/sanitize_helper_overrides.rb +39 -0
- data/lib/decidim/voca/sync_locales/README.md +13 -0
- data/lib/decidim/voca/sync_locales/awesome_menu_label_sync.rb +89 -0
- data/lib/decidim/voca/sync_locales/command.rb +54 -0
- data/lib/decidim/voca/sync_locales/component_setting_sync.rb +72 -0
- data/lib/decidim/voca/sync_locales/content_block_setting_sync.rb +86 -0
- data/lib/decidim/voca/sync_locales/field_hash_normalizer.rb +98 -0
- data/lib/decidim/voca/sync_locales/locale_context.rb +589 -0
- data/lib/decidim/voca/sync_locales/machine_translation_enqueuer.rb +60 -0
- data/lib/decidim/voca/sync_locales/relation_lint_runner.rb +55 -0
- data/lib/decidim/voca/sync_locales/runner.rb +352 -0
- data/lib/decidim/voca/sync_locales.rb +11 -0
- data/lib/decidim/voca/update_column_without_callbacks.rb +21 -0
- data/lib/decidim/voca/version.rb +13 -3
- data/lib/decidim/voca.rb +42 -13
- data/lib/decidim-voca.rb +5 -0
- data/lib/tasks/decidim/voca/voca_anonymize.rake +41 -0
- data/lib/tasks/decidim/voca/voca_clean_machine_translations.rake +22 -0
- data/lib/tasks/decidim/voca/voca_enhanced_invalid_record.rake +141 -0
- data/lib/tasks/decidim/voca/voca_install_migration.rake +45 -0
- data/lib/tasks/decidim/voca/voca_relation_lint.rake +12 -0
- data/lib/tasks/decidim/voca/voca_sync_locales.rake +10 -0
- data/lib/tasks/decidim/voca/voca_upgrade.rake +13 -0
- data/lib/tasks/decidim/voca/voca_webpacker.rake +58 -0
- metadata +248 -55
- data/app/assets/config/voca_manifest.js +0 -0
- data/app/assets/images/decidim/voca/icon.svg +0 -1
- data/app/commands/decidim/voca/organization/command.rb +0 -16
- data/app/commands/decidim/voca/organization/organization_command.rb +0 -17
- data/app/commands/decidim/voca/organization/update_color_command.rb +0 -35
- data/app/commands/decidim/voca/organization/update_environment_command.rb +0 -23
- data/app/commands/decidim/voca/organization/update_feature_command.rb +0 -32
- data/app/commands/decidim/voca/organization/update_file_upload_command.rb +0 -45
- data/app/commands/decidim/voca/organization/update_locale_command.rb +0 -53
- data/app/commands/decidim/voca/organization/update_naming_command.rb +0 -30
- data/app/commands/decidim/voca/organization/update_permission_command.rb +0 -31
- data/app/commands/decidim/voca/organization/update_smtp_command.rb +0 -51
- data/app/jobs/decidim/voca/command_job.rb +0 -36
- data/app/jobs/decidim/voca/webhook_notifier_job.rb +0 -57
- data/app/rpc/decidim/voca/decidim_service_controller.rb +0 -68
- data/app/rpc/decidim/voca/rpc/enum_casting.rb +0 -58
- data/app/rpc/decidim/voca/rpc/get_settings.rb +0 -144
- data/app/rpc/decidim/voca/rpc/health.rb +0 -18
- data/app/rpc/decidim/voca/rpc/seed_admin.rb +0 -75
- data/app/rpc/decidim/voca/rpc/set_settings.rb +0 -56
- data/app/rpc/decidim/voca/rpc/setup_db.rb +0 -38
- data/config/environments/development.rb +0 -6
- data/config/spring.rb +0 -2
- data/lib/decidim/voca/admin.rb +0 -10
- data/lib/decidim/voca/admin_engine.rb +0 -27
- data/lib/decidim/voca/backup/app_backup.rb +0 -169
- data/lib/decidim/voca/backup/app_decrypt_backup_file.rb +0 -50
- data/lib/decidim/voca/backup/app_encrypt_backup_file.rb +0 -49
- data/lib/decidim/voca/backup/app_upload_to_s3.rb +0 -49
- data/lib/decidim/voca/middleware/dynamic_config_middleware.rb +0 -42
- data/lib/decidim/voca/rpc/decidim_pb.rb +0 -134
- data/lib/decidim/voca/rpc/decidim_services_pb.rb +0 -30
- data/lib/decidim/voca/test/factories.rb +0 -9
- data/lib/decidim/voca/updater.rb +0 -50
- data/lib/tasks/voca.rake +0 -88
data/lib/decidim/voca/engine.rb
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "rails"
|
|
4
|
+
require "socket"
|
|
4
5
|
require "decidim/core"
|
|
6
|
+
require "deface"
|
|
7
|
+
require "decidim/verifications"
|
|
8
|
+
require "decidim/voca/code_census"
|
|
9
|
+
require "decidim/toggle"
|
|
10
|
+
require_relative "export/csv_with_locale_transformer"
|
|
11
|
+
require_relative "export/proposal_serializer_localized_csv"
|
|
12
|
+
require_relative "export/comment_serializer_localized_csv"
|
|
13
|
+
require_relative "export/user_answers_serializer_localized_csv"
|
|
14
|
+
require_relative "overrides/csv_export_serializers"
|
|
15
|
+
require_relative "overrides/mod_secure/user_conversations_redirect_overrides"
|
|
16
|
+
|
|
5
17
|
module Decidim
|
|
6
18
|
module Voca
|
|
7
19
|
# This is the engine that runs on the public interface of voca.
|
|
@@ -9,21 +21,316 @@ module Decidim
|
|
|
9
21
|
isolate_namespace Decidim::Voca
|
|
10
22
|
|
|
11
23
|
routes do
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
Decidim::Core::Engine.routes.draw do
|
|
25
|
+
post :editor_files, to: "voca/editor_files#create"
|
|
26
|
+
post :locate, to: "voca/geolocation#locate"
|
|
27
|
+
mount Decidim::Voca::CodeCensus::Engine, at: "/code_census", as: "decidim_code_census"
|
|
28
|
+
|
|
29
|
+
if Rails.application.config.active_job.queue_adapter == :good_job
|
|
30
|
+
authenticate :admin, ->(admin) { !admin.locked_at? } do
|
|
31
|
+
mount GoodJob::Engine => "/system/active_jobs"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
decidim_engine = ::Decidim::Core::Engine
|
|
36
|
+
cleaned_routes = decidim_engine.routes.routes.instance_variable_get(:@routes)
|
|
37
|
+
cleaned_routes.reject! do |route|
|
|
38
|
+
path_spec = route.path.spec.to_s
|
|
39
|
+
route.constraints[:id] != Decidim::Voca::UUID_REGEXP && (
|
|
40
|
+
(path_spec.include?("/conversations") && path_spec.include?("/:id")) ||
|
|
41
|
+
(path_spec.include?("/profiles/:nickname/conversations") && path_spec.include?("/:id"))
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
constraints(id: Decidim::Voca::UUID_REGEXP) do
|
|
46
|
+
resources :conversations, only: [:new, :create, :index, :show, :update], controller: "messaging/conversations"
|
|
47
|
+
end
|
|
48
|
+
scope "/profiles/:nickname", format: false, constraints: { nickname: %r{[^/]+} } do
|
|
49
|
+
constraints(id: Decidim::Voca::UUID_REGEXP) do
|
|
50
|
+
resources :conversations, except: [:destroy], controller: "user_conversations", as: "profile_conversations"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Enforce conversation sanitization
|
|
57
|
+
config.to_prepare do
|
|
58
|
+
Decidim::Messaging::ConversationForm.include(Decidim::Voca::Overrides::ConversationSanitize)
|
|
59
|
+
Decidim::Messaging::Message.include(Decidim::Voca::Overrides::ConversationSanitize)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Enforce profile verification
|
|
63
|
+
config.to_prepare do
|
|
64
|
+
# Decidim::AccountForm will use these regexps:
|
|
65
|
+
Decidim::UserBaseEntity::REGEXP_NAME = /\A(?!.*[<>?%&\^*#@()\[\]=+:;"{}\\|])/m
|
|
66
|
+
Decidim::User::REGEXP_NICKNAME = /\A[\w-]+\z/m
|
|
67
|
+
# If it has gone through forms, and still want to save, we sanitize on save:
|
|
68
|
+
Decidim::UserBaseEntity.include(Decidim::Voca::Overrides::UserProfileVerificationOverride)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Enforce uuid in conversations
|
|
72
|
+
config.to_prepare do
|
|
73
|
+
Decidim::Core::Engine.routes.url_helpers.define_singleton_method(:profile_conversation_path) do |options|
|
|
74
|
+
options[:id] = options[:id].to_param if options[:id].respond_to?(:to_param)
|
|
75
|
+
if options[:id] && (options[:id].is_a?(Integer) || !options[:id].match?(Decidim::Voca::UUID_REGEXP))
|
|
76
|
+
options[:id] =
|
|
77
|
+
Decidim::Messaging::Conversation.find(options[:id]).uuid
|
|
78
|
+
end
|
|
79
|
+
super(options)
|
|
80
|
+
end
|
|
81
|
+
Decidim::Core::Engine.routes.url_helpers.define_singleton_method(:conversation_path) do |conversation, options = {}|
|
|
82
|
+
options = conversation if conversation.is_a?(Hash) && options.empty?
|
|
83
|
+
conversation_id = options[:id] || conversation
|
|
84
|
+
options[:id] = if conversation.respond_to?(:uuid)
|
|
85
|
+
conversation.uuid
|
|
86
|
+
elsif conversation_id.respond_to?(:uuid)
|
|
87
|
+
conversation_id.uuid
|
|
88
|
+
elsif conversation_id && (conversation_id.is_a?(Integer) || !conversation_id.match?(Decidim::Voca::UUID_REGEXP))
|
|
89
|
+
Decidim::Messaging::Conversation.find(conversation_id).uuid
|
|
90
|
+
else
|
|
91
|
+
conversation_id
|
|
92
|
+
end
|
|
93
|
+
super(options)
|
|
94
|
+
end
|
|
95
|
+
Decidim::Messaging::Conversation.include(Decidim::Voca::Overrides::ConversationUuid)
|
|
96
|
+
Decidim::Messaging::ConversationsController.include(Decidim::Voca::Overrides::ConversationControllerOverrides)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
config.to_prepare do
|
|
100
|
+
Decidim::Organization.include(Decidim::Voca::OrganizationVocaExtensions)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
config.to_prepare do
|
|
104
|
+
Decidim::Voca::DeepL::EngineConfig.configure!
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
initializer "decidim.voca.deepl", after: :load_config_initializers do
|
|
108
|
+
Decidim::Voca::DeepL::EngineConfig.initialize!
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Overrides
|
|
112
|
+
config.to_prepare do
|
|
113
|
+
# Set retry on Decidim::ApplicationJob
|
|
114
|
+
good_job_retry = Decidim::Voca::GoodJobSettings.retry
|
|
115
|
+
::Decidim::ApplicationJob.retry_on StandardError, attempts: good_job_retry
|
|
116
|
+
|
|
117
|
+
# Overrides ResourcePresenter
|
|
118
|
+
Decidim::ResourcePresenter.include(Decidim::Voca::Overrides::ResourcePresenterOverrides)
|
|
119
|
+
|
|
120
|
+
# Overrides SanitizeHelper
|
|
121
|
+
Decidim::SanitizeHelper.include(Decidim::Voca::Overrides::SanitizeHelperOverrides)
|
|
122
|
+
|
|
123
|
+
# Menu breadcrumb last activity (< 0.32): skip ActionLog before fragment cache.
|
|
124
|
+
# Cell removed upstream in Decidim 0.32 (#15862).
|
|
125
|
+
if Gem::Version.new(Decidim.version) < Gem::Version.new("0.32.0")
|
|
126
|
+
Decidim::ContentBlocks::MenuBreadcrumbLastActivityCell.prepend(
|
|
127
|
+
Decidim::Voca::Overrides::MenuBreadcrumbLastActivityCache
|
|
128
|
+
)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Trigger additional hooks on organization creation and update
|
|
133
|
+
config.to_prepare do
|
|
134
|
+
::Decidim::Organization.after_commit on: :create do |organization|
|
|
135
|
+
ActiveSupport::Notifications.instrument(
|
|
136
|
+
"voca.organization_created",
|
|
137
|
+
resource_id: organization.id
|
|
138
|
+
)
|
|
139
|
+
end
|
|
140
|
+
::Decidim::Organization.after_commit on: :update do |organization|
|
|
141
|
+
ActiveSupport::Notifications.instrument(
|
|
142
|
+
"voca.organization_updated",
|
|
143
|
+
resource_id: organization.id
|
|
144
|
+
)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# CSV serializers must load after Decidim Awesome's ProposalSerializer override, or Awesome's
|
|
149
|
+
# +alias_method :decidim_original_serialize, :serialize+ aliases voca's prepended +serialize+ and causes
|
|
150
|
+
# infinite recursion (see Overrides::CsvExportSerializers).
|
|
151
|
+
if Gem.loaded_specs.has_key?("decidim-decidim_awesome")
|
|
152
|
+
initializer "decidim.voca.after_awesome", after: "decidim_decidim_awesome.overrides" do
|
|
153
|
+
config.to_prepare do
|
|
154
|
+
Decidim::Voca::Overrides::CsvExportSerializers.apply
|
|
155
|
+
ActiveSupport.on_load(:action_controller) do
|
|
156
|
+
Decidim::EditorImagesController = Decidim::DecidimAwesome::EditorImagesController
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
else
|
|
161
|
+
config.to_prepare do
|
|
162
|
+
Decidim::Voca::Overrides::CsvExportSerializers.apply
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Cache namespace configuration
|
|
167
|
+
# See https://guides.rubyonrails.org/caching_with_rails.html
|
|
168
|
+
initializer "decidim.voca.cache_namespace", before: "decidim.voca.rack_attack" do
|
|
169
|
+
Rails.application.configure do |_config|
|
|
170
|
+
cache_store = Rails.application.config.cache_store
|
|
171
|
+
next unless cache_store.present? && cache_store != :null_store
|
|
172
|
+
|
|
173
|
+
cache_namespace = Decidim::Voca::CacheNamespace.value
|
|
174
|
+
next if cache_namespace.blank?
|
|
175
|
+
|
|
176
|
+
cache_store_config = Array(cache_store)
|
|
177
|
+
store_type = cache_store_config.first
|
|
178
|
+
|
|
179
|
+
# Handle memcached stores (dalli)
|
|
180
|
+
if store_type == :mem_cache_store
|
|
181
|
+
# cache_store_config[1] can be a string (server address) or hash (options)
|
|
182
|
+
if cache_store_config[1].is_a?(Hash)
|
|
183
|
+
cache_store_config[1][:namespace] = cache_namespace
|
|
184
|
+
else
|
|
185
|
+
# Server address(es) are strings, options hash goes after all servers
|
|
186
|
+
# Format: [:mem_cache_store, "server1:11211", "server2:11211", { options }]
|
|
187
|
+
# Find existing options hash (after all server strings) or create new one
|
|
188
|
+
options_index = cache_store_config.find_index { |item| item.is_a?(Hash) }
|
|
189
|
+
if options_index
|
|
190
|
+
cache_store_config[options_index][:namespace] = cache_namespace
|
|
191
|
+
else
|
|
192
|
+
cache_store_config << { namespace: cache_namespace }
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
Rails.application.config.cache_store = cache_store_config
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
initializer "decidim.voca.custom_user_fields", after: :load_config_initializers do
|
|
201
|
+
# Decidim::Voca::UserFieldsConfigurator.call
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
initializer "decidim.voca.good_job", after: :load_config_initializers do
|
|
205
|
+
# Execution mode is configurable, to adapt on demand:
|
|
206
|
+
# - async_server: when your installation is small and want to run all in same server (but a new thread)
|
|
207
|
+
# - external: when you run your own process with ``
|
|
208
|
+
execution_mode = Decidim::Voca::GoodJobSettings.execution_mode
|
|
209
|
+
good_job_max_threads = Decidim::Voca::GoodJobSettings.max_threads
|
|
210
|
+
good_job_poll_interval = Decidim::Voca::GoodJobSettings.poll_interval
|
|
211
|
+
good_job_shutdown_timeout = Decidim::Voca::GoodJobSettings.shutdown_timeout
|
|
212
|
+
good_job_retry = Decidim::Voca::GoodJobSettings.retry
|
|
213
|
+
good_job_queues = Decidim::Voca::GoodJobSettings.queues
|
|
214
|
+
supported_execution_modes = [:async_server, :external]
|
|
215
|
+
unless supported_execution_modes.include?(execution_mode)
|
|
216
|
+
raise "Unsupported execution mode: #{execution_mode}. Supported modes are: #{supported_execution_modes.join(", ")}"
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
Rails.application.configure do
|
|
220
|
+
if config.active_job.queue_adapter == :good_job
|
|
221
|
+
Rails.logger.warn("Overriding good_job configuration for Decidim")
|
|
222
|
+
config.good_job.preserve_job_records = true
|
|
223
|
+
config.good_job.retry_on_unhandled_error = false
|
|
224
|
+
config.good_job.on_thread_error = ->(exception) { Rails.error.report(exception) }
|
|
225
|
+
config.good_job.execution_mode = execution_mode
|
|
226
|
+
config.good_job.queues = good_job_queues
|
|
227
|
+
config.good_job.max_threads = good_job_max_threads
|
|
228
|
+
config.good_job.poll_interval = good_job_poll_interval # seconds
|
|
229
|
+
config.good_job.shutdown_timeout = good_job_shutdown_timeout # seconds
|
|
230
|
+
config.good_job.enable_cron = false
|
|
231
|
+
config.good_job.dashboard_default_locale = :en
|
|
232
|
+
# Retry on unhandled error
|
|
233
|
+
ActionMailer::MailDeliveryJob.retry_on StandardError, attempts: good_job_retry
|
|
234
|
+
end
|
|
235
|
+
end
|
|
15
236
|
end
|
|
16
237
|
|
|
17
|
-
initializer "
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
238
|
+
initializer "decidim_decidim-voca.organization_settings_tab", after: "decidim_toggle.organization_settings_tabs" do
|
|
239
|
+
Decidim::Toggle.settings_tabs :organization_settings do |tabs|
|
|
240
|
+
tabs.add_tab :my_module, "Voca",
|
|
241
|
+
form: Decidim::Voca::Admin::OrganizationConfigForm,
|
|
242
|
+
command: Decidim::Toggle::UpdateModuleConfigCommand,
|
|
243
|
+
module_name: Decidim::Voca::MODULE_NAME,
|
|
244
|
+
position: 4
|
|
245
|
+
end
|
|
21
246
|
end
|
|
22
247
|
|
|
23
|
-
initializer "
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
248
|
+
initializer "decidim.voca.csp", after: :load_config_initializers do
|
|
249
|
+
Decidim.configure do |decidim_config|
|
|
250
|
+
decidim_config.content_security_policies_extra["worker-src"] = [] unless decidim_config.content_security_policies_extra.has_key? "worker-src"
|
|
251
|
+
decidim_config.content_security_policies_extra["worker-src"].push("blob:")
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
initializer "decidim.voca.weglot", after: :load_config_initializers do
|
|
256
|
+
# configure additional CSP for weglot
|
|
257
|
+
Decidim.configure do |decidim_config|
|
|
258
|
+
decidim_config.content_security_policies_extra["connect-src"] = [] unless decidim_config.content_security_policies_extra.has_key? "connect-src"
|
|
259
|
+
decidim_config.content_security_policies_extra["connect-src"].push("*.weglot.com")
|
|
260
|
+
decidim_config.content_security_policies_extra["connect-src"].push("cdn-api-weglot.com")
|
|
261
|
+
|
|
262
|
+
decidim_config.content_security_policies_extra["script-src"] = [] unless decidim_config.content_security_policies_extra.has_key? "script-src"
|
|
263
|
+
decidim_config.content_security_policies_extra["script-src"].push("*.weglot.com")
|
|
264
|
+
decidim_config.content_security_policies_extra["script-src"].push("'unsafe-inline'")
|
|
265
|
+
|
|
266
|
+
decidim_config.content_security_policies_extra["style-src"] = [] unless decidim_config.content_security_policies_extra.has_key? "style-src"
|
|
267
|
+
decidim_config.content_security_policies_extra["style-src"].push("cdn.weglot.com")
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
initializer "decidim.voca.map_configuration", after: :load_config_initializers do
|
|
272
|
+
Decidim.configure do |decidim_config|
|
|
273
|
+
maps_enabled = %w(1 true enabled).include?(ENV.fetch("DECIDIM_MAPS_ENABLED", "true"))
|
|
274
|
+
map_provider = ENV.fetch("MAPS_PROVIDER", "here")
|
|
275
|
+
if !maps_enabled || map_provider.blank?
|
|
276
|
+
decidim_config.maps = nil
|
|
277
|
+
decidim_config.geocoder = nil
|
|
278
|
+
next
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
Rails.logger.warn("Decidim.config.maps will be overridden by voca maps configuration") unless decidim_config.maps
|
|
282
|
+
|
|
283
|
+
# Setup CSP for geocoding, static maps (pngs), dynamic maps (tiles) and autocomplete.
|
|
284
|
+
decidim_config.content_security_policies_extra = {} unless decidim_config.content_security_policies_extra
|
|
285
|
+
decidim_config.content_security_policies_extra["connect-src"] = [] unless decidim_config.content_security_policies_extra.has_key? "connect-src"
|
|
286
|
+
decidim_config.content_security_policies_extra["img-src"] = [] unless decidim_config.content_security_policies_extra.has_key? "img-src"
|
|
287
|
+
|
|
288
|
+
decidim_config.content_security_policies_extra["connect-src"].push("*.hereapi.com", "*.openstreetmap.org", "photon.komoot.io", "*.basemaps.cartocdn.com",
|
|
289
|
+
"*.maps.ls.hereapi.com")
|
|
290
|
+
decidim_config.content_security_policies_extra["img-src"].push("*.hereapi.com", "*.openstreetmap.org", "photon.komoot.io", "*.basemaps.cartocdn.com",
|
|
291
|
+
"*.maps.ls.hereapi.com")
|
|
292
|
+
|
|
293
|
+
decidim_config.maps = {
|
|
294
|
+
provider: map_provider,
|
|
295
|
+
api_key: ENV.fetch("MAPS_API_KEY", ""),
|
|
296
|
+
dynamic: {
|
|
297
|
+
tile_layer: {
|
|
298
|
+
url: "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",
|
|
299
|
+
api_key: false,
|
|
300
|
+
attribution: %(
|
|
301
|
+
<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> contributors
|
|
302
|
+
).strip
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
static: { url: "https://image.maps.hereapi.com/mia/v3/base/mc/overlay" },
|
|
307
|
+
autocomplete: {
|
|
308
|
+
address_format: [%w(street houseNumber), "city", "country"],
|
|
309
|
+
url: "https://photon.komoot.io/api/"
|
|
310
|
+
},
|
|
311
|
+
geocoding: { host: "nominatim.openstreetmap.org", use_https: true }
|
|
312
|
+
}
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
initializer "decidim_voca.webpacker.assets_path" do
|
|
317
|
+
Decidim.register_assets_path File.expand_path("#{Decidim::Voca::Engine.root}/app/packs")
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
initializer "decidim_voca.cells" do
|
|
321
|
+
Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Voca::Engine.root}/app/cells")
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
initializer "decidim_voca.icons" do
|
|
325
|
+
Decidim.icons.register(name: "camera", icon: "camera-line", category: "system", description: "", engine: :core)
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
initializer "decidim_voca.image_processing" do
|
|
329
|
+
# Keep Decidim's default :mini_magick in test (CI / docker often lack a full libvips stack).
|
|
330
|
+
next if Rails.env.test?
|
|
331
|
+
|
|
332
|
+
Rails.application.configure do
|
|
333
|
+
config.active_storage.variant_processor = :vips
|
|
27
334
|
end
|
|
28
335
|
end
|
|
29
336
|
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Voca
|
|
5
|
+
module Export
|
|
6
|
+
# Prepended on CommentSerializer for +locale/body+ columns and +locale+ from human slots.
|
|
7
|
+
module CommentSerializerLocalizedCsv
|
|
8
|
+
def serialize
|
|
9
|
+
data = super
|
|
10
|
+
serialize_localized_data(data)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def serialize_localized_data(data)
|
|
16
|
+
org = resource.organization
|
|
17
|
+
locales = Array(org.available_locales).map(&:to_s).uniq.compact_blank
|
|
18
|
+
return data if locales.empty?
|
|
19
|
+
|
|
20
|
+
nested = {}
|
|
21
|
+
locales.each do |loc|
|
|
22
|
+
nested[loc] = { "body" => CsvWithLocaleTransformer.value_for_locale(resource.body, loc) }
|
|
23
|
+
end
|
|
24
|
+
submission = CsvWithLocaleTransformer.human_source_locale_from(resource.body).presence ||
|
|
25
|
+
data[:locale].to_s.presence ||
|
|
26
|
+
org.default_locale.to_s
|
|
27
|
+
fields_without_body_and_locale = data.except(:body, :locale)
|
|
28
|
+
locale_prefixed_columns = nested.deep_stringify_keys
|
|
29
|
+
fields_without_body_and_locale.merge(locale_prefixed_columns).merge(locale: submission)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Voca
|
|
5
|
+
module Export
|
|
6
|
+
# Pure helpers for locale-first CSV columns (+en/body+, +locale+, …) via
|
|
7
|
+
# +Decidim::Exporters::CSV+ flattening.
|
|
8
|
+
module CsvWithLocaleTransformer
|
|
9
|
+
module_function
|
|
10
|
+
|
|
11
|
+
# Visible string for +locale+ from a Decidim-style i18n (+machine_translations+) hash.
|
|
12
|
+
def value_for_locale(field_hash, locale)
|
|
13
|
+
return "" unless field_hash.is_a?(Hash)
|
|
14
|
+
|
|
15
|
+
h = field_hash.stringify_keys
|
|
16
|
+
loc = locale.to_s
|
|
17
|
+
v = h[loc]
|
|
18
|
+
return v.to_s if v.present?
|
|
19
|
+
|
|
20
|
+
mt = h["machine_translations"]
|
|
21
|
+
return mt[loc].to_s if mt.is_a?(Hash) && mt[loc].present?
|
|
22
|
+
|
|
23
|
+
""
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# First top-level locale key with a non-blank human value (+machine_translations+ excluded).
|
|
27
|
+
def human_source_locale_from(field_hash)
|
|
28
|
+
return nil unless field_hash.is_a?(Hash)
|
|
29
|
+
|
|
30
|
+
field_hash.stringify_keys.except("machine_translations").each do |loc, val|
|
|
31
|
+
return loc if val.present?
|
|
32
|
+
end
|
|
33
|
+
nil
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# @param locales [Array<String>]
|
|
37
|
+
# @param fields [Hash{String => Hash}] field_name => translatable hash from the record
|
|
38
|
+
# @return [Hash{String => Hash}] locale => { field_name => string }
|
|
39
|
+
def columns_for_locales(locales, fields)
|
|
40
|
+
locales = Array(locales).map(&:to_s).uniq.compact_blank
|
|
41
|
+
out = {}
|
|
42
|
+
locales.each do |loc|
|
|
43
|
+
out[loc] = {}
|
|
44
|
+
fields.each do |name, hash|
|
|
45
|
+
out[loc][name.to_s] = value_for_locale(hash, loc)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
out
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Voca
|
|
5
|
+
module Export
|
|
6
|
+
# Prepended on ProposalSerializer: locale-first CSV columns and +locale+ from human slots.
|
|
7
|
+
module ProposalSerializerLocalizedCsv
|
|
8
|
+
def serialize
|
|
9
|
+
data = super
|
|
10
|
+
serialize_localized_data(data)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def serialize_localized_data(data)
|
|
16
|
+
org = proposal.organization
|
|
17
|
+
locales = Array(org.available_locales).map(&:to_s).uniq.compact_blank
|
|
18
|
+
return data if locales.empty?
|
|
19
|
+
|
|
20
|
+
nested = CsvWithLocaleTransformer.columns_for_locales(
|
|
21
|
+
locales,
|
|
22
|
+
"title" => proposal.title,
|
|
23
|
+
"body" => proposal.body,
|
|
24
|
+
"answer" => proposal.answer
|
|
25
|
+
)
|
|
26
|
+
nested.each_value do |inner|
|
|
27
|
+
inner["body"] = plain_export_cell(inner["body"])
|
|
28
|
+
inner["answer"] = plain_export_cell(inner["answer"])
|
|
29
|
+
end
|
|
30
|
+
submission = CsvWithLocaleTransformer.human_source_locale_from(proposal.body).presence ||
|
|
31
|
+
org.default_locale.to_s
|
|
32
|
+
fields_without_translatables = data.except(:title, :body, :answer)
|
|
33
|
+
locale_prefixed_columns = nested.deep_stringify_keys
|
|
34
|
+
fields_without_translatables.merge(locale_prefixed_columns).merge(locale: submission)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def plain_export_cell(str)
|
|
38
|
+
return "" if str.blank?
|
|
39
|
+
|
|
40
|
+
convert_to_plain_text({ "_" => str })["_"].to_s
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Voca
|
|
5
|
+
module Export
|
|
6
|
+
# Prepended on UserResponsesSerializer: +locale/q_<id>+ columns.
|
|
7
|
+
#
|
|
8
|
+
# Decidim does not persist the UI locale used when submitting +Decidim::Forms::Response+
|
|
9
|
+
# (see +Decidim::Forms::AnswerQuestionnaire+). The export +locale+ column uses the
|
|
10
|
+
# organization default as a neutral placeholder.
|
|
11
|
+
module UserAnswersSerializerLocalizedCsv
|
|
12
|
+
def serialize
|
|
13
|
+
data = super
|
|
14
|
+
serialize_localized_data(data)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def serialize_localized_data(data)
|
|
20
|
+
questionnaire = responses&.first&.questionnaire
|
|
21
|
+
return data unless questionnaire
|
|
22
|
+
|
|
23
|
+
org = questionnaire.questionnaire_for.try(:organization)
|
|
24
|
+
return data unless org
|
|
25
|
+
|
|
26
|
+
locales = Array(org.available_locales).map(&:to_s).uniq.compact_blank
|
|
27
|
+
return data if locales.empty?
|
|
28
|
+
|
|
29
|
+
nested = build_answer_columns(questionnaire, responses, locales)
|
|
30
|
+
question_keys = data.keys.select { |k| k.to_s.match?(/\A\d+\.\s/) }
|
|
31
|
+
non_question_fields = data.except(*question_keys)
|
|
32
|
+
locale_prefixed_columns = nested.deep_stringify_keys
|
|
33
|
+
submission_locale = org.default_locale.to_s
|
|
34
|
+
non_question_fields.merge(locale_prefixed_columns).merge(locale: submission_locale)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def build_answer_columns(questionnaire, answers, locales)
|
|
38
|
+
questions = Decidim::Forms::Question.where(decidim_questionnaire_id: questionnaire.id).order(:position)
|
|
39
|
+
nested = {}
|
|
40
|
+
locales.each { |loc| nested[loc] = {} }
|
|
41
|
+
|
|
42
|
+
questions.each do |question|
|
|
43
|
+
answer = answers.find { |a| a.decidim_question_id == question.id }
|
|
44
|
+
val = answer ? normalize_body(answer) : ""
|
|
45
|
+
locales.each do |loc|
|
|
46
|
+
nested[loc]["q_#{question.id}"] = val
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
nested
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Voca
|
|
5
|
+
# Good Job settings. Credentials path is good_job.*.
|
|
6
|
+
# Env name is GOOD_JOB__* (ENV, then credentials). VOCA_* is used only when that value is blank.
|
|
7
|
+
module GoodJobSettings
|
|
8
|
+
DEFAULTS = {
|
|
9
|
+
execution_mode: "async_server",
|
|
10
|
+
max_threads: 5,
|
|
11
|
+
poll_interval: 30,
|
|
12
|
+
shutdown_timeout: 120,
|
|
13
|
+
retry: 5,
|
|
14
|
+
queues: "*"
|
|
15
|
+
}.freeze
|
|
16
|
+
|
|
17
|
+
LEGACY_ENV = {
|
|
18
|
+
execution_mode: "VOCA_ACTIVE_JOB_EXECUTION_MODE",
|
|
19
|
+
max_threads: "VOCA_GOOD_JOB_MAX_THREADS",
|
|
20
|
+
poll_interval: "VOCA_GOOD_JOB_POLL_INTERVAL",
|
|
21
|
+
shutdown_timeout: "VOCA_GOOD_JOB_SHUTDOWN_TIMEOUT",
|
|
22
|
+
retry: "VOCA_GOOD_JOB_RETRY",
|
|
23
|
+
queues: "VOCA_GOOD_JOB_QUEUES"
|
|
24
|
+
}.freeze
|
|
25
|
+
|
|
26
|
+
module_function
|
|
27
|
+
|
|
28
|
+
def execution_mode
|
|
29
|
+
fetch(:execution_mode).to_sym
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def max_threads
|
|
33
|
+
fetch(:max_threads).to_i
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def poll_interval
|
|
37
|
+
fetch(:poll_interval).to_i
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def shutdown_timeout
|
|
41
|
+
fetch(:shutdown_timeout).to_i
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def retry
|
|
45
|
+
fetch(:retry).to_i
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def queues
|
|
49
|
+
fetch(:queues).to_s
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def fetch(key)
|
|
53
|
+
value = canonical(key)
|
|
54
|
+
value = ENV.fetch(LEGACY_ENV.fetch(key), nil) if blank?(value)
|
|
55
|
+
blank?(value) ? DEFAULTS.fetch(key) : value
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def canonical(key)
|
|
59
|
+
if defined?(::CredentialsOverlay)
|
|
60
|
+
from_env = ENV.fetch(::CredentialsOverlay.env_for(:good_job, key), nil)
|
|
61
|
+
return from_env unless blank?(from_env)
|
|
62
|
+
|
|
63
|
+
::CredentialsOverlay.dig(:good_job, key)
|
|
64
|
+
else
|
|
65
|
+
ENV.fetch("GOOD_JOB__#{key.to_s.upcase}", nil)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def blank?(value)
|
|
70
|
+
value.nil? || value == ""
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Voca
|
|
5
|
+
module Installation
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
def decidim_awesome_installed?
|
|
9
|
+
@decidim_awesome_installed ||= Gem.loaded_specs.has_key?("decidim-decidim_awesome")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def decidim_templates_installed?
|
|
13
|
+
@decidim_templates_installed ||= Gem.loaded_specs.has_key?("decidim-templates")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def deepl_installed?
|
|
17
|
+
@deepl_installed ||= Gem.loaded_specs.has_key?("deepl-rb")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def decidim_conferences_installed?
|
|
21
|
+
@decidim_conferences_installed ||= Gem.loaded_specs.has_key?("decidim-conferences")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def decidim_initiatives_installed?
|
|
25
|
+
@decidim_initiatives_installed ||= Gem.loaded_specs.has_key?("decidim-initiatives")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def deepl_enabled?
|
|
29
|
+
deepl_installed? && ::Decidim::Env.new("DECIDIM_DEEPL_API_KEY", "").present?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|