From adf964d0dff67283cdde9bd777e74012d2decf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Fri, 19 Aug 2016 10:46:32 +0200 Subject: [PATCH] Sorting tasks and attachments inside us and tasks correctly --- taiga/projects/attachments/utils.py | 3 ++- taiga/projects/userstories/utils.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/taiga/projects/attachments/utils.py b/taiga/projects/attachments/utils.py index 33e36c44..5103fccb 100644 --- a/taiga/projects/attachments/utils.py +++ b/taiga/projects/attachments/utils.py @@ -37,7 +37,8 @@ def attach_basic_attachments(queryset, as_field="attachments_attr"): attachments_attachment.id, attachments_attachment.attached_file FROM attachments_attachment - WHERE attachments_attachment.object_id = {tbl}.id AND attachments_attachment.content_type_id = {type_id}) t""" + WHERE attachments_attachment.object_id = {tbl}.id AND attachments_attachment.content_type_id = {type_id} + ORDER BY attachments_attachment.order, attachments_attachment.id) t""" sql = sql.format(tbl=model._meta.db_table, type_id=type.id) queryset = queryset.extra(select={as_field: sql}) diff --git a/taiga/projects/userstories/utils.py b/taiga/projects/userstories/utils.py index 87b8e094..35456b71 100644 --- a/taiga/projects/userstories/utils.py +++ b/taiga/projects/userstories/utils.py @@ -89,7 +89,10 @@ def attach_tasks(queryset, as_field="tasks_attr"): projects_taskstatus.is_closed FROM tasks_task INNER JOIN projects_taskstatus on projects_taskstatus.id = tasks_task.status_id - WHERE user_story_id = {tbl}.id) t""" + WHERE user_story_id = {tbl}.id + ORDER BY tasks_task.us_order, tasks_task.ref + ) t + """ sql = sql.format(tbl=model._meta.db_table) queryset = queryset.extra(select={as_field: sql})