Call plugin's installed() method upon event creation (#2089)

Co-authored-by: Raphael Michel <mail@raphaelmichel.de>
This commit is contained in:
Maico Timmerman
2021-05-27 10:27:18 +02:00
committed by GitHub
parent ffc41605f9
commit ab30129fc2
3 changed files with 7 additions and 2 deletions

View File

@@ -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:

View File

@@ -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!'))

View File

@@ -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()