From f3c71bd96f0de690be83a46de15ad2d693f6e9e6 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 16 May 2020 20:56:36 +1000 Subject: [PATCH] API interface for StockItemTestResult --- InvenTree/stock/api.py | 34 ++++++++++++++++++++++++++++++++++ InvenTree/stock/serializers.py | 1 + 2 files changed, 35 insertions(+) diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index 1c654d8b3c..f0fb8a5d7a 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -15,6 +15,7 @@ from django.db.models import Q from .models import StockLocation, StockItem from .models import StockItemTracking from .models import StockItemAttachment +from .models import StockItemTestResult from part.models import Part, PartCategory from part.serializers import PartBriefSerializer @@ -26,6 +27,7 @@ from .serializers import StockItemSerializer from .serializers import LocationSerializer, LocationBriefSerializer from .serializers import StockTrackingSerializer from .serializers import StockItemAttachmentSerializer +from .serializers import StockItemTestResultSerializer from InvenTree.views import TreeSerializer from InvenTree.helpers import str2bool, isNull @@ -659,6 +661,33 @@ class StockAttachmentList(generics.ListCreateAPIView, AttachmentMixin): ] +class StockItemTestResultList(generics.ListCreateAPIView): + """ + API endpoint for listing (and creating) a StockItemTestResult object. + """ + + queryset = StockItemTestResult.objects.all() + serializer_class = StockItemTestResultSerializer + + permission_classes = [ + permissions.IsAuthenticated, + ] + + filter_backends = [ + DjangoFilterBackend, + filters.SearchFilter, + filters.OrderingFilter, + ] + + filter_fields = [ + 'stock_item', + 'test', + 'user', + 'result', + 'value', + ] + + class StockTrackingList(generics.ListCreateAPIView): """ API endpoint for list view of StockItemTracking objects. @@ -769,6 +798,11 @@ stock_api_urls = [ url(r'^$', StockAttachmentList.as_view(), name='api-stock-attachment-list'), ])), + # Base URL for StockItemTestResult API endpoints + url(r'^test/', include([ + url(r'^$', StockItemTestResultList.as_view(), name='api-stock-test-result-list'), + ])), + url(r'track/?', StockTrackingList.as_view(), name='api-stock-track'), url(r'^tree/?', StockCategoryTree.as_view(), name='api-stock-tree'), diff --git a/InvenTree/stock/serializers.py b/InvenTree/stock/serializers.py index ad53da200d..8459aefd2a 100644 --- a/InvenTree/stock/serializers.py +++ b/InvenTree/stock/serializers.py @@ -225,6 +225,7 @@ class StockItemTestResultSerializer(InvenTreeModelSerializer): fields = [ 'pk', + 'stock_item', 'test', 'result', 'value',