Skip to content

Commit

Permalink
config: add sort parameter on creation date
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
zannkukai committed Nov 5, 2020
1 parent 4aaad68 commit c449775
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions rero_ils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c449775

Please sign in to comment.