Bugfix: Fix display order in multi-item compartments
This commit is contained in:
parent
970f314c06
commit
3d3fe2969a
1 changed files with 2 additions and 5 deletions
|
@ -18,9 +18,6 @@ class BoxView(CanBeIndexMixin, DetailView):
|
||||||
'layout'
|
'layout'
|
||||||
).prefetch_related(
|
).prefetch_related(
|
||||||
'box_related'
|
'box_related'
|
||||||
).order_by(
|
|
||||||
'index',
|
|
||||||
'id'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def layout(self, obj: QuerySet, layout: list[Union[list, int]], idx=0):
|
def layout(self, obj: QuerySet, layout: list[Union[list, int]], idx=0):
|
||||||
|
@ -31,7 +28,7 @@ class BoxView(CanBeIndexMixin, DetailView):
|
||||||
result.append(resulting_sublayout)
|
result.append(resulting_sublayout)
|
||||||
idx = new_idx
|
idx = new_idx
|
||||||
else:
|
else:
|
||||||
instances = obj.filter(index=idx)
|
instances = obj.filter(index=idx).order_by('id')
|
||||||
items: List[dict[str, Any]] = []
|
items: List[dict[str, Any]] = []
|
||||||
|
|
||||||
# Add all items to the layout container
|
# Add all items to the layout container
|
||||||
|
@ -54,7 +51,7 @@ class BoxView(CanBeIndexMixin, DetailView):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self.object = cast(Box, self.get_object())
|
self.object = cast(Box, self.get_object())
|
||||||
context = self.get_context_data(object=self.object)
|
context = self.get_context_data(object=self.object)
|
||||||
context['layouted'], _ = self.layout(self.object.item_related.all(), self.object.layout.data)
|
context['layouted'], _ = self.layout(self.object.item_related.all().order_by('index'), self.object.layout.data)
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue