Remove PartFilterMixin class

This commit is contained in:
Oliver Walters 2020-08-23 21:08:41 +10:00
parent ed5ad3c047
commit 9a35293126
2 changed files with 4 additions and 32 deletions

View File

@ -8,7 +8,7 @@ from .models import TestReport, ReportAsset
class ReportTemplateAdmin(admin.ModelAdmin):
list_display = ('name', 'description', 'template', 'enabled')
list_display = ('name', 'description', 'template', 'filters', 'enabled')
class ReportAssetAdmin(admin.ModelAdmin):

View File

@ -153,36 +153,6 @@ class ReportTemplateBase(models.Model):
verbose_name=_('Enabled')
)
class Meta:
abstract = True
class PartFilterMixin(models.Model):
"""
A model mixin used for matching a report type against a Part object.
Used to assign a report to a given part using custom filters.
"""
class Meta:
abstract = True
def matches_part(self, part):
"""
Test if this report matches a given part.
"""
filters = self.get_part_filters()
parts = PartModels.Part.objects.filter(**filters)
parts = parts.filter(pk=part.pk)
return parts.exists()
def get_part_filters(self):
""" Return a map of filters to be used for Part filtering """
return validateFilterString(self.part_filters)
filters = models.CharField(
blank=True,
max_length=250,
@ -190,8 +160,10 @@ class PartFilterMixin(models.Model):
validators=[validateFilterString]
)
class Meta:
abstract = True
class TestReport(ReportTemplateBase, PartFilterMixin):
class TestReport(ReportTemplateBase):
"""
Render a TestReport against a StockItem object.
"""