From 99dc39783c364185457b781ecea68e6f4b6aabeb Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Tue, 5 Sep 2017 03:44:15 -0400 Subject: [PATCH] Sort the list of document's cabinets. Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 +- mayan/apps/cabinets/apps.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index dbc4043f4d..bf06ce4f71 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -9,7 +9,7 @@ to Jesaja Everling (@jeverling) for the report. - Sort the list of root cabinets. Thanks to Thomas Plotkowiak for the request. - +- Sort the list of a document's cabinets. 2.7.1 (2017-09-03) ================== diff --git a/mayan/apps/cabinets/apps.py b/mayan/apps/cabinets/apps.py index 5a45775ed3..ea945817ce 100644 --- a/mayan/apps/cabinets/apps.py +++ b/mayan/apps/cabinets/apps.py @@ -48,9 +48,11 @@ class CabinetsApp(MayanAppConfig): APIEndPoint(app=self, version_string='1') + # Add explicit order_by as DocumentCabinet ordering Meta option has no + # effect. Document.add_to_class( 'document_cabinets', - lambda document: DocumentCabinet.objects.filter(documents=document) + lambda document: DocumentCabinet.objects.filter(documents=document).order_by('parent__label', 'label') ) ModelPermission.register(