2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 03:25:42 +00:00

Toot toot! It's the refactor tractor.

- Create helper functions to qualify media and static files
This commit is contained in:
Oliver Walters
2020-04-07 11:38:57 +10:00
parent ae9ef04013
commit 95032141ce
3 changed files with 46 additions and 10 deletions

View File

@ -23,6 +23,7 @@ from markdownx.models import MarkdownxField
from stdimage.models import StdImageField
from InvenTree.helpers import getMediaUrl, getBlankImage, getBlankThumbnail
from InvenTree.fields import InvenTreeURLField, RoundingDecimalField
from InvenTree.status_codes import OrderStatus
from common.models import Currency
@ -118,18 +119,18 @@ class Company(models.Model):
""" Return the URL of the image for this company """
if self.image:
return os.path.join(settings.MEDIA_URL, str(self.image.url))
return getMediaUrl(self.image.url)
else:
return os.path.join(settings.STATIC_URL, 'img/blank_image.png')
return getBlankImage()
def get_thumbnail_url(self):
""" Return the URL for the thumbnail image for this Company """
if self.image:
return os.path.join(settings.MEDIA_URL, str(self.image.thumbnail.url))
return getMediaUrl(self.image.thumbnail.url)
else:
return os.path.join(settings.STATIC_URL, 'img/blank_image.thumbnail.png')
return getBlankThumbnail()
@property
def part_count(self):
""" The number of parts supplied by this company """