Fixing API attachments order and deprecated

remotes/origin/issue/4795/notification_even_they_are_disabled
Alejandro Alonso 2016-11-16 09:45:39 +01:00 committed by David Barragán Merino
parent d44d666a66
commit d21b4193ce
1 changed files with 4 additions and 2 deletions

View File

@ -37,8 +37,10 @@ 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} WHERE attachments_attachment.object_id = {tbl}.id
ORDER BY attachments_attachment.order, attachments_attachment.id) t""" AND attachments_attachment.content_type_id = {type_id}
AND attachments_attachment.is_deprecated = False
ORDER BY attachments_attachment.order, attachments_attachment.created_date, 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})