mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Display images in report debug mode
This commit is contained in:
parent
46f20593c5
commit
7d30e75bc6
@ -22,6 +22,13 @@ def asset(filename):
|
|||||||
Return fully-qualified path for an upload report asset file.
|
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.join(settings.MEDIA_ROOT, 'report', 'assets', filename)
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
|
|
||||||
@ -34,6 +41,9 @@ def part_image(part):
|
|||||||
Return a fully-qualified path for a part image
|
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:
|
if type(part) is Part:
|
||||||
img = part.image.name
|
img = part.image.name
|
||||||
|
|
||||||
@ -43,6 +53,13 @@ def part_image(part):
|
|||||||
else:
|
else:
|
||||||
img = ''
|
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.join(settings.MEDIA_ROOT, img)
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user