mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Exposes BuildOrderAttachment objects to the REST API
This commit is contained in:
parent
f67779c816
commit
a7d60cf5ad
@ -11,11 +11,12 @@ from rest_framework import generics
|
||||
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from InvenTree.api import AttachmentMixin
|
||||
from InvenTree.helpers import str2bool, isNull
|
||||
from InvenTree.status_codes import BuildStatus
|
||||
|
||||
from .models import Build, BuildItem
|
||||
from .serializers import BuildSerializer, BuildItemSerializer
|
||||
from .models import Build, BuildItem, BuildOrderAttachment
|
||||
from .serializers import BuildAttachmentSerializer, BuildSerializer, BuildItemSerializer
|
||||
|
||||
|
||||
class BuildList(generics.ListCreateAPIView):
|
||||
@ -226,14 +227,40 @@ class BuildItemList(generics.ListCreateAPIView):
|
||||
]
|
||||
|
||||
|
||||
build_item_api_urls = [
|
||||
url('^.*$', BuildItemList.as_view(), name='api-build-item-list'),
|
||||
]
|
||||
class BuildAttachmentList(generics.ListCreateAPIView, AttachmentMixin):
|
||||
"""
|
||||
API endpoint for listing (and creating) BuildOrderAttachment objects
|
||||
"""
|
||||
|
||||
queryset = BuildOrderAttachment.objects.all()
|
||||
serializer_class = BuildAttachmentSerializer
|
||||
|
||||
|
||||
class BuildAttachmentDetail(generics.RetrieveUpdateDestroyAPIView, AttachmentMixin):
|
||||
"""
|
||||
Detail endpoint for a BuildOrderAttachment object
|
||||
"""
|
||||
|
||||
queryset = BuildOrderAttachment.objects.all()
|
||||
serializer_class = BuildAttachmentSerializer
|
||||
|
||||
|
||||
build_api_urls = [
|
||||
url(r'^item/', include(build_item_api_urls)),
|
||||
|
||||
# Attachments
|
||||
url(r'^attachment/', include([
|
||||
url(r'^(?P<pk>\d+)/', BuildAttachmentDetail.as_view(), name='api-build-attachment-detail'),
|
||||
url('^.*$', BuildAttachmentList.as_view(), name='api-build-attachment-list'),
|
||||
])),
|
||||
|
||||
# Build Items
|
||||
url(r'^item/', include([
|
||||
url('^.*$', BuildItemList.as_view(), name='api-build-item-list')
|
||||
])),
|
||||
|
||||
# Build Detail
|
||||
url(r'^(?P<pk>\d+)/', BuildDetail.as_view(), name='api-build-detail'),
|
||||
|
||||
# Build List
|
||||
url(r'^.*$', BuildList.as_view(), name='api-build-list'),
|
||||
]
|
||||
|
@ -10,13 +10,13 @@ from django.db.models import BooleanField
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from InvenTree.serializers import InvenTreeModelSerializer
|
||||
from InvenTree.serializers import InvenTreeModelSerializer, InvenTreeAttachmentSerializerField
|
||||
|
||||
from stock.serializers import StockItemSerializerBrief
|
||||
from stock.serializers import LocationSerializer
|
||||
from part.serializers import PartSerializer, PartBriefSerializer
|
||||
|
||||
from .models import Build, BuildItem
|
||||
from .models import Build, BuildItem, BuildOrderAttachment
|
||||
|
||||
|
||||
class BuildSerializer(InvenTreeModelSerializer):
|
||||
@ -143,3 +143,21 @@ class BuildItemSerializer(InvenTreeModelSerializer):
|
||||
'stock_item_detail',
|
||||
'quantity'
|
||||
]
|
||||
|
||||
|
||||
class BuildAttachmentSerializer(InvenTreeModelSerializer):
|
||||
"""
|
||||
Serializer for a BuildAttachment
|
||||
"""
|
||||
|
||||
attachment = InvenTreeAttachmentSerializerField(required=True)
|
||||
|
||||
class Meta:
|
||||
model = BuildOrderAttachment
|
||||
|
||||
fields = [
|
||||
'pk',
|
||||
'build',
|
||||
'attachment',
|
||||
'comment'
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user