From b18a5f26c0a8a685aad995ea50c4ea447ecde2cf Mon Sep 17 00:00:00 2001 From: Quentin Champenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:11:26 +0100 Subject: [PATCH] fix: Allow to configure deface (#30) * fix: Add arm-darwin-22 support in Gemfile.lock * fix: Add config_accessor in custom proposal states * lint: Remove unused requirement * fix: Deactivate Deface by default * fix: Enable DEFACE by default for test env --- Gemfile.lock | 3 +++ lib/decidim/custom_proposal_states.rb | 6 ++++++ lib/decidim/custom_proposal_states/engine.rb | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 34b6a78..7571155 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -559,6 +559,8 @@ GEM net-smtp (0.4.0) net-protocol nio4r (2.7.0) + nokogiri (1.14.5-arm64-darwin) + racc (~> 1.4) nokogiri (1.14.5-x86_64-linux) racc (~> 1.4) oauth (1.1.0) @@ -852,6 +854,7 @@ GEM zeitwerk (2.6.12) PLATFORMS + arm64-darwin-22 x86_64-linux DEPENDENCIES diff --git a/lib/decidim/custom_proposal_states.rb b/lib/decidim/custom_proposal_states.rb index 2600f17..34e71d9 100644 --- a/lib/decidim/custom_proposal_states.rb +++ b/lib/decidim/custom_proposal_states.rb @@ -8,6 +8,8 @@ module Decidim # This namespace holds the logic of the `CustomProposalStates` component. This component # allows users to create custom_proposal_states in a participatory space. module CustomProposalStates + include ActiveSupport::Configurable + module Overrides autoload :Proposal, "decidim/custom_proposal_states/overrides/proposal" autoload :ImportProposalsToBudgets, "decidim/custom_proposal_states/overrides/import_proposals_to_budgets" @@ -28,6 +30,10 @@ module Overrides autoload :ProposalSearch, "decidim/custom_proposal_states/overrides/proposal_search" end + config_accessor :deface_enabled do + ENV.fetch("DEFACE_ENABLED", nil) == "true" || Rails.env.test? + end + def self.module_installed?(mod) return Decidim.module_installed?(mod) if Decidim.respond_to?(:module_installed?) diff --git a/lib/decidim/custom_proposal_states/engine.rb b/lib/decidim/custom_proposal_states/engine.rb index 3fb2ba0..2ff2bfb 100644 --- a/lib/decidim/custom_proposal_states/engine.rb +++ b/lib/decidim/custom_proposal_states/engine.rb @@ -19,7 +19,7 @@ class Engine < ::Rails::Engine initializer "decidim_custom_proposal_states.views" do Rails.application.configure do - config.deface.enabled = true + config.deface.enabled = Decidim::CustomProposalStates.deface_enabled end end