From ce8c179c59bcee28ac28726ff4cb0683d1138beb Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Sun, 16 Jul 2023 07:34:43 +0200 Subject: [PATCH] automatism stops on manual action --- .../communication/websites/menus/items_controller.rb | 2 ++ app/models/communication/website/menu.rb | 1 + .../communication/website/menu/with_automatism.rb | 12 ++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 app/models/communication/website/menu/with_automatism.rb diff --git a/app/controllers/admin/communication/websites/menus/items_controller.rb b/app/controllers/admin/communication/websites/menus/items_controller.rb index d110e26bb..dd37cd429 100644 --- a/app/controllers/admin/communication/websites/menus/items_controller.rb +++ b/app/controllers/admin/communication/websites/menus/items_controller.rb @@ -50,6 +50,7 @@ class Admin::Communication::Websites::Menus::ItemsController < Admin::Communicat end def create + @menu.stop_automatism! @item.menu = @menu @item.website = @website if @item.save @@ -62,6 +63,7 @@ class Admin::Communication::Websites::Menus::ItemsController < Admin::Communicat end def update + @menu.stop_automatism! if @item.update(item_params) redirect_to redirect_path(@item), notice: t('admin.successfully_updated_html', model: @item.to_s) diff --git a/app/models/communication/website/menu.rb b/app/models/communication/website/menu.rb index f617f1c0d..fc424526f 100644 --- a/app/models/communication/website/menu.rb +++ b/app/models/communication/website/menu.rb @@ -30,6 +30,7 @@ class Communication::Website::Menu < ApplicationRecord include AsDirectObject include Sanitizable + include WithAutomatism include WithTranslations include WithUniversity diff --git a/app/models/communication/website/menu/with_automatism.rb b/app/models/communication/website/menu/with_automatism.rb new file mode 100644 index 000000000..fa4ff8540 --- /dev/null +++ b/app/models/communication/website/menu/with_automatism.rb @@ -0,0 +1,12 @@ +module Communication::Website::Menu::WithAutomatism + extend ActiveSupport::Concern + + def create_automatic_menu + + end + + def stop_automatism! + update_column :automatic, false + end + +end \ No newline at end of file -- GitLab