mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
SubEvent editing: Pass copy_from to plugins
This commit is contained in:
@@ -291,7 +291,7 @@ As with all plugin signals, the ``sender`` keyword argument will contain the eve
|
||||
"""
|
||||
|
||||
subevent_forms = EventPluginSignal(
|
||||
providing_args=['request', 'subevent']
|
||||
providing_args=['request', 'subevent', 'copy_from']
|
||||
)
|
||||
"""
|
||||
This signal allows you to return additional forms that should be rendered on the subevent creation
|
||||
@@ -301,7 +301,8 @@ as part of the standard validation and rendering cycle and rendered using defaul
|
||||
styles. It is advisable to set a prefix for your form to avoid clashes with other plugins.
|
||||
|
||||
``subevent`` can be ``None`` during creation. Before ``save()`` is called, a ``subevent`` property of
|
||||
your form instance will automatically being set to the subevent that has just been created.
|
||||
your form instance will automatically being set to the subevent that has just been created. During
|
||||
creation, ``copy_from`` can be a subevent that is being copied from.
|
||||
|
||||
As with all plugin signals, the ``sender`` keyword argument will contain the event.
|
||||
"""
|
||||
|
||||
@@ -151,7 +151,8 @@ class SubEventEditorMixin(MetaDataEditorMixin):
|
||||
@cached_property
|
||||
def plugin_forms(self):
|
||||
forms = []
|
||||
for rec, resp in subevent_forms.send(sender=self.request.event, subevent=self.object, request=self.request):
|
||||
for rec, resp in subevent_forms.send(sender=self.request.event, subevent=self.object, request=self.request,
|
||||
copy_from=self.copy_from):
|
||||
if isinstance(resp, (list, tuple)):
|
||||
forms.extend(resp)
|
||||
else:
|
||||
@@ -323,7 +324,7 @@ class SubEventEditorMixin(MetaDataEditorMixin):
|
||||
|
||||
@cached_property
|
||||
def copy_from(self):
|
||||
if self.request.GET.get("copy_from") and not getattr(self, 'object', None):
|
||||
if self.request.GET.get("copy_from") and (not getattr(self, 'object', None) or not self.object.pk):
|
||||
try:
|
||||
return self.request.event.subevents.get(pk=self.request.GET.get("copy_from"))
|
||||
except SubEvent.DoesNotExist:
|
||||
|
||||
Reference in New Issue
Block a user