From 0ee07f80c0ee2186cc6ab72bc173b9c1a134adb6 Mon Sep 17 00:00:00 2001 From: Simon Tharby Date: Thu, 29 Aug 2024 21:34:19 +0100 Subject: [PATCH] [TAN-2512] dependent destroy idea_import_files & children when project deleted --- back/app/models/project.rb | 1 + .../app/models/bulk_import_ideas/idea_import_file.rb | 2 +- .../app/models/bulk_import_ideas/patches/project.rb | 7 +++++++ env_files/back-safe.env | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/patches/project.rb diff --git a/back/app/models/project.rb b/back/app/models/project.rb index 33a19d06db24..58eb18d4be05 100644 --- a/back/app/models/project.rb +++ b/back/app/models/project.rb @@ -287,3 +287,4 @@ def old_folder_moderators Project.include(ContentBuilder::Patches::Project) Project.include(Analysis::Patches::Project) Project.include(EmailCampaigns::Extensions::Project) +Project.include(BulkImportIdeas::Patches::Project) diff --git a/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/idea_import_file.rb b/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/idea_import_file.rb index 741e9a1fe744..21c61fd2e685 100644 --- a/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/idea_import_file.rb +++ b/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/idea_import_file.rb @@ -35,7 +35,7 @@ class IdeaImportFile < ApplicationRecord belongs_to :project, optional: true belongs_to :parent, class_name: 'BulkImportIdeas::IdeaImportFile', optional: true - has_many :children, class_name: 'BulkImportIdeas::IdeaImportFile', foreign_key: 'parent_id' + has_many :children, class_name: 'BulkImportIdeas::IdeaImportFile', foreign_key: 'parent_id', dependent: :destroy validates :name, presence: true validates :file, presence: true, unless: proc { Current.loading_tenant_template } diff --git a/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/patches/project.rb b/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/patches/project.rb new file mode 100644 index 000000000000..c150b612ba1a --- /dev/null +++ b/back/engines/commercial/bulk_import_ideas/app/models/bulk_import_ideas/patches/project.rb @@ -0,0 +1,7 @@ +module BulkImportIdeas::Patches::Project + def self.included(base) + base.class_eval do + has_many :idea_import_files, class_name: 'BulkImportIdeas::IdeaImportFile', dependent: :destroy + end + end +end diff --git a/env_files/back-safe.env b/env_files/back-safe.env index 67993caf5781..42e51e3eec32 100644 --- a/env_files/back-safe.env +++ b/env_files/back-safe.env @@ -21,7 +21,7 @@ AWS_TOXICITY_DETECTION_REGION=eu-central-1 # ==== Development experience configuration ==== SEED_SIZE=small # Tenant is fetched by this host name: -OVERRIDE_HOST=localhost +OVERRIDE_HOST=yourvoice_westoxon_gov_uk # Set to `true` if you want to upload/download files to/from AWS S3: USE_AWS_S3_IN_DEV=false # If USE_AWS_S3_IN_DEV=false, this host is used in file URLs (find it in the code for details):