forked from CGM_Public/pretix_original
SubEvent editing: Pass copy_from to plugins
This commit is contained in:
@@ -36,7 +36,7 @@ def validate_plan_change(event, subevent, plan):
|
||||
'already sold.'), leftovers[0])
|
||||
|
||||
|
||||
def generate_seats(event, subevent, plan, mapping):
|
||||
def generate_seats(event, subevent, plan, mapping, blocked_guids=None):
|
||||
current_seats = {}
|
||||
for s in event.seats.select_related('product').annotate(
|
||||
has_op=Count('orderposition'), has_v=Count('vouchers')
|
||||
@@ -68,7 +68,10 @@ def generate_seats(event, subevent, plan, mapping):
|
||||
update(seat, 'seat_label', ss.seat_label),
|
||||
update(seat, 'x', ss.x),
|
||||
update(seat, 'y', ss.y),
|
||||
])
|
||||
] + (
|
||||
[update(seat, 'blocked', ss.guid in blocked_guids)]
|
||||
if blocked_guids else []
|
||||
))
|
||||
if updated:
|
||||
seat.save()
|
||||
else:
|
||||
@@ -84,6 +87,7 @@ def generate_seats(event, subevent, plan, mapping):
|
||||
seat_label=ss.seat_label,
|
||||
x=ss.x,
|
||||
y=ss.y,
|
||||
blocked=bool(blocked_guids and ss.guid in blocked_guids),
|
||||
product=p,
|
||||
))
|
||||
|
||||
|
||||
@@ -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