Sorting tasks and attachments inside us and tasks correctly

remotes/origin/issue/4795/notification_even_they_are_disabled
Jesús Espino 2016-08-19 10:46:32 +02:00 committed by David Barragán Merino
parent b2a55d84f1
commit adf964d0df
2 changed files with 6 additions and 2 deletions

View File

@ -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})

View File

@ -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})