From a8454c9ff5fa3d8d43cbeac7636829947d000214 Mon Sep 17 00:00:00 2001 From: Oliver Valls <199462+tramuntanal@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:06:22 +0200 Subject: [PATCH 1/3] Fix decidim-templates dependency --- Gemfile.lock | 2 +- decidim-admin/config/routes.rb | 1 + decidim-core/lib/decidim/core.rb | 9 ++++++--- decidim-forms/lib/decidim/forms.rb | 2 ++ decidim-surveys/lib/decidim/surveys.rb | 2 ++ decidim-templates/lib/decidim/templates/admin_engine.rb | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1887237807f1a..662a854561ecd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -831,4 +831,4 @@ RUBY VERSION ruby 3.1.1p18 BUNDLED WITH - 2.4.6 + 2.5.14 diff --git a/decidim-admin/config/routes.rb b/decidim-admin/config/routes.rb index 2ed8c928ec705..f89f21ca6d756 100644 --- a/decidim-admin/config/routes.rb +++ b/decidim-admin/config/routes.rb @@ -18,6 +18,7 @@ Decidim.participatory_space_manifests.each do |manifest| mount manifest.context(:admin).engine, at: "/", as: "decidim_admin_#{manifest.name}" end + mount Decidim::Templates::AdminEngine, at: "/", as: "decidim_admin_templates" resources :static_pages do put :update_content_blocks, on: :member diff --git a/decidim-core/lib/decidim/core.rb b/decidim-core/lib/decidim/core.rb index f8ed81e382a28..4308371e1366a 100644 --- a/decidim-core/lib/decidim/core.rb +++ b/decidim-core/lib/decidim/core.rb @@ -870,9 +870,12 @@ def self.module_installed?(mod) # user lists e.g. "decidim-core" and "decidim-budgets" in it. In this # situation, "decidim-comments" is also needed because it is a dependency # for "decidim-budgets". - require "decidim/#{mod}" - - true + if mod.to_sym == :templates + Bundler.definition.dependencies.find { |d| d.name == "decidim-templates" }.present? && require("decidim/#{mod}") + else + require "decidim/#{mod}" + true + end rescue LoadError false end diff --git a/decidim-forms/lib/decidim/forms.rb b/decidim-forms/lib/decidim/forms.rb index 5c3db346089d2..d3f4837c05329 100644 --- a/decidim-forms/lib/decidim/forms.rb +++ b/decidim-forms/lib/decidim/forms.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "decidim/templates" if Decidim.module_installed?(:templates) + require "decidim/forms/admin" require "decidim/forms/api" require "decidim/forms/engine" diff --git a/decidim-surveys/lib/decidim/surveys.rb b/decidim-surveys/lib/decidim/surveys.rb index d49ea6def2b56..2b97d29937d21 100644 --- a/decidim-surveys/lib/decidim/surveys.rb +++ b/decidim-surveys/lib/decidim/surveys.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "decidim/templates" if Decidim.module_installed?(:templates) + require "decidim/surveys/admin" require "decidim/surveys/api" require "decidim/surveys/engine" diff --git a/decidim-templates/lib/decidim/templates/admin_engine.rb b/decidim-templates/lib/decidim/templates/admin_engine.rb index 2d26b6869b7ca..5f774ecf1b04a 100644 --- a/decidim-templates/lib/decidim/templates/admin_engine.rb +++ b/decidim-templates/lib/decidim/templates/admin_engine.rb @@ -4,7 +4,7 @@ module Decidim module Templates - # This is the engine that runs on the public interface of `Templates`. + # This is the engine that runs on the admin panel interface of `Templates`. class AdminEngine < ::Rails::Engine isolate_namespace Decidim::Templates::Admin From a105bab8380e196ef7ccb3603e4f43aa3a24cd8a Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 13 Dec 2024 10:51:23 +0100 Subject: [PATCH 2/3] Fix active link templates in admin --- Gemfile.lock | 2 +- decidim-admin/config/routes.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 662a854561ecd..1887237807f1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -831,4 +831,4 @@ RUBY VERSION ruby 3.1.1p18 BUNDLED WITH - 2.5.14 + 2.4.6 diff --git a/decidim-admin/config/routes.rb b/decidim-admin/config/routes.rb index f89f21ca6d756..2ed8c928ec705 100644 --- a/decidim-admin/config/routes.rb +++ b/decidim-admin/config/routes.rb @@ -18,7 +18,6 @@ Decidim.participatory_space_manifests.each do |manifest| mount manifest.context(:admin).engine, at: "/", as: "decidim_admin_#{manifest.name}" end - mount Decidim::Templates::AdminEngine, at: "/", as: "decidim_admin_templates" resources :static_pages do put :update_content_blocks, on: :member From c1e57f5fca7c98507635748e9dde83161b28a76d Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Mon, 16 Dec 2024 12:29:34 +0100 Subject: [PATCH 3/3] Remove if in templates routes --- decidim-admin/config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decidim-admin/config/routes.rb b/decidim-admin/config/routes.rb index 2ed8c928ec705..307a0c2cd6bf9 100644 --- a/decidim-admin/config/routes.rb +++ b/decidim-admin/config/routes.rb @@ -39,7 +39,7 @@ mount manifest.admin_engine, at: "/#{manifest.name}", as: "decidim_admin_#{manifest.name}" end - mount Decidim::Templates::AdminEngine, at: "/templates", as: "decidim_admin_templates" if Decidim.module_installed?(:templates) + mount Decidim::Templates::AdminEngine, at: "/templates", as: "decidim_admin_templates" resources :users, except: [:edit, :update], controller: "users" do member do