forked from CGM_Public/pretix_original
Versionable.clone_shallow() has to set version_end_date records
This commit is contained in:
@@ -71,7 +71,8 @@ class Versionable(BaseVersionable):
|
|||||||
source = getattr(self, manager_field_name) # returns a VersionedRelatedManager instance
|
source = getattr(self, manager_field_name) # returns a VersionedRelatedManager instance
|
||||||
# Destination: the clone, where the cloned relations should point to
|
# Destination: the clone, where the cloned relations should point to
|
||||||
source.through.objects.filter(**{source.source_field.attname: clone.id}).update(**{
|
source.through.objects.filter(**{source.source_field.attname: clone.id}).update(**{
|
||||||
source.source_field.attname: self.id})
|
source.source_field.attname: self.id, 'version_end_date': forced_version_date
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class UserManager(BaseUserManager):
|
class UserManager(BaseUserManager):
|
||||||
|
|||||||
@@ -514,22 +514,21 @@ class QuotaEditorMixin:
|
|||||||
# optimization of pretixbase.models.Versionable.clone_shallow()
|
# optimization of pretixbase.models.Versionable.clone_shallow()
|
||||||
# items = self.object.items.all()
|
# items = self.object.items.all()
|
||||||
# variations = self.object.variations.all()
|
# variations = self.object.variations.all()
|
||||||
|
selected_variations = []
|
||||||
self.object = form.instance
|
self.object = form.instance
|
||||||
for item in self.items:
|
for item in self.items:
|
||||||
field = form.fields['item_%s' % item.identity]
|
field = form.fields['item_%s' % item.identity]
|
||||||
data = form.cleaned_data['item_%s' % item.identity]
|
data = form.cleaned_data['item_%s' % item.identity]
|
||||||
if isinstance(field, VariationsField):
|
if isinstance(field, VariationsField):
|
||||||
self.object.variations.add(*data)
|
for v in data:
|
||||||
# for v in data:
|
selected_variations.append(v)
|
||||||
# if v not in variations:
|
|
||||||
# self.object.variations.add(v)
|
|
||||||
# for v in variations:
|
|
||||||
# if v not in data:
|
|
||||||
# self.object.variations.remove(v)
|
|
||||||
if data: # and item not in items:
|
if data: # and item not in items:
|
||||||
self.object.items.add(item)
|
self.object.items.add(item)
|
||||||
# elif not data and item in items:
|
# elif not data and item in items:
|
||||||
# self.object.items.remove(item)
|
# self.object.items.remove(item)
|
||||||
|
|
||||||
|
self.object.variations.add(*[v for v in selected_variations]) # if v not in variations])
|
||||||
|
# self.object.variations.remove(*[v for v in variations if v not in selected_variations])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user