2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-21 06:16:29 +00:00

Merge branch 'master' of git://github.com/inventree/InvenTree into categories_parameters

This commit is contained in:
eeintech
2020-11-04 07:52:16 -05:00
5 changed files with 34 additions and 8 deletions

View File

@ -217,18 +217,29 @@ class PartTestTemplateList(generics.ListCreateAPIView):
class PartThumbs(generics.ListAPIView):
""" API endpoint for retrieving information on available Part thumbnails """
"""
API endpoint for retrieving information on available Part thumbnails
"""
queryset = Part.objects.all()
serializer_class = part_serializers.PartThumbSerializer
def get_queryset(self):
queryset = super().get_queryset()
# Get all Parts which have an associated image
queryset = queryset.exclude(image='')
return queryset
def list(self, request, *args, **kwargs):
"""
Serialize the available Part images.
- Images may be used for multiple parts!
"""
# Get all Parts which have an associated image
queryset = Part.objects.all().exclude(image='')
queryset = self.get_queryset()
# TODO - We should return the thumbnails here, not the full image!

View File

@ -241,6 +241,17 @@ class PartAPITest(APITestCase):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_get_thumbs(self):
"""
Return list of part thumbnails
"""
url = reverse('api-part-thumbs')
response = self.client.get(url)
self.assertEqual(response.status_code, status.HTTP_200_OK)
class PartAPIAggregationTest(APITestCase):
"""