Display images in report debug mode

This commit is contained in:
Oliver Walters 2021-02-16 20:40:09 +11:00
parent 46f20593c5
commit 7d30e75bc6

View File

@ -22,6 +22,13 @@ def asset(filename):
Return fully-qualified path for an upload report asset file.
"""
# If in debug mode, return URL to the image, not a local file
debug_mode = InvenTreeSetting.get_setting('REPORT_DEBUG_MODE')
if debug_mode:
path = os.path.join(settings.MEDIA_URL, 'report', 'assets', filename)
else:
path = os.path.join(settings.MEDIA_ROOT, 'report', 'assets', filename)
path = os.path.abspath(path)
@ -34,6 +41,9 @@ def part_image(part):
Return a fully-qualified path for a part image
"""
# If in debug mode, return URL to the image, not a local file
debug_mode = InvenTreeSetting.get_setting('REPORT_DEBUG_MODE')
if type(part) is Part:
img = part.image.name
@ -43,6 +53,13 @@ def part_image(part):
else:
img = ''
if debug_mode:
if img:
return os.path.join(settings.MEDIA_URL, img)
else:
return os.path.join(settings.STATIC_URL, 'img', 'blank_image.png')
else:
path = os.path.join(settings.MEDIA_ROOT, img)
path = os.path.abspath(path)