parent
54bc863f5f
commit
57a8375c5c
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,43 @@
|
|||||||
|
from rest_framework import serializers
|
||||||
|
from .models import Product, Employee, Position, StorageLocation, Contractor, SupplyContract, Truck
|
||||||
|
|
||||||
|
class ProductSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Product
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class PositionSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Position
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class EmployeeSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Employee
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class StorageLocationSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = StorageLocation
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class ContractorSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Contractor
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class SupplyContractSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = SupplyContract
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
|
class TruckSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Truck
|
||||||
|
fields = '__all__'
|
@ -0,0 +1,19 @@
|
|||||||
|
from django.urls import path, include
|
||||||
|
from rest_framework.routers import DefaultRouter
|
||||||
|
from .views import (
|
||||||
|
ProductViewSet, EmployeeViewSet, PositionViewSet,
|
||||||
|
StorageLocationViewSet, ContractorViewSet, SupplyContractViewSet, TruckViewSet
|
||||||
|
)
|
||||||
|
|
||||||
|
router = DefaultRouter()
|
||||||
|
router.register(r'products', ProductViewSet)
|
||||||
|
router.register(r'employees', EmployeeViewSet)
|
||||||
|
router.register(r'positions', PositionViewSet)
|
||||||
|
router.register(r'storage-locations', StorageLocationViewSet)
|
||||||
|
router.register(r'contractors', ContractorViewSet)
|
||||||
|
router.register(r'supply-contracts', SupplyContractViewSet)
|
||||||
|
router.register(r'trucks', TruckViewSet)
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('api/', include(router.urls)),
|
||||||
|
]
|
@ -1,3 +1,40 @@
|
|||||||
from django.shortcuts import render
|
from rest_framework import viewsets
|
||||||
|
from .models import Product, Employee, Position, StorageLocation, Contractor, SupplyContract, Truck
|
||||||
|
from .serializers import (
|
||||||
|
ProductSerializer, EmployeeSerializer, PositionSerializer,
|
||||||
|
StorageLocationSerializer, ContractorSerializer, SupplyContractSerializer, TruckSerializer
|
||||||
|
)
|
||||||
|
|
||||||
# Create your views here.
|
class ProductViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Product.objects.all()
|
||||||
|
serializer_class = ProductSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class EmployeeViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Employee.objects.all()
|
||||||
|
serializer_class = EmployeeSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class PositionViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Position.objects.all()
|
||||||
|
serializer_class = PositionSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class StorageLocationViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = StorageLocation.objects.all()
|
||||||
|
serializer_class = StorageLocationSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class ContractorViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Contractor.objects.all()
|
||||||
|
serializer_class = ContractorSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class SupplyContractViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = SupplyContract.objects.all()
|
||||||
|
serializer_class = SupplyContractSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class TruckViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = Truck.objects.all()
|
||||||
|
serializer_class = TruckSerializer
|
Loading…
Reference in new issue