From aa0f72539e63d9103fe138180d81d3e99f4898af Mon Sep 17 00:00:00 2001 From: David Vogt Date: Mon, 27 Apr 2020 17:28:06 +0200 Subject: [PATCH] fix(structure): return table rows in sorted fashion This is not strictly required for the structure module's purpose, but some tests may depend on evaluation order, so we sort it explicitly. --- caluma/caluma_form/structure.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/caluma/caluma_form/structure.py b/caluma/caluma_form/structure.py index f63bb2710..d1f0312f7 100644 --- a/caluma/caluma_form/structure.py +++ b/caluma/caluma_form/structure.py @@ -3,7 +3,7 @@ from functools import singledispatch from typing import Optional -from .models import Question +from .models import AnswerDocument, Question def object_local_memoise(method): @@ -112,14 +112,15 @@ def children(self): if not self.answer: return [] # pragma: no cover + rows = AnswerDocument.objects.filter(answer=self.answer).order_by("sort") return [ FieldSet( - row_doc, + ans_doc.document, self.question.row_form, question=self.question, parent=self.parent(), ) - for row_doc in self.answer.documents.all() + for ans_doc in rows ]