From c5ae503c0ef176572a2980817bb9b1d6c5116ea5 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 18 Feb 2015 20:35:24 +0100 Subject: [PATCH] Fix a severe bug in VariationField --- src/pretix/base/models.py | 10 +++++----- src/pretix/control/views/forms.py | 2 +- src/pretix/control/views/item.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pretix/base/models.py b/src/pretix/base/models.py index 66c76a4df..30825dff0 100644 --- a/src/pretix/base/models.py +++ b/src/pretix/base/models.py @@ -649,12 +649,12 @@ class PropertyValue(Versionable): if self.prop: self.prop.event.get_cache().clear() + @property + def sortkey(self): + return self.position, self.pk + def __lt__(self, other): - if self.position < other.position: - return True - if self.position == other.position: - return self.pk < other.pk - return False + return self.sortkey < other.sortkey class Question(Versionable): diff --git a/src/pretix/control/views/forms.py b/src/pretix/control/views/forms.py index ded2d2683..b13e1e5ec 100644 --- a/src/pretix/control/views/forms.py +++ b/src/pretix/control/views/forms.py @@ -179,7 +179,7 @@ class VariationsFieldRenderer(forms.widgets.CheckboxFieldRenderer): def sort(v): # Given a list of variations, this will sort them by their position # on the x-axis - return v[prop2.identity].identity + return v[prop2.identity].sortkey # We now iterate over the cartesian product of all the other # properties which are NOT on the axes of the grid because we diff --git a/src/pretix/control/views/item.py b/src/pretix/control/views/item.py index e1895a54a..2d3699f08 100644 --- a/src/pretix/control/views/item.py +++ b/src/pretix/control/views/item.py @@ -765,7 +765,7 @@ class ItemVariations(ItemDetailMixin, EventPermissionRequiredMixin, TemplateView def sort(v): # Given a list of variations, this will sort them by their position # on the x-axis - return v[prop2.identity].identity + return v[prop2.identity].sortkey # We now iterate over the cartesian product of all the other # properties which are NOT on the axes of the grid because we