mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Display supplier logo in part suppliers list
- Also add a background colour for popup image in case of transparent image file
This commit is contained in:
parent
0754afd5f5
commit
58e5b10d26
@ -9,6 +9,7 @@ import os
|
||||
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
def rename_company_image(instance, filename):
|
||||
@ -78,6 +79,14 @@ class Company(models.Model):
|
||||
""" Get the web URL for the detail view for this Company """
|
||||
return reverse('company-detail', kwargs={'pk': self.id})
|
||||
|
||||
def get_image_url(self):
|
||||
""" Return the URL of the image for this company """
|
||||
|
||||
if self.image:
|
||||
return os.path.join(settings.MEDIA_URL, str(self.image.url))
|
||||
else:
|
||||
return ''
|
||||
|
||||
@property
|
||||
def part_count(self):
|
||||
""" The number of parts supplied by this company """
|
||||
|
@ -128,6 +128,7 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
||||
part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
|
||||
|
||||
supplier_name = serializers.CharField(source='supplier.name', read_only=True)
|
||||
supplier_logo = serializers.CharField(source='supplier.get_image_url', read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = SupplierPart
|
||||
@ -138,6 +139,7 @@ class SupplierPartSerializer(serializers.ModelSerializer):
|
||||
'part_detail',
|
||||
'supplier',
|
||||
'supplier_name',
|
||||
'supplier_logo',
|
||||
'SKU',
|
||||
'manufacturer',
|
||||
'MPN',
|
||||
|
@ -63,7 +63,7 @@
|
||||
field: 'supplier_name',
|
||||
title: 'Supplier',
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value, '/company/' + row.supplier + '/');
|
||||
return imageHoverIcon(row.supplier_logo) + renderLink(value, '/company/' + row.supplier + '/');
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -13,12 +13,14 @@
|
||||
/* Part image icons with full-display on mouse hover */
|
||||
|
||||
.hover-img-thumb {
|
||||
background: #eee;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border: 1px solid #cce;
|
||||
}
|
||||
|
||||
.hover-img-large {
|
||||
background: #eee;
|
||||
display: none;
|
||||
position: absolute;
|
||||
z-index: 999;
|
||||
|
Loading…
Reference in New Issue
Block a user