mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Expose stock items labels to the API
This commit is contained in:
parent
5666db6b7a
commit
446c744462
@ -28,6 +28,7 @@ from company.api import company_api_urls
|
|||||||
from stock.api import stock_api_urls
|
from stock.api import stock_api_urls
|
||||||
from build.api import build_api_urls
|
from build.api import build_api_urls
|
||||||
from order.api import order_api_urls
|
from order.api import order_api_urls
|
||||||
|
from label.api import label_api_urls
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
@ -58,6 +59,7 @@ apipatterns = [
|
|||||||
url(r'^stock/', include(stock_api_urls)),
|
url(r'^stock/', include(stock_api_urls)),
|
||||||
url(r'^build/', include(build_api_urls)),
|
url(r'^build/', include(build_api_urls)),
|
||||||
url(r'^order/', include(order_api_urls)),
|
url(r'^order/', include(order_api_urls)),
|
||||||
|
url(r'^label/', include(label_api_urls)),
|
||||||
|
|
||||||
# User URLs
|
# User URLs
|
||||||
url(r'^user/', include(user_urls)),
|
url(r'^user/', include(user_urls)),
|
||||||
|
43
InvenTree/label/api.py
Normal file
43
InvenTree/label/api.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.conf.urls import url, include
|
||||||
|
|
||||||
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
|
|
||||||
|
from rest_framework import generics, filters
|
||||||
|
|
||||||
|
from .models import StockItemLabel
|
||||||
|
from .serializers import StockItemLabelSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class StockItemLabelList(generics.ListAPIView):
|
||||||
|
"""
|
||||||
|
API endpoint for viewing list of StockItemLabel objects.
|
||||||
|
"""
|
||||||
|
|
||||||
|
queryset = StockItemLabel.objects.all()
|
||||||
|
serializer_class = StockItemLabelSerializer
|
||||||
|
|
||||||
|
filter_backends = [
|
||||||
|
DjangoFilterBackend,
|
||||||
|
filters.SearchFilter
|
||||||
|
]
|
||||||
|
|
||||||
|
filter_fields = [
|
||||||
|
'enabled',
|
||||||
|
]
|
||||||
|
|
||||||
|
search_fields = [
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
label_api_urls = [
|
||||||
|
|
||||||
|
# Stock item labels
|
||||||
|
url(r'stock/', include([
|
||||||
|
url(r'^.*$', StockItemLabelList.as_view(), name='api-stock-label-list'),
|
||||||
|
])),
|
||||||
|
]
|
26
InvenTree/label/serializers.py
Normal file
26
InvenTree/label/serializers.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from InvenTree.serializers import InvenTreeModelSerializer
|
||||||
|
from InvenTree.serializers import InvenTreeAttachmentSerializerField
|
||||||
|
|
||||||
|
from .models import StockItemLabel
|
||||||
|
|
||||||
|
|
||||||
|
class StockItemLabelSerializer(InvenTreeModelSerializer):
|
||||||
|
"""
|
||||||
|
Serializes a StockItemLabel object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
label = InvenTreeAttachmentSerializerField(required=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = StockItemLabel
|
||||||
|
fields = [
|
||||||
|
'pk',
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'label',
|
||||||
|
'filters',
|
||||||
|
'enabled',
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user