mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +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
|
||||
|
||||
name = models.CharField(max_length=100)
|
||||
URL = models.URLField(blank=True)
|
||||
website = models.URLField(blank=True)
|
||||
address = models.CharField(max_length=200,
|
||||
blank=True)
|
||||
phone = models.CharField(max_length=50,
|
||||
|
@ -4,7 +4,7 @@ from .models import Supplier, SupplierPart, Customer, Manufacturer
|
||||
|
||||
|
||||
class CompanyAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'URL', 'contact')
|
||||
list_display = ('name', 'website', 'contact')
|
||||
|
||||
|
||||
admin.site.register(Customer, CompanyAdmin)
|
||||
|
@ -3,7 +3,7 @@ from rest_framework import serializers
|
||||
from .models import Supplier, SupplierPart, SupplierPriceBreak
|
||||
|
||||
|
||||
class SupplierSerializer(serializers.ModelSerializer):
|
||||
class SupplierSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = Supplier
|
||||
@ -12,11 +12,13 @@ class SupplierSerializer(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:
|
||||
model = SupplierPart
|
||||
fields = ['pk',
|
||||
fields = ['url',
|
||||
'part',
|
||||
'supplier',
|
||||
'SKU',
|
||||
@ -32,11 +34,11 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
||||
'lead_time']
|
||||
|
||||
|
||||
class SupplierPriceBreakSerializer(serializers.ModelSerializer):
|
||||
class SupplierPriceBreakSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
class Meta:
|
||||
model = SupplierPriceBreak
|
||||
fields = ['pk',
|
||||
fields = ['url',
|
||||
'part',
|
||||
'quantity',
|
||||
'cost']
|
||||
|
@ -3,15 +3,17 @@ from django.conf.urls import url, include
|
||||
from . import views
|
||||
|
||||
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 = [
|
||||
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 = [
|
||||
@ -23,8 +25,9 @@ urlpatterns = [
|
||||
url(r'price/?', include(pricepatterns)),
|
||||
|
||||
# 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
|
||||
url(r'^\?*[^/]*/?$', views.SupplierList.as_view())
|
||||
url(r'^\?.*/?$', views.SupplierList.as_view()),
|
||||
url(r'^$', views.SupplierList.as_view())
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user