Fix #372 -- Plugin hook for "Copy from event"

This commit is contained in:
Raphael Michel
2017-04-26 15:24:16 +02:00
parent 39513448f3
commit bbe272c35c
3 changed files with 20 additions and 1 deletions

View File

@@ -226,6 +226,8 @@ class Event(LoggedModel):
def copy_data_from(self, other):
from . import ItemAddOn, ItemCategory, Item, Question, Quota
from ..signals import event_copy_data
self.plugins = other.plugins
self.save()
@@ -297,6 +299,8 @@ class Event(LoggedModel):
s.value = 'file://' + newname
s.save()
event_copy_data.send(sender=self, other=other)
def generate_invite_token():
return get_random_string(length=32, allowed_chars=string.ascii_lowercase + string.digits)

View File

@@ -153,6 +153,21 @@ to the user. The receivers are expected to return HTML code.
As with all event-plugin signals, the ``sender`` keyword argument will contain the event.
"""
event_copy_data = EventPluginSignal(
providing_args=["other"]
)
"""
This signal is sent out when a new event is created as a clone of an existing event, i.e.
the settings from the older event are copied to the newer one. You can listen to this
signal to copy data or configuration stored within your plugin's models as well.
You don't need to copy data inside the general settings storage which is cloned automatically,
but you might need to modify that data.
The ``sender`` keyword argument will contain the event of the **new** event. The ``other``
keyword argument will contain the event to **copy from**.
"""
periodic_task = django.dispatch.Signal()
"""
This is a regular django signal (no pretix event signal) that we send out every