mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Add subclass models for report types
This commit is contained in:
parent
251a23d127
commit
174c4cc591
@ -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: ''
|
@ -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)
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user