From 8482ddb684e712a718cd00d07a4661ea73abb2b3 Mon Sep 17 00:00:00 2001 From: Graham Gilbert Date: Tue, 18 Jul 2017 13:01:29 -0700 Subject: [PATCH] Inventory --- api/serializers.py | 8 ++++++-- api/urls.py | 1 + api/views.py | 9 +++++++++ sal/version.plist | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/api/serializers.py b/api/serializers.py index 3eaff94d..86db86cf 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -1,12 +1,16 @@ from django.forms import widgets from rest_framework import serializers -from inventory.models import InventoryItem +from inventory.models import InventoryItem, Application from server.models import * +class InventoryApplicationSerializer(serializers.ModelSerializer): + class Meta: + model = Application + class InventoryItemSerializer(serializers.ModelSerializer): + application = InventoryApplicationSerializer() class Meta: model = InventoryItem - # exclude = ('machine',) class BusinessUnitSerializer(serializers.ModelSerializer): class Meta: diff --git a/api/urls.py b/api/urls.py index f33b7b45..db82312b 100644 --- a/api/urls.py +++ b/api/urls.py @@ -7,6 +7,7 @@ url(r'^machines/(?P.+)/full/$', views.MachineFullDetail.as_view()), url(r'^machines/(?P.+)/$', views.MachineDetail.as_view()), url(r'^machines/$', views.MachineList.as_view()), + url(r'^inventory/$', views.AllInventory.as_view()), url(r'^facts/(?P.+)/$', views.FactsMachine.as_view()), url(r'^facts/$', views.Facts.as_view()), url(r'^conditions/(?P.+)/$', views.ConditionsMachine.as_view()), diff --git a/api/views.py b/api/views.py index 8036b99c..9be833b0 100644 --- a/api/views.py +++ b/api/views.py @@ -58,6 +58,15 @@ def get_queryset(self): serial = self.kwargs['serial'] return Machine.objects.get(serial=serial).inventoryitem_set.all() +class AllInventory(generics.ListAPIView): + """ + Retrieve all the inventory items + """ + authentication_classes = (ApiKeyAuthentication,) + permission_classes = (HasRWPermission,) + serializer_class = InventoryItemSerializer + queryset = InventoryItem.objects.all() + class PendingAppleUpdates(generics.ListAPIView): """ Retrieve pending apple updates for a machine. diff --git a/sal/version.plist b/sal/version.plist index e2623825..6633cbc2 100644 --- a/sal/version.plist +++ b/sal/version.plist @@ -3,6 +3,6 @@ version - 3.2.1.950 + 3.2.1.952