From 5accf22e4b14d64540008bf5eb331e1ec0a33eaf Mon Sep 17 00:00:00 2001 From: Harrison Hassig Date: Fri, 18 Oct 2024 12:26:05 +0200 Subject: [PATCH] Add term customizer gem and one time actions (#14) --- Gemfile | 1 + Gemfile.lock | 10 +++++++ ...ranslation_sets.decidim_term_customizer.rb | 10 +++++++ ...er_translations.decidim_term_customizer.rb | 19 +++++++++++++ ...zer_constraints.decidim_term_customizer.rb | 18 +++++++++++++ db/schema.rb | 27 ++++++++++++++++++- .../decidim_awesome/custom_styles_spec.rb | 2 +- 7 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20241018100809_create_decidim_term_customizer_translation_sets.decidim_term_customizer.rb create mode 100644 db/migrate/20241018100810_create_decidim_term_customizer_translations.decidim_term_customizer.rb create mode 100644 db/migrate/20241018100811_create_decidim_term_customizer_constraints.decidim_term_customizer.rb diff --git a/Gemfile b/Gemfile index 151096f..375a1c1 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,7 @@ gem "decidim", DECIDIM_VERSION gem "decidim-templates", DECIDIM_VERSION gem "decidim-decidim_awesome" +gem "decidim-term_customizer", git: "https://github.com/mainio/decidim-module-term_customizer.git", branch: "main" gem "decidim-ub" gem "bootsnap", "~> 1.3" diff --git a/Gemfile.lock b/Gemfile.lock index 82ce77f..632196e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,12 @@ +GIT + remote: https://github.com/mainio/decidim-module-term_customizer.git + revision: 9133eea57ebfc4164b640efd1ac6b9ca1628c793 + branch: main + specs: + decidim-term_customizer (0.28.0) + decidim-admin (~> 0.28.0) + decidim-core (~> 0.28.0) + GEM remote: https://rubygems.org/ specs: @@ -887,6 +896,7 @@ DEPENDENCIES decidim-decidim_awesome decidim-dev (= 0.28.2) decidim-templates (= 0.28.2) + decidim-term_customizer! decidim-ub figaro (~> 1.2) letter_opener_web (~> 2.0) diff --git a/db/migrate/20241018100809_create_decidim_term_customizer_translation_sets.decidim_term_customizer.rb b/db/migrate/20241018100809_create_decidim_term_customizer_translation_sets.decidim_term_customizer.rb new file mode 100644 index 0000000..c0fc109 --- /dev/null +++ b/db/migrate/20241018100809_create_decidim_term_customizer_translation_sets.decidim_term_customizer.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +# This migration comes from decidim_term_customizer (originally 20190217132503) + +class CreateDecidimTermCustomizerTranslationSets < ActiveRecord::Migration[5.2] + def change + create_table :decidim_term_customizer_translation_sets do |t| + t.jsonb :name + end + end +end diff --git a/db/migrate/20241018100810_create_decidim_term_customizer_translations.decidim_term_customizer.rb b/db/migrate/20241018100810_create_decidim_term_customizer_translations.decidim_term_customizer.rb new file mode 100644 index 0000000..90bced4 --- /dev/null +++ b/db/migrate/20241018100810_create_decidim_term_customizer_translations.decidim_term_customizer.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true +# This migration comes from decidim_term_customizer (originally 20190217132654) + +class CreateDecidimTermCustomizerTranslations < ActiveRecord::Migration[5.2] + def change + create_table :decidim_term_customizer_translations do |t| + t.string :locale + t.string :key + t.text :value + + t.references( + :translation_set, + null: false, + foreign_key: { to_table: :decidim_term_customizer_translation_sets }, + index: { name: "decidim_term_customizer_translation_translation_set" } + ) + end + end +end diff --git a/db/migrate/20241018100811_create_decidim_term_customizer_constraints.decidim_term_customizer.rb b/db/migrate/20241018100811_create_decidim_term_customizer_constraints.decidim_term_customizer.rb new file mode 100644 index 0000000..c027259 --- /dev/null +++ b/db/migrate/20241018100811_create_decidim_term_customizer_constraints.decidim_term_customizer.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true +# This migration comes from decidim_term_customizer (originally 20190217132726) + +class CreateDecidimTermCustomizerConstraints < ActiveRecord::Migration[5.2] + def change + create_table :decidim_term_customizer_constraints do |t| + t.references :decidim_organization, null: false, foreign_key: true, index: { name: "decidim_term_customizer_constraint_organization" } + t.references :subject, polymorphic: true, index: { name: "decidim_term_customizer_constraint_subject" } + + t.references( + :translation_set, + null: false, + foreign_key: { to_table: :decidim_term_customizer_translation_sets }, + index: { name: "decidim_term_customizer_constraint_translation_set" } + ) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 71301c0..bca29d6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_09_06_102431) do +ActiveRecord::Schema.define(version: 2024_10_18_100811) do # These are extensions that must be enabled in order to support this database enable_extension "ltree" @@ -1534,6 +1534,28 @@ t.index ["templatable_type", "templatable_id"], name: "index_decidim_templates_templatable" end + create_table "decidim_term_customizer_constraints", force: :cascade do |t| + t.bigint "decidim_organization_id", null: false + t.string "subject_type" + t.bigint "subject_id" + t.bigint "translation_set_id", null: false + t.index ["decidim_organization_id"], name: "decidim_term_customizer_constraint_organization" + t.index ["subject_type", "subject_id"], name: "decidim_term_customizer_constraint_subject" + t.index ["translation_set_id"], name: "decidim_term_customizer_constraint_translation_set" + end + + create_table "decidim_term_customizer_translation_sets", force: :cascade do |t| + t.jsonb "name" + end + + create_table "decidim_term_customizer_translations", force: :cascade do |t| + t.string "locale" + t.string "key" + t.text "value" + t.bigint "translation_set_id", null: false + t.index ["translation_set_id"], name: "decidim_term_customizer_translation_translation_set" + end + create_table "decidim_user_blocks", force: :cascade do |t| t.bigint "decidim_user_id" t.integer "blocking_user_id" @@ -1771,6 +1793,9 @@ add_foreign_key "decidim_scopes", "decidim_scope_types", column: "scope_type_id" add_foreign_key "decidim_scopes", "decidim_scopes", column: "parent_id" add_foreign_key "decidim_static_pages", "decidim_organizations" + add_foreign_key "decidim_term_customizer_constraints", "decidim_organizations" + add_foreign_key "decidim_term_customizer_constraints", "decidim_term_customizer_translation_sets", column: "translation_set_id" + add_foreign_key "decidim_term_customizer_translations", "decidim_term_customizer_translation_sets", column: "translation_set_id" add_foreign_key "decidim_user_blocks", "decidim_users" add_foreign_key "decidim_user_blocks", "decidim_users", column: "blocking_user_id" add_foreign_key "decidim_user_moderations", "decidim_users" diff --git a/spec/system/decidim_awesome/custom_styles_spec.rb b/spec/system/decidim_awesome/custom_styles_spec.rb index 856c832..10de891 100644 --- a/spec/system/decidim_awesome/custom_styles_spec.rb +++ b/spec/system/decidim_awesome/custom_styles_spec.rb @@ -33,7 +33,7 @@ expect(page.body).to have_no_content("body {background: red;}") end - it "css is not applyied" do + it "css is not applied" do expect(page.execute_script("return window.getComputedStyle($('body')[0]).backgroundColor")).to eq("rgba(0, 0, 0, 0)") end end