mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
API endpoint for PartParameter and PartParameterTemplate
This commit is contained in:
parent
13270617b9
commit
f415e2040e
@ -21,10 +21,12 @@ from django.urls import reverse
|
||||
import os
|
||||
|
||||
from .models import Part, PartCategory, BomItem, PartStar
|
||||
from .models import PartParameter, PartParameterTemplate
|
||||
|
||||
from .serializers import PartSerializer, BomItemSerializer
|
||||
from .serializers import CategorySerializer
|
||||
from .serializers import PartStarSerializer
|
||||
from .serializers import PartParameterSerializer, PartParameterTemplateSerializer
|
||||
|
||||
from InvenTree.views import TreeSerializer
|
||||
from InvenTree.helpers import str2bool
|
||||
@ -261,6 +263,53 @@ class PartStarList(generics.ListCreateAPIView):
|
||||
]
|
||||
|
||||
|
||||
class PartParameterTemplateList(generics.ListCreateAPIView):
|
||||
""" API endpoint for accessing a list of PartParameterTemplate objects.
|
||||
|
||||
- GET: Return list of PartParameterTemplate objects
|
||||
- POST: Create a new PartParameterTemplate object
|
||||
"""
|
||||
|
||||
queryset = PartParameterTemplate.objects.all()
|
||||
serializer_class = PartParameterTemplateSerializer
|
||||
|
||||
permission_classes = [
|
||||
permissions.IsAuthenticated,
|
||||
]
|
||||
|
||||
filter_backends = [
|
||||
filters.OrderingFilter,
|
||||
]
|
||||
|
||||
filter_fields = [
|
||||
'name',
|
||||
]
|
||||
|
||||
|
||||
class PartParameterList(generics.ListCreateAPIView):
|
||||
""" API endpoint for accessing a list of PartParameter objects
|
||||
|
||||
- GET: Return list of PartParameter objects
|
||||
- POST: Create a new PartParameter object
|
||||
"""
|
||||
|
||||
queryset = PartParameter.objects.all()
|
||||
serializer_class = PartParameterSerializer
|
||||
|
||||
permission_classes = [
|
||||
permissions.IsAuthenticated,
|
||||
]
|
||||
|
||||
filter_backends = [
|
||||
DjangoFilterBackend
|
||||
]
|
||||
|
||||
filter_fields = [
|
||||
'part',
|
||||
'template',
|
||||
]
|
||||
|
||||
|
||||
class BomList(generics.ListCreateAPIView):
|
||||
""" API endpoint for accessing a list of BomItem objects.
|
||||
|
||||
@ -362,12 +411,18 @@ part_star_api_urls = [
|
||||
url(r'^.*$', PartStarList.as_view(), name='api-part-star-list'),
|
||||
]
|
||||
|
||||
part_param_api_urls = [
|
||||
url(r'^template/?$', PartParameterTemplateList.as_view(), name='api-part-param-template-list'),
|
||||
|
||||
url(r'^.*$', PartParameterList.as_view(), name='api-part-param-list'),
|
||||
]
|
||||
|
||||
part_api_urls = [
|
||||
url(r'^tree/?', PartCategoryTree.as_view(), name='api-part-tree'),
|
||||
|
||||
url(r'^category/', include(cat_api_urls)),
|
||||
url(r'^star/', include(part_star_api_urls)),
|
||||
url(r'^parameter/', include(part_param_api_urls)),
|
||||
|
||||
url(r'^(?P<pk>\d+)/?', PartDetail.as_view(), name='api-part-detail'),
|
||||
|
||||
|
@ -8,6 +8,7 @@ from .models import Part, PartStar
|
||||
|
||||
from .models import PartCategory
|
||||
from .models import BomItem
|
||||
from .models import PartParameter, PartParameterTemplate
|
||||
|
||||
from InvenTree.serializers import InvenTreeModelSerializer
|
||||
|
||||
@ -174,3 +175,28 @@ class BomItemSerializer(InvenTreeModelSerializer):
|
||||
'note',
|
||||
'validated',
|
||||
]
|
||||
|
||||
|
||||
class PartParameterSerializer(InvenTreeModelSerializer):
|
||||
""" JSON serializers for the PartParameter model """
|
||||
|
||||
class Meta:
|
||||
model = PartParameter
|
||||
fields = [
|
||||
'pk',
|
||||
'part',
|
||||
'template',
|
||||
'data'
|
||||
]
|
||||
|
||||
|
||||
class PartParameterTemplateSerializer(InvenTreeModelSerializer):
|
||||
""" JSON serializer for the PartParameterTemplate model """
|
||||
|
||||
class Meta:
|
||||
model = PartParameterTemplate
|
||||
fields = [
|
||||
'pk',
|
||||
'name',
|
||||
'units',
|
||||
]
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
{% block settings %}
|
||||
|
||||
<h4>Currencies</h4>
|
||||
|
||||
<table class='table table-striped table-condensed' id='currency-table'/>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user