mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
* Fix issues made in #7614 * Flip cases * Remove caching of the debug settings --------- Co-authored-by: Oliver <oliver.henry.walters@gmail.com>
This commit is contained in:
parent
c87b5c8f3d
commit
e5814ea486
@ -75,12 +75,6 @@ class InvenTreeLabelSheetPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlug
|
|||||||
}
|
}
|
||||||
|
|
||||||
PrintingOptionsSerializer = LabelPrintingOptionsSerializer
|
PrintingOptionsSerializer = LabelPrintingOptionsSerializer
|
||||||
debug = None
|
|
||||||
|
|
||||||
def in_debug_mode(self):
|
|
||||||
"""Check if the plugin is printing in debug mode."""
|
|
||||||
if self.debug is None:
|
|
||||||
self.debug = str2bool(self.get_setting('DEBUG'))
|
|
||||||
|
|
||||||
def print_labels(
|
def print_labels(
|
||||||
self, label: LabelTemplate, output: LabelOutput, items: list, request, **kwargs
|
self, label: LabelTemplate, output: LabelOutput, items: list, request, **kwargs
|
||||||
@ -149,14 +143,15 @@ class InvenTreeLabelSheetPlugin(LabelPrintingMixin, SettingsMixin, InvenTreePlug
|
|||||||
# Render to a single HTML document
|
# Render to a single HTML document
|
||||||
html_data = self.wrap_pages(pages, **document_data)
|
html_data = self.wrap_pages(pages, **document_data)
|
||||||
|
|
||||||
if self.in_debug_mode():
|
if str2bool(self.get_setting('DEBUG')):
|
||||||
|
# In debug mode return with the raw HTML
|
||||||
|
output.output = ContentFile(html_data, 'labels.html')
|
||||||
|
else:
|
||||||
# Render HTML to PDF
|
# Render HTML to PDF
|
||||||
html = weasyprint.HTML(string=html_data)
|
html = weasyprint.HTML(string=html_data)
|
||||||
document = html.render().write_pdf()
|
document = html.render().write_pdf()
|
||||||
|
|
||||||
output.output = ContentFile(document, 'labels.pdf')
|
output.output = ContentFile(document, 'labels.pdf')
|
||||||
else:
|
|
||||||
output.output = ContentFile(html_data, 'labels.html')
|
|
||||||
|
|
||||||
output.progress = 100
|
output.progress = 100
|
||||||
output.complete = True
|
output.complete = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user