From 5174d380173f7c895adcf4424d923c6cbde157b2 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 7 Mar 2022 09:45:50 +0100 Subject: [PATCH] Do not delete TicketLayout backgrounds long as they're referenced somewhere --- src/pretix/plugins/badges/views.py | 2 +- src/pretix/plugins/ticketoutputpdf/views.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pretix/plugins/badges/views.py b/src/pretix/plugins/badges/views.py index 47e0b7dc9..e5152eb64 100644 --- a/src/pretix/plugins/badges/views.py +++ b/src/pretix/plugins/badges/views.py @@ -227,7 +227,7 @@ class LayoutEditorView(BaseEditorView): return self.layout.background.url if self.layout.background else self.get_default_background() def save_background(self, f: CachedFile): - if self.layout.background: + if self.layout.background and BadgeLayout.objects.filter(background=self.layout.background).count() == 1: self.layout.background.delete() self.layout.background.save('background.pdf', f.file) diff --git a/src/pretix/plugins/ticketoutputpdf/views.py b/src/pretix/plugins/ticketoutputpdf/views.py index aa032126d..0a1e38375 100644 --- a/src/pretix/plugins/ticketoutputpdf/views.py +++ b/src/pretix/plugins/ticketoutputpdf/views.py @@ -282,7 +282,7 @@ class LayoutEditorView(BaseEditorView): return self.layout.background.url if self.layout.background else self.get_default_background() def save_background(self, f: CachedFile): - if self.layout.background: + if self.layout.background and TicketLayout.objects.filter(background=self.layout.background).count() == 1: self.layout.background.delete() self.layout.background.save('background.pdf', f.file) invalidate_cache.apply_async(kwargs={'event': self.request.event.pk, 'provider': 'pdf'})