From ab30129fc2b2b80303e11687bdb413d74dec8c08 Mon Sep 17 00:00:00 2001 From: Maico Timmerman Date: Thu, 27 May 2021 10:27:18 +0200 Subject: [PATCH] Call plugin's installed() method upon event creation (#2089) Co-authored-by: Raphael Michel --- src/pretix/base/models/event.py | 5 +++++ src/pretix/control/views/event.py | 2 +- src/pretix/control/views/main.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pretix/base/models/event.py b/src/pretix/base/models/event.py index 4fa42b238f..16b2efd825 100644 --- a/src/pretix/base/models/event.py +++ b/src/pretix/base/models/event.py @@ -637,6 +637,11 @@ class Event(EventMixin, LoggedModel): Quota, ) + # Note: avoid self.set_active_plugins(), it causes trouble e.g. for the badges plugin. + # Plugins can create data in installed() hook based on existing data of the event. + # Calling set_active_plugins() results in defaults being created while actually data + # should come from the copied event. Instead plugins should use event_copy_data to move + # over their data. self.plugins = other.plugins self.is_public = other.is_public if other.date_admission: diff --git a/src/pretix/control/views/event.py b/src/pretix/control/views/event.py index f19a75ef24..9e1274a9d4 100644 --- a/src/pretix/control/views/event.py +++ b/src/pretix/control/views/event.py @@ -1402,7 +1402,7 @@ class QuickSetupView(FormView): }) quota.items.add(*items) - self.request.event.plugins = ",".join(plugins_active) + self.request.event.set_active_plugins(plugins_active, allow_restricted=True) self.request.event.save() messages.success(self.request, _('Your changes have been saved. You can now go on with looking at the details ' 'or take your event live to start selling!')) diff --git a/src/pretix/control/views/main.py b/src/pretix/control/views/main.py index f69610aedd..d4a3a22a63 100644 --- a/src/pretix/control/views/main.py +++ b/src/pretix/control/views/main.py @@ -251,7 +251,7 @@ class EventWizard(SafeSessionWizardView): with transaction.atomic(), language(basics_data['locale']): event = form_dict['basics'].instance event.organizer = foundation_data['organizer'] - event.plugins = settings.PRETIX_PLUGINS_DEFAULT + event.set_active_plugins(settings.PRETIX_PLUGINS_DEFAULT.split(","), allow_restricted=True) event.has_subevents = foundation_data['has_subevents'] event.testmode = True form_dict['basics'].save()