From 56ae9a06e997ca22d36ff2e6fbadab0767d37fdf Mon Sep 17 00:00:00 2001 From: Jean-Marie Favreau Date: Sun, 2 Mar 2025 16:30:02 +0100 Subject: [PATCH] =?UTF-8?q?On=20ne=20supprime=20pas=20les=20dupliqu=C3=A9s?= =?UTF-8?q?=20m=C3=AAme=20s'ils=20sont=20dans=20le=20m=C3=AAme=20import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agenda_culturel/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index 554b523..b98d19f 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -1481,12 +1481,15 @@ class Event(models.Model): # check if we need to clean the other_versions if ( not clone + and not "noclean_other_versions" in kwargs and self.pk and self.other_versions is not None and self.other_versions.nb_duplicated() == 1 ): self.other_versions.delete() self.other_versions = None + if "noclean_other_versions" in kwargs: + del kwargs["noclean_other_versions"] # first save the current object super().save(*args, **kwargs) @@ -2042,7 +2045,7 @@ class Event(models.Model): or new_image ): same_imported.download_image() - same_imported.save(update_fields=["local_image"]) + same_imported.save(update_fields=["local_image"], noclean_other_versions=True) to_update.append(same_imported) else: