Copy add-ons during event cloning

This commit is contained in:
Raphael Michel
2017-04-18 20:31:16 +02:00
parent ec73c916b7
commit 0b068f6d79
2 changed files with 9 additions and 3 deletions

View File

@@ -8,8 +8,8 @@ from .event import (
)
from .invoices import Invoice, InvoiceLine, invoice_filename
from .items import (
Item, ItemCategory, ItemVariation, Question, QuestionOption, Quota,
itempicture_upload_to,
Item, ItemAddOn, ItemCategory, ItemVariation, Question, QuestionOption,
Quota, itempicture_upload_to,
)
from .log import LogEntry
from .orders import (

View File

@@ -225,7 +225,7 @@ class Event(LoggedModel):
), tz)
def copy_data_from(self, other):
from . import ItemCategory, Item, Question, Quota
from . import ItemAddOn, ItemCategory, Item, Question, Quota
self.plugins = other.plugins
self.save()
@@ -254,6 +254,12 @@ class Event(LoggedModel):
v.item = i
v.save()
for ia in ItemAddOn.objects.filter(base_item__event=other).prefetch_related('base_item', 'addon_category'):
ia.pk = None
ia.base_item = item_map[ia.base_item.pk]
ia.addon_category = category_map[ia.addon_category.pk]
ia.save()
for q in Quota.objects.filter(event=other).prefetch_related('items', 'variations'):
items = list(q.items.all())
vars = list(q.variations.all())