From 32b86b081da5db9dcef3bc20f21c585145ef0750 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Fri, 17 Jul 2026 14:43:38 +0200 Subject: [PATCH] Destruction de fichier sans contexte --- app/models/communication/file.rb | 2 ++ app/views/admin/communication/library/files/show.html.erb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/communication/file.rb b/app/models/communication/file.rb index 19065d06b..97fd6103f 100644 --- a/app/models/communication/file.rb +++ b/app/models/communication/file.rb @@ -26,6 +26,8 @@ class Communication::File < ApplicationRecord include LocalizableOrderByNameScope include WithOpenApi + has_many :contexts, through: :localizations + scope :for_search_term, -> (term, language = nil) { joins(:localizations) .where(communication_file_localizations: { language_id: language.id }) diff --git a/app/views/admin/communication/library/files/show.html.erb b/app/views/admin/communication/library/files/show.html.erb index 4e9004c96..e93e83de3 100644 --- a/app/views/admin/communication/library/files/show.html.erb +++ b/app/views/admin/communication/library/files/show.html.erb @@ -2,7 +2,7 @@ <% content_for :title_right do %> <%= button_advanced do %> - <%# FIXME = destroy_link @file if @file.contexts.none? %> + <%= destroy_link @file if @file.contexts.none? %> <% end %> <%= edit_link @file %> <% end %>