From c4497757ca92f8eb868410ca26984a05e8520c1d Mon Sep 17 00:00:00 2001 From: Renaud Michotte Date: Thu, 8 Oct 2020 20:44:58 +0200 Subject: [PATCH] config: add sort parameter on creation date * Adds a new option to sort API response by the resource creation date. This option is available for all resource. * Corrects the loan sort options. Co-Authored-by: Renaud Michotte --- rero_ils/config.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/rero_ils/config.py b/rero_ils/config.py index bed1aebead..a9174940aa 100644 --- a/rero_ils/config.py +++ b/rero_ils/config.py @@ -1813,6 +1813,10 @@ def _(x): fields=['-_updated'], title='Last updated', default_order='desc', order=3 ), + created=dict( + fields=['_created'], title='Most recent', default_order='asc', + order=4 + ), ) RECORDS_REST_DEFAULT_SORT[index] = dict( query='bestmatch', noquery='mostrecent') @@ -1859,12 +1863,16 @@ def _(x): query='bestmatch', noquery='name') # ------ LOANS SORT -RECORDS_REST_SORT_OPTIONS['loans'] = dict( - transactiondate=dict( - fields=['-transaction_date'], title='Transaction date', - default_order='asc' - ) +RECORDS_REST_SORT_OPTIONS['loans']['transactiondate'] = dict( + fields=['-transaction_date'], title='Transaction date', + default_order='desc' +) +RECORDS_REST_SORT_OPTIONS['loans']['duedate'] = dict( + fields=['end_date'], title='Due date', + default_order='asc' ) +RECORDS_REST_DEFAULT_SORT['loans'] = dict( + query='bestmatch', noquery='transactiondate') # ------ LOCATIONS SORT RECORDS_REST_SORT_OPTIONS['locations']['name'] = dict(