From f0a0a576b96d0242d47754f4a0f2bff528d1e05d Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 9 Apr 2024 15:41:20 +0200 Subject: ✨ Document: post importer action - set main image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 14b210ea2..e40c7c54c 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -4712,6 +4712,16 @@ class Document( ) ) + @post_importer_action + def set_main_image(self, __, value): + """ + Post importer action - set the imported image as a main image for associated "value" items + """ + for item in getattr(self, value).all(): + item.main_image = self + item.no_post_process() + item.save() + def get_related_operation_ids(self): operations = list(self.operations.values_list("id", flat=True).all()) operations += list( -- cgit v1.2.3