Merge pull request #697 from SchrodingersGat/stock-api-fix

Stock api fix
This commit is contained in:
Oliver 2020-04-05 23:09:03 +10:00 committed by GitHub
commit fce26c80b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -225,11 +225,17 @@ class PartList(generics.ListCreateAPIView):
# Use the 'thumbnail' image here instead of the full-size image
# Note: The full-size image is used when requesting the /api/part/<x>/ endpoint
if img:
fn, ext = os.path.splitext(img)
thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
item['thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
thumb = os.path.join(settings.MEDIA_URL, thumb)
else:
thumb = ''
item['thumbnail'] = thumb
del item['image']

View File

@ -340,12 +340,17 @@ class StockList(generics.ListCreateAPIView):
img = item['part__image']
if img:
# Use the thumbnail image instead
fn, ext = os.path.splitext(img)
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']