43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
|
from django.shortcuts import render
|
||
|
from rest_framework import viewsets
|
||
|
from rest_framework import permissions
|
||
|
from api.serializers import ContainerSerializer, ContainerTypeSerializer, AssetSerializer, GtinProductSerializer
|
||
|
from container.models import Container, ContainerType
|
||
|
from asset.models import Asset, GtinProduct
|
||
|
|
||
|
|
||
|
class ContainerViewSet(viewsets.ModelViewSet):
|
||
|
"""
|
||
|
API endpoint that allows containers to be viewed or edited.
|
||
|
"""
|
||
|
queryset = Container.objects.all().order_by('named_id')
|
||
|
serializer_class = ContainerSerializer
|
||
|
permission_classes = [permissions.IsAuthenticated]
|
||
|
|
||
|
|
||
|
class ContainerTypeViewSet(viewsets.ModelViewSet):
|
||
|
"""
|
||
|
API endpoint that allows container-types to be viewed or edited.
|
||
|
"""
|
||
|
queryset = ContainerType.objects.all()
|
||
|
serializer_class = ContainerTypeSerializer
|
||
|
permission_classes = [permissions.IsAuthenticated]
|
||
|
|
||
|
|
||
|
class AssetViewSet(viewsets.ModelViewSet):
|
||
|
"""
|
||
|
API endpoint that allows containers to be viewed or edited.
|
||
|
"""
|
||
|
queryset = Asset.objects.all().order_by('named_id')
|
||
|
serializer_class = AssetSerializer
|
||
|
permission_classes = [permissions.IsAuthenticated]
|
||
|
|
||
|
|
||
|
class GtinProductViewSet(viewsets.ModelViewSet):
|
||
|
"""
|
||
|
API endpoint that allows containers to be viewed or edited.
|
||
|
"""
|
||
|
queryset = GtinProduct.objects.all().order_by('gtin')
|
||
|
serializer_class = GtinProductSerializer
|
||
|
permission_classes = [permissions.IsAuthenticated]
|