Skip to content

Commit

Permalink
Inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamgilbert committed Jul 18, 2017
1 parent ddb5599 commit 8482ddb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
8 changes: 6 additions & 2 deletions api/serializers.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
url(r'^machines/(?P<serial>.+)/full/$', views.MachineFullDetail.as_view()),
url(r'^machines/(?P<serial>.+)/$', views.MachineDetail.as_view()),
url(r'^machines/$', views.MachineList.as_view()),
url(r'^inventory/$', views.AllInventory.as_view()),
url(r'^facts/(?P<serial>.+)/$', views.FactsMachine.as_view()),
url(r'^facts/$', views.Facts.as_view()),
url(r'^conditions/(?P<serial>.+)/$', views.ConditionsMachine.as_view()),
Expand Down
9 changes: 9 additions & 0 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion sal/version.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>version</key>
<string>3.2.1.950</string>
<string>3.2.1.952</string>
</dict>
</plist>

0 comments on commit 8482ddb

Please sign in to comment.