mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Improved Part API docs
This commit is contained in:
parent
ad6038b769
commit
71d7895148
@ -3,12 +3,23 @@ from django.contrib import admin
|
|||||||
|
|
||||||
from rest_framework.documentation import include_docs_urls
|
from rest_framework.documentation import include_docs_urls
|
||||||
|
|
||||||
|
from part.urls import part_urls, part_cat_urls, part_param_urls, part_param_template_urls
|
||||||
|
|
||||||
admin.site.site_header = "InvenTree Admin"
|
admin.site.site_header = "InvenTree Admin"
|
||||||
|
|
||||||
apipatterns = [
|
apipatterns = [
|
||||||
|
|
||||||
|
# Stock URLs
|
||||||
url(r'^stock/', include('stock.urls')),
|
url(r'^stock/', include('stock.urls')),
|
||||||
url(r'^stock-location/', include('stock.location_urls')),
|
url(r'^stock-location/', include('stock.location_urls')),
|
||||||
url(r'^part/', include('part.urls')),
|
|
||||||
|
# Part URLs
|
||||||
|
url(r'^part/', include(part_urls)),
|
||||||
|
url(r'^part-category/', include(part_cat_urls)),
|
||||||
|
url(r'^part-param/', include(part_param_urls)),
|
||||||
|
url(r'^part-param-template/', include(part_param_template_urls)),
|
||||||
|
|
||||||
|
# Supplier URLs
|
||||||
url(r'^supplier/', include('supplier.urls')),
|
url(r'^supplier/', include('supplier.urls')),
|
||||||
url(r'^supplier-part/', include('supplier.part_urls')),
|
url(r'^supplier-part/', include('supplier.part_urls')),
|
||||||
url(r'^price-break/', include('supplier.price_urls')),
|
url(r'^price-break/', include('supplier.price_urls')),
|
||||||
|
@ -2,12 +2,7 @@ from django.conf.urls import url, include
|
|||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
""" URL patterns associated with part categories:
|
part_cat_urls = [
|
||||||
/category -> List all top-level categories
|
|
||||||
/category/<pk> -> Detail view of given category
|
|
||||||
/category/new -> Create a new category
|
|
||||||
"""
|
|
||||||
categorypatterns = [
|
|
||||||
|
|
||||||
# Part category detail
|
# Part category detail
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.PartCategoryDetail.as_view(), name='partcategory-detail'),
|
url(r'^(?P<pk>[0-9]+)/?$', views.PartCategoryDetail.as_view(), name='partcategory-detail'),
|
||||||
@ -17,7 +12,7 @@ categorypatterns = [
|
|||||||
url(r'^$', views.PartCategoryList.as_view())
|
url(r'^$', views.PartCategoryList.as_view())
|
||||||
]
|
]
|
||||||
|
|
||||||
partparampatterns = [
|
part_param_urls = [
|
||||||
# Detail of a single part parameter
|
# Detail of a single part parameter
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.PartParamDetail.as_view(), name='partparameter-detail'),
|
url(r'^(?P<pk>[0-9]+)/?$', views.PartParamDetail.as_view(), name='partparameter-detail'),
|
||||||
|
|
||||||
@ -26,7 +21,7 @@ partparampatterns = [
|
|||||||
url(r'^$', views.PartParamList.as_view()),
|
url(r'^$', views.PartParamList.as_view()),
|
||||||
]
|
]
|
||||||
|
|
||||||
parttemplatepatterns = [
|
part_param_template_urls = [
|
||||||
# Detail of a single part field template
|
# Detail of a single part field template
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.PartTemplateDetail.as_view(), name='partparametertemplate-detail'),
|
url(r'^(?P<pk>[0-9]+)/?$', views.PartTemplateDetail.as_view(), name='partparametertemplate-detail'),
|
||||||
|
|
||||||
@ -35,21 +30,7 @@ parttemplatepatterns = [
|
|||||||
url(r'^$', views.PartTemplateList.as_view())
|
url(r'^$', views.PartTemplateList.as_view())
|
||||||
]
|
]
|
||||||
|
|
||||||
""" Top-level URL patterns for the Part app:
|
part_urls = [
|
||||||
/part/ -> List all parts
|
|
||||||
/part/new -> Create a new part
|
|
||||||
/part/<pk> -> (refer to partdetailpatterns)
|
|
||||||
/part/category -> (refer to categorypatterns)
|
|
||||||
"""
|
|
||||||
urlpatterns = [
|
|
||||||
# Part categories
|
|
||||||
url(r'^category/', include(categorypatterns)),
|
|
||||||
|
|
||||||
# Part parameters
|
|
||||||
url(r'^parameter/', include(partparampatterns)),
|
|
||||||
|
|
||||||
# Part templates
|
|
||||||
url(r'^template/', include(parttemplatepatterns)),
|
|
||||||
|
|
||||||
# Individual part
|
# Individual part
|
||||||
url(r'^(?P<pk>[0-9]+)/?$', views.PartDetail.as_view(), name='part-detail'),
|
url(r'^(?P<pk>[0-9]+)/?$', views.PartDetail.as_view(), name='part-detail'),
|
||||||
|
@ -11,7 +11,17 @@ from .serializers import PartTemplateSerializer
|
|||||||
|
|
||||||
|
|
||||||
class PartDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PartDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
""" Return information on a single part
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
Return detail on a single Part
|
||||||
|
|
||||||
|
post:
|
||||||
|
Update data for a single Part
|
||||||
|
|
||||||
|
delete:
|
||||||
|
Remove a part from the database
|
||||||
|
|
||||||
"""
|
"""
|
||||||
queryset = Part.objects.all()
|
queryset = Part.objects.all()
|
||||||
serializer_class = PartSerializer
|
serializer_class = PartSerializer
|
||||||
@ -19,7 +29,13 @@ class PartDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartParamList(generics.ListCreateAPIView):
|
class PartParamList(generics.ListCreateAPIView):
|
||||||
""" Return all parameters associated with a particular part
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
Return a list of all part parameters (with optional filters)
|
||||||
|
|
||||||
|
post:
|
||||||
|
Create a new part parameter
|
||||||
"""
|
"""
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
part_id = self.request.query_params.get('part', None)
|
part_id = self.request.query_params.get('part', None)
|
||||||
@ -34,7 +50,17 @@ class PartParamList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartParamDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PartParamDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
""" Detail view of a single PartParameter
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
Detail view of a single PartParameter
|
||||||
|
|
||||||
|
post:
|
||||||
|
Update data for a PartParameter
|
||||||
|
|
||||||
|
delete:
|
||||||
|
Remove a PartParameter from the database
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
queryset = PartParameter.objects.all()
|
queryset = PartParameter.objects.all()
|
||||||
@ -54,7 +80,13 @@ class PartFilter(django_filters.rest_framework.FilterSet):
|
|||||||
|
|
||||||
|
|
||||||
class PartList(generics.ListCreateAPIView):
|
class PartList(generics.ListCreateAPIView):
|
||||||
""" List of parts, with optional filters
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
List of Parts, with optional filters
|
||||||
|
|
||||||
|
post:
|
||||||
|
Create a new Part
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@ -73,7 +105,17 @@ class PartList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartCategoryDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PartCategoryDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
""" Return information on a single PartCategory
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
Return information on a single PartCategory
|
||||||
|
|
||||||
|
post:
|
||||||
|
Update a PartCategory
|
||||||
|
|
||||||
|
delete:
|
||||||
|
Remove a PartCategory
|
||||||
|
|
||||||
"""
|
"""
|
||||||
queryset = PartCategory.objects.all()
|
queryset = PartCategory.objects.all()
|
||||||
serializer_class = PartCategorySerializer
|
serializer_class = PartCategorySerializer
|
||||||
@ -81,8 +123,14 @@ class PartCategoryDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartCategoryList(generics.ListCreateAPIView):
|
class PartCategoryList(generics.ListCreateAPIView):
|
||||||
""" Return a list of all top-level part categories.
|
"""
|
||||||
Categories are considered "top-level" if they do not have a parent
|
|
||||||
|
get:
|
||||||
|
Return a list of all categories
|
||||||
|
(with optional filters)
|
||||||
|
|
||||||
|
post:
|
||||||
|
Create a new PartCategory
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
@ -100,6 +148,18 @@ class PartCategoryList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartTemplateDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PartTemplateDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
Return detail on a single PartParameterTemplate object
|
||||||
|
|
||||||
|
post:
|
||||||
|
Update a PartParameterTemplate object
|
||||||
|
|
||||||
|
delete:
|
||||||
|
Remove a PartParameterTemplate object
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
queryset = PartParameterTemplate.objects.all()
|
queryset = PartParameterTemplate.objects.all()
|
||||||
serializer_class = PartTemplateSerializer
|
serializer_class = PartTemplateSerializer
|
||||||
@ -107,6 +167,16 @@ class PartTemplateDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
|
|
||||||
class PartTemplateList(generics.ListCreateAPIView):
|
class PartTemplateList(generics.ListCreateAPIView):
|
||||||
|
"""
|
||||||
|
|
||||||
|
get:
|
||||||
|
Return a list of all PartParameterTemplate objects
|
||||||
|
(with optional query filters)
|
||||||
|
|
||||||
|
post:
|
||||||
|
Create a new PartParameterTemplate object
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
queryset = PartParameterTemplate.objects.all()
|
queryset = PartParameterTemplate.objects.all()
|
||||||
serializer_class = PartTemplateSerializer
|
serializer_class = PartTemplateSerializer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user