mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Server-side paginatino for build orders
This commit is contained in:
parent
1239d4af16
commit
90feb6d210
@ -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
|
||||
|
||||
@ -28,6 +29,8 @@ class BuildList(generics.ListCreateAPIView):
|
||||
queryset = Build.objects.all()
|
||||
serializer_class = BuildSerializer
|
||||
|
||||
pagination_class = LimitOffsetPagination
|
||||
|
||||
filter_backends = [
|
||||
DjangoFilterBackend,
|
||||
filters.SearchFilter,
|
||||
|
@ -235,6 +235,19 @@ class PartAPITest(InvenTreeAPITestCase):
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
|
||||
def test_paginate(self):
|
||||
"""
|
||||
Test pagination of the Part list API
|
||||
"""
|
||||
|
||||
for n in [1, 5, 10]:
|
||||
response = self.get(reverse('api-part-list'), {'limit': n})
|
||||
|
||||
self.assertIn('count', response)
|
||||
self.assertIn('results', response)
|
||||
|
||||
self.assertEqual(len(response['results']), n)
|
||||
|
||||
|
||||
class PartAPIAggregationTest(InvenTreeAPITestCase):
|
||||
"""
|
||||
|
@ -244,6 +244,19 @@ class StockItemListTest(StockAPITestCase):
|
||||
response = self.get_stock(expired=0)
|
||||
self.assertEqual(len(response), 16)
|
||||
|
||||
def test_paginate(self):
|
||||
"""
|
||||
Test that we can paginate results correctly
|
||||
"""
|
||||
|
||||
for n in [1, 5, 10]:
|
||||
response = self.get_stock(limit=n)
|
||||
|
||||
self.assertIn('count', response)
|
||||
self.assertIn('results', response)
|
||||
|
||||
self.assertEqual(len(response['results']), n)
|
||||
|
||||
|
||||
class StockItemTest(StockAPITestCase):
|
||||
"""
|
||||
|
@ -630,6 +630,7 @@ function loadBuildTable(table, options) {
|
||||
url: options.url,
|
||||
queryParams: filters,
|
||||
groupBy: false,
|
||||
sidePagination: 'server',
|
||||
name: 'builds',
|
||||
original: params,
|
||||
columns: [
|
||||
|
Loading…
Reference in New Issue
Block a user