2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-10-24 01:47:39 +00:00

make check more robust

This commit is contained in:
Matthias Mair
2025-10-18 18:41:36 +02:00
parent 631911a872
commit 38c3be4396

View File

@@ -222,6 +222,18 @@ class OutputOptionsMixin:
if getattr(cls, 'output_options', None) is not None:
schema_for_view_output_options(cls)
def __init__(self) -> None:
"""Initialize the mixin. Check that the serializer is compatible."""
super().__init__()
# Check that the serializer was defined
if hasattr(self, 'serializer_class') and (
not issubclass(self.serializer_class, FilterableSerializerMixin)
):
raise Exception(
'INVE-I2: `OutputOptionsMixin` can only be used with serializers that contain the `FilterableSerializerMixin` mixin'
)
def get_serializer(self, *args, **kwargs):
"""Return serializer instance with output options applied."""
if self.output_options and hasattr(self, 'request'):