Copy ItemBundle when cloning events

This commit is contained in:
Raphael Michel
2020-11-04 12:30:27 +01:00
parent 78798ff382
commit 04e9c8a226

View File

@@ -507,7 +507,7 @@ class Event(EventMixin, LoggedModel):
def copy_data_from(self, other):
from ..signals import event_copy_data
from . import (
Item, ItemAddOn, ItemCategory, ItemMetaValue, Question, Quota,
Item, ItemAddOn, ItemBundle, ItemCategory, ItemMetaValue, Question, Quota,
)
self.plugins = other.plugins
@@ -573,6 +573,14 @@ class Event(EventMixin, LoggedModel):
ia.addon_category = category_map[ia.addon_category.pk]
ia.save()
for ia in ItemBundle.objects.filter(base_item__event=other).prefetch_related('base_item', 'bundled_item', 'bundled_variation'):
ia.pk = None
ia.base_item = item_map[ia.base_item.pk]
ia.bundled_item = item_map[ia.bundled_item.pk]
if ia.bundled_variation:
ia.bundled_variation = variation_map[ia.bundled_variation.pk]
ia.save()
for q in Quota.objects.filter(event=other, subevent__isnull=True).prefetch_related('items', 'variations'):
items = list(q.items.all())
vars = list(q.variations.all())