mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Cleanup
This commit is contained in:
parent
cab87a6860
commit
251a23d127
@ -356,6 +356,8 @@ latex_settings = CONFIG.get('latex', {})
|
||||
# Set the latex interpreter in the config.yaml settings file
|
||||
LATEX_INTERPRETER = latex_settings.get('interpreter', 'pdflatex')
|
||||
|
||||
LATEX_INTERPRETER_OPTIONS = latex_settings.get('options', '')
|
||||
|
||||
LATEX_GRAPHICSPATH = [
|
||||
# Allow LaTeX files to access the report assets directory
|
||||
os.path.join(MEDIA_ROOT, "report", "assets"),
|
||||
|
@ -82,3 +82,5 @@ latex:
|
||||
# Note: The intepreter needs to be installed on the system!
|
||||
# e.g. to install pdflatx: apt-get texlive-latex-base
|
||||
interpreter: pdflatex
|
||||
# Extra options to pass through to the LaTeX interpreter
|
||||
options: ''
|
@ -54,7 +54,14 @@ class ReportTemplate(models.Model):
|
||||
def template_name(self):
|
||||
return os.path.join('report_template', os.path.basename(self.template.name))
|
||||
|
||||
def render(self, request, context={}, **kwargs):
|
||||
def get_context_data(self, request):
|
||||
"""
|
||||
Supply context data to the template for rendering
|
||||
"""
|
||||
|
||||
return {}
|
||||
|
||||
def render(self, request, **kwargs):
|
||||
"""
|
||||
Render the template to a PDF file.
|
||||
|
||||
@ -65,15 +72,18 @@ class ReportTemplate(models.Model):
|
||||
|
||||
filename = kwargs.get('filename', 'report.pdf')
|
||||
|
||||
context = self.get_context_data(request)
|
||||
|
||||
context['request'] = request
|
||||
|
||||
if self.extension == '.tex':
|
||||
# Render LaTeX template to PDF
|
||||
return render_to_pdf(request, self.template_name, context, filename=filename)
|
||||
elif self.extension in ['.htm', '.html']:
|
||||
# Render HTML template to PDF
|
||||
wp = WeasyprintReportMixin(request, self.template_name, **kwargs)
|
||||
return wp.render_to_response(context, **kwargs)
|
||||
|
||||
|
||||
name = models.CharField(
|
||||
blank=False, max_length=100,
|
||||
help_text=_('Template name'),
|
||||
|
Loading…
Reference in New Issue
Block a user