Sort currency API

This commit is contained in:
Oliver Walters 2019-09-07 19:28:20 +10:00
parent 873faee040
commit 6752bdc1c6
2 changed files with 12 additions and 2 deletions

View File

@ -5,7 +5,7 @@ Provides a JSON API for common components.
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from rest_framework import permissions, generics
from rest_framework import permissions, generics, filters
from django.conf.urls import url
@ -27,7 +27,11 @@ class CurrencyList(generics.ListCreateAPIView):
permissions.IsAuthenticated,
]
ordering_fields = ['name', 'value']
filter_backends = [
filters.OrderingFilter,
]
ordering_fields = ['suffix', 'value']
common_api_urls = [

View File

@ -15,6 +15,9 @@
$("#currency-table").bootstrapTable({
url: "{% url 'api-currency-list' %}",
queryParams: {
ordering: 'suffix'
},
sortable: true,
search: true,
formatNoMatches: function() { return "No currencies found"; },
@ -38,14 +41,17 @@
{
field: 'suffix',
title: 'Currency',
sortable: true,
},
{
field: 'description',
title: 'Description',
sortable: true,
},
{
field: 'value',
title: 'Value',
sortable: true,
}
]
});