mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Allowing Part thumbnail (image) update via API
This commit is contained in:
parent
5209a7a1b0
commit
af70dd5dfe
@ -190,6 +190,21 @@ class PartThumbs(generics.ListAPIView):
|
|||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
|
|
||||||
|
class PartThumbsUpdate(generics.RetrieveUpdateAPIView):
|
||||||
|
""" API endpoint for updating Part thumbnails"""
|
||||||
|
|
||||||
|
queryset = Part.objects.all()
|
||||||
|
serializer_class = part_serializers.PartThumbSerializerUpdate
|
||||||
|
|
||||||
|
permission_classes = [
|
||||||
|
permissions.IsAuthenticated,
|
||||||
|
]
|
||||||
|
|
||||||
|
filter_backends = [
|
||||||
|
DjangoFilterBackend
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartDetail(generics.RetrieveUpdateDestroyAPIView):
|
class PartDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
""" API endpoint for detail view of a single Part object """
|
""" API endpoint for detail view of a single Part object """
|
||||||
|
|
||||||
@ -716,7 +731,10 @@ part_api_urls = [
|
|||||||
url(r'^.*$', PartParameterList.as_view(), name='api-part-param-list'),
|
url(r'^.*$', PartParameterList.as_view(), name='api-part-param-list'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
url(r'^thumbs/', PartThumbs.as_view(), name='api-part-thumbs'),
|
url(r'^thumbs/', include([
|
||||||
|
url(r'^$', PartThumbs.as_view(), name='api-part-thumbs'),
|
||||||
|
url(r'^(?P<pk>\d+)/?', PartThumbsUpdate.as_view(), name='api-part-thumbs-update'),
|
||||||
|
])),
|
||||||
|
|
||||||
url(r'^(?P<pk>\d+)/?', PartDetail.as_view(), name='api-part-detail'),
|
url(r'^(?P<pk>\d+)/?', PartDetail.as_view(), name='api-part-detail'),
|
||||||
|
|
||||||
|
@ -92,6 +92,18 @@ class PartThumbSerializer(serializers.Serializer):
|
|||||||
count = serializers.IntegerField(read_only=True)
|
count = serializers.IntegerField(read_only=True)
|
||||||
|
|
||||||
|
|
||||||
|
class PartThumbSerializerUpdate(InvenTreeModelSerializer):
|
||||||
|
""" Serializer for updating Part thumbnail """
|
||||||
|
|
||||||
|
image = InvenTreeAttachmentSerializerField(required=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Part
|
||||||
|
fields = [
|
||||||
|
'image',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartBriefSerializer(InvenTreeModelSerializer):
|
class PartBriefSerializer(InvenTreeModelSerializer):
|
||||||
""" Serializer for Part (brief detail) """
|
""" Serializer for Part (brief detail) """
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user