mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Supplier API now hyperlinked
This commit is contained in:
parent
f85489bc0e
commit
e641a913f2
@ -7,24 +7,14 @@ from rest_framework.decorators import api_view
|
||||
|
||||
admin.site.site_header = "InvenTree Admin"
|
||||
|
||||
|
||||
@api_view()
|
||||
def Inventree404(self):
|
||||
""" Supplied URL is invalid
|
||||
"""
|
||||
content = {'detail': 'Malformed API URL'}
|
||||
return Response(content, status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
||||
apipatterns = [
|
||||
url(r'^stock/', include('stock.urls')),
|
||||
url(r'^part/', include('part.urls')),
|
||||
url(r'^supplier/', include('supplier.urls')),
|
||||
url(r'^manufacturer/', include('supplier.manufacturer_urls')),
|
||||
url(r'^customer/', include('supplier.customer_urls')),
|
||||
url(r'^track/', include('track.urls')),
|
||||
url(r'^project/', include('project.urls')),
|
||||
|
||||
# Any other URL
|
||||
url(r'', Inventree404)
|
||||
]
|
||||
|
||||
urlpatterns = [
|
||||
|
12
InvenTree/supplier/customer_urls.py
Normal file
12
InvenTree/supplier/customer_urls.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
# Customer detail
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.CustomerDetail.as_view(), name='customer-detail'),
|
||||
|
||||
# List customers
|
||||
url(r'^\?.*/?$', views.CustomerList.as_view()),
|
||||
url(r'^$', views.CustomerList.as_view())
|
||||
]
|
12
InvenTree/supplier/manufacturer_urls.py
Normal file
12
InvenTree/supplier/manufacturer_urls.py
Normal file
@ -0,0 +1,12 @@
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
# Manufacturer detail
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.ManufacturerDetail.as_view(), name='manufacturer-detail'),
|
||||
|
||||
# List manufacturers
|
||||
url(r'^\?.*/?$', views.ManufacturerList.as_view()),
|
||||
url(r'^$', views.ManufacturerList.as_view())
|
||||
]
|
@ -1,6 +1,10 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from part.models import Part
|
||||
|
||||
from .models import Supplier, SupplierPart, SupplierPriceBreak
|
||||
from .models import Manufacturer
|
||||
from .models import Customer
|
||||
|
||||
|
||||
class SupplierSerializer(serializers.HyperlinkedModelSerializer):
|
||||
@ -10,14 +14,38 @@ class SupplierSerializer(serializers.HyperlinkedModelSerializer):
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class ManufacturerSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Manufacturer
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class CustomerSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Customer
|
||||
fields = '__all__'
|
||||
|
||||
|
||||
class SupplierPartSerializer(serializers.ModelSerializer):
|
||||
|
||||
price_breaks = serializers.HyperlinkedRelatedField(many=True,
|
||||
read_only=True,
|
||||
view_name='price_break-detail')
|
||||
view_name='supplierpricebreak-detail')
|
||||
|
||||
part = serializers.HyperlinkedRelatedField(view_name='part-detail',
|
||||
queryset = Part.objects.all())
|
||||
|
||||
supplier = serializers.HyperlinkedRelatedField(view_name='supplier-detail',
|
||||
queryset = Supplier.objects.all())
|
||||
|
||||
manufacturer = serializers.HyperlinkedRelatedField(view_name='manufacturer-detail',
|
||||
queryset = Manufacturer.objects.all())
|
||||
|
||||
class Meta:
|
||||
model = SupplierPart
|
||||
#extra_kwargs = {'url': {'view_name': 'supplier-part-detail'}}
|
||||
fields = ['url',
|
||||
'part',
|
||||
'supplier',
|
||||
|
@ -3,14 +3,14 @@ from django.conf.urls import url, include
|
||||
from . import views
|
||||
|
||||
partpatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPartDetail.as_view(), name='supplier-part-detail'),
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPartDetail.as_view(), name='supplierpart-detail'),
|
||||
|
||||
url(r'^\?.*/?$', views.SupplierPartList.as_view()),
|
||||
url(r'^$', views.SupplierPartList.as_view())
|
||||
]
|
||||
|
||||
pricepatterns = [
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPriceBreakDetail.as_view(), name='price-break-detail'),
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPriceBreakDetail.as_view(), name='supplierpricebreak-detail'),
|
||||
|
||||
url(r'^\?.*/?$', views.SupplierPriceBreakList.as_view()),
|
||||
url(r'^$', views.SupplierPriceBreakList.as_view())
|
||||
@ -19,13 +19,13 @@ pricepatterns = [
|
||||
urlpatterns = [
|
||||
|
||||
# Supplier part information
|
||||
url(r'part/?', include(partpatterns)),
|
||||
url(r'part/', include(partpatterns)),
|
||||
|
||||
# Supplier price information
|
||||
url(r'price/?', include(pricepatterns)),
|
||||
url(r'price/', include(pricepatterns)),
|
||||
|
||||
# Display details of a supplier
|
||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierDetail.as_view(), name='supplier-detail'),
|
||||
url(r'^(?P<pk>[0-9]+)/$', views.SupplierDetail.as_view(), name='supplier-detail'),
|
||||
|
||||
# List suppliers
|
||||
url(r'^\?.*/?$', views.SupplierList.as_view()),
|
||||
|
@ -1,9 +1,40 @@
|
||||
from rest_framework import generics, permissions
|
||||
|
||||
from .models import Supplier, SupplierPart, SupplierPriceBreak
|
||||
from .models import Manufacturer, Customer
|
||||
from .serializers import SupplierSerializer
|
||||
from .serializers import SupplierPartSerializer
|
||||
from .serializers import SupplierPriceBreakSerializer
|
||||
from .serializers import ManufacturerSerializer
|
||||
from .serializers import CustomerSerializer
|
||||
|
||||
|
||||
class ManufacturerDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
queryset = Manufacturer.objects.all()
|
||||
serializer_class = ManufacturerSerializer
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
|
||||
class ManufacturerList(generics.ListCreateAPIView):
|
||||
|
||||
queryset = Manufacturer.objects.all()
|
||||
serializer_class = ManufacturerSerializer
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
|
||||
class CustomerDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
queryset = Customer.objects.all()
|
||||
serializer_class = CustomerSerializer
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
|
||||
class CustomerList(generics.ListCreateAPIView):
|
||||
|
||||
queryset = Customer.objects.all()
|
||||
serializer_class = CustomerSerializer
|
||||
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
|
||||
|
||||
|
||||
class SupplierDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
Loading…
Reference in New Issue
Block a user