2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-30 12:36:45 +00:00

Bug fix for stock api

- If a part had an empty image, the thumbnail was improperly encoded
This commit is contained in:
Oliver Walters 2020-04-05 22:57:42 +10:00
parent 3559e81d5f
commit 94b9878c8d

View File

@ -340,12 +340,17 @@ class StockList(generics.ListCreateAPIView):
img = item['part__image']
# Use the thumbnail image instead
fn, ext = os.path.splitext(img)
if img:
# Use the thumbnail image instead
fn, ext = os.path.splitext(img)
thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
item['part__thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
thumb = os.path.join(settings.MEDIA_URL, thumb)
else:
thumb = ''
item['part__thumbnail'] = thumb
del item['part__image']