From 44635d2499304204548fafb4fb310ba5a5758299 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sun, 28 Feb 2021 20:35:32 +1100 Subject: [PATCH] Use server-side pagination for more list endpoints --- InvenTree/company/api.py | 2 ++ InvenTree/company/templates/company/index.html | 2 +- InvenTree/order/api.py | 3 +++ InvenTree/templates/js/company.js | 1 + InvenTree/templates/js/order.js | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/InvenTree/company/api.py b/InvenTree/company/api.py index 3398760d45..27d67bdfed 100644 --- a/InvenTree/company/api.py +++ b/InvenTree/company/api.py @@ -8,6 +8,7 @@ from __future__ import unicode_literals from django_filters.rest_framework import DjangoFilterBackend from rest_framework import filters from rest_framework import generics +from rest_framework.pagination import LimitOffsetPagination from django.conf.urls import url, include from django.db.models import Q @@ -32,6 +33,7 @@ class CompanyList(generics.ListCreateAPIView): serializer_class = CompanySerializer queryset = Company.objects.all() + pagination_class = LimitOffsetPagination def get_queryset(self): diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index ae3e191bc1..ca2fa619d9 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -22,7 +22,7 @@ InvenTree | {% trans "Supplier List" %} {% endif %} - +
{% endblock %} diff --git a/InvenTree/order/api.py b/InvenTree/order/api.py index ce75a47697..0d3755384b 100644 --- a/InvenTree/order/api.py +++ b/InvenTree/order/api.py @@ -8,6 +8,7 @@ from __future__ import unicode_literals from django_filters.rest_framework import DjangoFilterBackend from rest_framework import generics from rest_framework import filters +from rest_framework.pagination import LimitOffsetPagination from django.conf.urls import url, include @@ -36,6 +37,7 @@ class POList(generics.ListCreateAPIView): queryset = PurchaseOrder.objects.all() serializer_class = POSerializer + pagination_class = LimitOffsetPagination def get_serializer(self, *args, **kwargs): @@ -238,6 +240,7 @@ class SOList(generics.ListCreateAPIView): queryset = SalesOrder.objects.all() serializer_class = SalesOrderSerializer + pagination_class = LimitOffsetPagination def get_serializer(self, *args, **kwargs): diff --git a/InvenTree/templates/js/company.js b/InvenTree/templates/js/company.js index 388a79668b..b497609db1 100644 --- a/InvenTree/templates/js/company.js +++ b/InvenTree/templates/js/company.js @@ -93,6 +93,7 @@ function loadCompanyTable(table, url, options={}) { method: 'get', queryParams: filters, groupBy: false, + sidePagination: 'server', formatNoMatches: function() { return "{% trans "No company information found" %}"; }, showColumns: true, name: options.pagetype || 'company', diff --git a/InvenTree/templates/js/order.js b/InvenTree/templates/js/order.js index 53063cd709..c4ca4acd08 100644 --- a/InvenTree/templates/js/order.js +++ b/InvenTree/templates/js/order.js @@ -131,6 +131,7 @@ function loadPurchaseOrderTable(table, options) { queryParams: filters, name: 'purchaseorder', groupBy: false, + sidePagination: 'server', original: options.params, formatNoMatches: function() { return '{% trans "No purchase orders found" %}'; }, columns: [ @@ -225,6 +226,7 @@ function loadSalesOrderTable(table, options) { queryParams: filters, name: 'salesorder', groupBy: false, + sidePagination: 'server', original: options.params, formatNoMatches: function() { return '{% trans "No sales orders found" %}'; }, columns: [