diff --git a/InvenTree/config_template.yaml b/InvenTree/config_template.yaml index b5446b8e89..5cb0b1073c 100644 --- a/InvenTree/config_template.yaml +++ b/InvenTree/config_template.yaml @@ -80,7 +80,7 @@ sentry: latex: # Select the LaTeX interpreter to use for PDF rendering # Note: The intepreter needs to be installed on the system! - # e.g. to install pdflatx: apt-get texlive-latex-base + # e.g. to install pdflatex: apt-get texlive-latex-base interpreter: pdflatex # Extra options to pass through to the LaTeX interpreter options: '' \ No newline at end of file diff --git a/InvenTree/report/admin.py b/InvenTree/report/admin.py index 683a188c80..15d44931df 100644 --- a/InvenTree/report/admin.py +++ b/InvenTree/report/admin.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals from django.contrib import admin from .models import ReportTemplate, ReportAsset - +from .models import TestReport class ReportTemplateAdmin(admin.ModelAdmin): @@ -17,4 +17,5 @@ class ReportAssetAdmin(admin.ModelAdmin): admin.site.register(ReportTemplate, ReportTemplateAdmin) +admin.site.register(TestReport, ReportTemplateAdmin) admin.site.register(ReportAsset, ReportAssetAdmin) diff --git a/InvenTree/report/models.py b/InvenTree/report/models.py index a2dae298e7..626d8a5923 100644 --- a/InvenTree/report/models.py +++ b/InvenTree/report/models.py @@ -38,7 +38,7 @@ class WeasyprintReportMixin(WeasyTemplateResponseMixin): self.pdf_filename = kwargs.get('filename', 'report.pdf') -class ReportTemplate(models.Model): +class ReportTemplateBase(models.Model): """ Reporting template model. """ @@ -46,13 +46,16 @@ class ReportTemplate(models.Model): def __str__(self): return os.path.basename(self.template.name) + def getSubdir(self): + return '' + @property def extension(self): return os.path.splitext(self.template.name)[1].lower() @property def template_name(self): - return os.path.join('report_template', os.path.basename(self.template.name)) + return os.path.join('report_template', self.getSubdir(), os.path.basename(self.template.name)) def get_context_data(self, request): """ @@ -105,6 +108,35 @@ class ReportTemplate(models.Model): validators=[validate_filter_string] ) + class Meta: + abstract = True + + +class ReportTemplate(ReportTemplateBase): + """ + A simple reporting template which is used to upload template files, + which can then be used in other concrete template classes. + """ + + pass + + +class TestReport(ReportTemplateBase): + """ + Render a TestReport against a StockItem object. + """ + + def getSubdir(self): + return 'test' + + stock_item = None + + def get_context_data(self, request): + return { + 'stock_item': self.stock_item, + 'results': self.stock_item.testResultMap() + } + def rename_asset(instance, filename):