mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-07 07:48:50 +00:00
Supplier API is hyperlinked
This commit is contained in:
parent
41eb427c02
commit
f85489bc0e
@ -12,7 +12,7 @@ class Company(models.Model):
|
|||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
URL = models.URLField(blank=True)
|
website = models.URLField(blank=True)
|
||||||
address = models.CharField(max_length=200,
|
address = models.CharField(max_length=200,
|
||||||
blank=True)
|
blank=True)
|
||||||
phone = models.CharField(max_length=50,
|
phone = models.CharField(max_length=50,
|
||||||
|
@ -4,7 +4,7 @@ from .models import Supplier, SupplierPart, Customer, Manufacturer
|
|||||||
|
|
||||||
|
|
||||||
class CompanyAdmin(admin.ModelAdmin):
|
class CompanyAdmin(admin.ModelAdmin):
|
||||||
list_display = ('name', 'URL', 'contact')
|
list_display = ('name', 'website', 'contact')
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Customer, CompanyAdmin)
|
admin.site.register(Customer, CompanyAdmin)
|
||||||
|
@ -3,7 +3,7 @@ from rest_framework import serializers
|
|||||||
from .models import Supplier, SupplierPart, SupplierPriceBreak
|
from .models import Supplier, SupplierPart, SupplierPriceBreak
|
||||||
|
|
||||||
|
|
||||||
class SupplierSerializer(serializers.ModelSerializer):
|
class SupplierSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Supplier
|
model = Supplier
|
||||||
@ -12,11 +12,13 @@ class SupplierSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class SupplierPartSerializer(serializers.ModelSerializer):
|
class SupplierPartSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
price_breaks = serializers.PrimaryKeyRelatedField(many=True, read_only=True)
|
price_breaks = serializers.HyperlinkedRelatedField(many=True,
|
||||||
|
read_only=True,
|
||||||
|
view_name='price_break-detail')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPart
|
model = SupplierPart
|
||||||
fields = ['pk',
|
fields = ['url',
|
||||||
'part',
|
'part',
|
||||||
'supplier',
|
'supplier',
|
||||||
'SKU',
|
'SKU',
|
||||||
@ -32,11 +34,11 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
|||||||
'lead_time']
|
'lead_time']
|
||||||
|
|
||||||
|
|
||||||
class SupplierPriceBreakSerializer(serializers.ModelSerializer):
|
class SupplierPriceBreakSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SupplierPriceBreak
|
model = SupplierPriceBreak
|
||||||
fields = ['pk',
|
fields = ['url',
|
||||||
'part',
|
'part',
|
||||||
'quantity',
|
'quantity',
|
||||||
'cost']
|
'cost']
|
||||||
|
@ -3,15 +3,17 @@ from django.conf.urls import url, include
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
partpatterns = [
|
partpatterns = [
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPartDetail.as_view()),
|
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPartDetail.as_view(), name='supplier-part-detail'),
|
||||||
|
|
||||||
url(r'^\?*[^/]*/?$', views.SupplierPartList.as_view())
|
url(r'^\?.*/?$', views.SupplierPartList.as_view()),
|
||||||
|
url(r'^$', views.SupplierPartList.as_view())
|
||||||
]
|
]
|
||||||
|
|
||||||
pricepatterns = [
|
pricepatterns = [
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPriceBreakDetail.as_view()),
|
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierPriceBreakDetail.as_view(), name='price-break-detail'),
|
||||||
|
|
||||||
url(r'^\?*[^/]*/?$', views.SupplierPriceBreakList.as_view())
|
url(r'^\?.*/?$', views.SupplierPriceBreakList.as_view()),
|
||||||
|
url(r'^$', views.SupplierPriceBreakList.as_view())
|
||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -23,8 +25,9 @@ urlpatterns = [
|
|||||||
url(r'price/?', include(pricepatterns)),
|
url(r'price/?', include(pricepatterns)),
|
||||||
|
|
||||||
# Display details of a supplier
|
# Display details of a supplier
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierDetail.as_view()),
|
url(r'^(?P<pk>[0-9]+)/?$', views.SupplierDetail.as_view(), name='supplier-detail'),
|
||||||
|
|
||||||
# List suppliers
|
# List suppliers
|
||||||
url(r'^\?*[^/]*/?$', views.SupplierList.as_view())
|
url(r'^\?.*/?$', views.SupplierList.as_view()),
|
||||||
|
url(r'^$', views.SupplierList.as_view())
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user