mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 05:46:34 +00:00
Toot toot! It's the refactor tractor.
- Create helper functions to qualify media and static files
This commit is contained in:
@ -300,9 +300,9 @@ class Part(models.Model):
|
||||
""" Return the URL of the image for this part """
|
||||
|
||||
if self.image:
|
||||
return os.path.join(settings.MEDIA_URL, str(self.image.url))
|
||||
return helpers.getMediaUrl(self.image.url)
|
||||
else:
|
||||
return os.path.join(settings.STATIC_URL, 'img/blank_image.png')
|
||||
return helpers.getBlankImage()
|
||||
|
||||
def get_thumbnail_url(self):
|
||||
"""
|
||||
@ -310,10 +310,10 @@ class Part(models.Model):
|
||||
"""
|
||||
|
||||
if self.image:
|
||||
return os.path.join(settings.MEDIA_URL, str(self.image.thumbnail.url))
|
||||
return helpers.getMediaUrl(self.image.thumbnail.url)
|
||||
else:
|
||||
return os.path.join(settings.STATIC_URL, 'img/blank_image.thumbnail.png')
|
||||
|
||||
return helpers.getBlankThumbnail()
|
||||
|
||||
def validate_unique(self, exclude=None):
|
||||
""" Validate that a part is 'unique'.
|
||||
Uniqueness is checked across the following (case insensitive) fields:
|
||||
|
Reference in New Issue
Block a user