2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 03:25:42 +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:
Oliver Walters
2019-05-08 20:23:54 +10:00
parent 0754afd5f5
commit 58e5b10d26
4 changed files with 14 additions and 1 deletions

View File

@ -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 """