Merge pull request #811 from taigaio/sorting-correctly-tasks-and-attachment

Sorting tasks and attachments inside us and tasks correctly
remotes/origin/issue/4795/notification_even_they_are_disabled
David Barragán Merino 2016-08-21 10:35:33 +02:00 committed by GitHub
commit 48d88cf987
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.id,
attachments_attachment.attached_file attachments_attachment.attached_file
FROM attachments_attachment 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) sql = sql.format(tbl=model._meta.db_table, type_id=type.id)
queryset = queryset.extra(select={as_field: sql}) 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 projects_taskstatus.is_closed
FROM tasks_task FROM tasks_task
INNER JOIN projects_taskstatus on projects_taskstatus.id = tasks_task.status_id 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) sql = sql.format(tbl=model._meta.db_table)
queryset = queryset.extra(select={as_field: sql}) queryset = queryset.extra(select={as_field: sql})