mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
List API now uses the thumbnail image
This commit is contained in:
parent
afa31b3415
commit
0cfb293ca9
@ -139,7 +139,7 @@ function loadPartTable(table, url, options={}) {
|
||||
name = '<i>' + name + '</i>';
|
||||
}
|
||||
|
||||
var display = imageHoverIcon(row.image) + renderLink(name, '/part/' + row.pk + '/');
|
||||
var display = imageHoverIcon(row.thumbnail) + renderLink(name, '/part/' + row.pk + '/');
|
||||
|
||||
if (row.is_template) {
|
||||
display = display + "<span class='label label-info' style='float: right;'>TEMPLATE</span>";
|
||||
|
@ -70,7 +70,7 @@ function loadStockTable(table, options) {
|
||||
|
||||
name += row.part__name;
|
||||
|
||||
return imageHoverIcon(row.part__image) + name + ' <i>(' + data.length + ' items)</i>';
|
||||
return imageHoverIcon(row.part__thumbnail) + name + ' <i>(' + data.length + ' items)</i>';
|
||||
}
|
||||
else if (field == 'part__description') {
|
||||
return row.part__description;
|
||||
@ -188,7 +188,7 @@ function loadStockTable(table, options) {
|
||||
name += row.part__revision;
|
||||
}
|
||||
|
||||
return imageHoverIcon(row.part__image) + renderLink(name, '/part/' + row.part + '/stock/');
|
||||
return imageHoverIcon(row.part__thumbnail) + renderLink(name, '/part/' + row.part + '/stock/');
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -221,7 +221,17 @@ class PartList(generics.ListCreateAPIView):
|
||||
for item in data:
|
||||
|
||||
if item['image']:
|
||||
item['image'] = os.path.join(settings.MEDIA_URL, item['image'])
|
||||
img = item['image']
|
||||
|
||||
# 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
|
||||
fn, ext = os.path.splitext(img)
|
||||
|
||||
thumb = "{fn}.thumbnail{ext}".format(fn=fn, ext=ext)
|
||||
|
||||
item['thumbnail'] = os.path.join(settings.MEDIA_URL, thumb)
|
||||
|
||||
del item['image']
|
||||
|
||||
cat_id = item['category']
|
||||
|
||||
|
@ -47,7 +47,7 @@ class PartBriefSerializer(InvenTreeModelSerializer):
|
||||
""" Serializer for Part (brief detail) """
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
image_url = serializers.CharField(source='get_image_url', read_only=True)
|
||||
image_url = serializers.CharField(source='get_thumbnail_url', read_only=True)
|
||||
|
||||
@staticmethod
|
||||
def setup_eager_loading(queryset):
|
||||
@ -79,7 +79,8 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
"""
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
image_url = serializers.CharField(source='get_image_url', read_only=True)
|
||||
image = serializers.CharField(source='get_image_url', read_only=True)
|
||||
thumbnail = serializers.CharField(source='get_thumbnail_url', read_only=True)
|
||||
category_name = serializers.CharField(source='category_path', read_only=True)
|
||||
|
||||
allocated_stock = serializers.IntegerField(source='allocation_count', read_only=True)
|
||||
@ -100,7 +101,8 @@ class PartSerializer(InvenTreeModelSerializer):
|
||||
'url', # Link to the part detail page
|
||||
'category',
|
||||
'category_name',
|
||||
'image_url',
|
||||
'image',
|
||||
'thumbnail',
|
||||
'full_name',
|
||||
'name',
|
||||
'IPN',
|
||||
|
@ -337,7 +337,17 @@ class StockList(generics.ListCreateAPIView):
|
||||
locations = {}
|
||||
|
||||
for item in data:
|
||||
item['part__image'] = os.path.join(settings.MEDIA_URL, item['part__image'])
|
||||
|
||||
img = item['part__image']
|
||||
|
||||
# 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)
|
||||
|
||||
del item['part__image']
|
||||
|
||||
loc_id = item['location']
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user