From 4090ee4cc47d0787cb96d9022c3e6f96d3792c63 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Thu, 30 Nov 2023 15:49:16 +0100 Subject: [PATCH] fix --- .../websites/posts/categories_controller.rb | 4 ++-- app/models/communication/website.rb | 3 ++- .../website/with_connected_objects.rb | 3 ++- .../website/with_program_categories.rb | 4 ++-- .../website/agenda/categories.yml | 20 +++++++++---------- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/admin/communication/websites/posts/categories_controller.rb b/app/controllers/admin/communication/websites/posts/categories_controller.rb index 77ee082c9..c0c9f4eef 100644 --- a/app/controllers/admin/communication/websites/posts/categories_controller.rb +++ b/app/controllers/admin/communication/websites/posts/categories_controller.rb @@ -13,8 +13,8 @@ class Admin::Communication::Websites::Posts::CategoriesController < Admin::Commu end def reorder - parent_id = params[:parentId].blank? ? nil : params[:parentId] - old_parent_id = params[:oldParentId].blank? ? nil : params[:oldParentId] + parent_id = params.dig(:parentId) + old_parent_id = params.dig(:oldParentId) ids = params[:ids] || [] ids.each.with_index do |id, index| category = @website.post_categories.find(id) diff --git a/app/models/communication/website.rb b/app/models/communication/website.rb index 4fd5f074d..fd03007eb 100644 --- a/app/models/communication/website.rb +++ b/app/models/communication/website.rb @@ -114,8 +114,9 @@ class Communication::Website < ApplicationRecord configs + pages.where(language_id: language_ids) + posts.where(language_id: language_ids) + + post_categories.where(language_id: language_ids) + events.where(language_id: language_ids) + - categories.where(language_id: language_ids) + + agenda_categories.where(language_id: language_ids) + menus.where(language_id: language_ids) + [about] + [default_image&.blob] diff --git a/app/models/communication/website/with_connected_objects.rb b/app/models/communication/website/with_connected_objects.rb index 50cc509ab..497dc69b9 100644 --- a/app/models/communication/website/with_connected_objects.rb +++ b/app/models/communication/website/with_connected_objects.rb @@ -10,7 +10,8 @@ module Communication::Website::WithConnectedObjects def clean_and_rebuild pages.find_each(&:connect_dependencies) posts.find_each(&:connect_dependencies) - categories.find_each(&:connect_dependencies) + post_categories.find_each(&:connect_dependencies) + agenda_categories.find_each(&:connect_dependencies) menus.find_each(&:connect_dependencies) connect(about, self) if about.present? destroy_obsolete_connections diff --git a/app/models/communication/website/with_program_categories.rb b/app/models/communication/website/with_program_categories.rb index a2f9bd468..4d4585894 100644 --- a/app/models/communication/website/with_program_categories.rb +++ b/app/models/communication/website/with_program_categories.rb @@ -8,7 +8,7 @@ module Communication::Website::WithProgramCategories # TODO : I18n # Actuellement, on ne crée que dans la langue par défaut du website, on ne gère pas les autres langues def set_programs_categories! - programs_root_category = categories.for_language_id(default_language_id).where(is_programs_root: true).first_or_create( + programs_root_category = post_categories.for_language_id(default_language_id).where(is_programs_root: true).first_or_create( name: 'Offre de formation', slug: 'offre-de-formation', is_programs_root: true, @@ -22,7 +22,7 @@ module Communication::Website::WithProgramCategories def set_programs_categories_at_level!(parent_category, programs) programs.map.with_index do |program, index| - category = categories.for_language_id(default_language_id).where(program_id: program.id).first_or_initialize( + category = post_categories.for_language_id(default_language_id).where(program_id: program.id).first_or_initialize( name: program.name, slug: program.name.parameterize, university_id: university.id diff --git a/test/fixtures/communication/website/agenda/categories.yml b/test/fixtures/communication/website/agenda/categories.yml index 80aea801a..2e9d4b659 100644 --- a/test/fixtures/communication/website/agenda/categories.yml +++ b/test/fixtures/communication/website/agenda/categories.yml @@ -35,28 +35,26 @@ one: name: MyString - path: MyString + path: 'my-string' position: 1 featured_image_alt: MyString featured_image_credit: MyText meta_description: MyText slug: MyString summary: MyText - communication_website: one - language: one - original: one - university: one + language: fr + university: default_university + website: website_with_github two: name: MyString - path: MyString - position: 1 + path: 'my-string' + position: 2 featured_image_alt: MyString featured_image_credit: MyText meta_description: MyText slug: MyString summary: MyText - communication_website: two - language: two - original: two - university: two + language: fr + university: default_university + website: website_with_github -- GitLab