InvenTree/InvenTree/label/serializers.py
Lukas e4d2e2f96b
PUI Template editor (#6541)
* Added first POC for label editor

* Added preview item selection

* Split code

* Fix import

* Use liquid lang and added custom tooltips

* Auto load first item for preview and add BOM part assembly filter

* Make the save&reload action more obvious

* Make save optional and use server stored template

* Fix icons and inherit model url

* Add label/report extra fields to serializer and default templates

* Bump api version to v176

* Remove generic and pass template to editor

* Added error overlay

* Moved default tempaltes in default folder

* Only show detail drawer back button if necessary

* Rename action dropdown disabled to hidden and add loading disabled to template editor

* Fix types

* Add icons to editor/preview tabs

* Add draggable split pane and make editors use full height

* Add SplitButton component

* add code editor tag description

* fix related model field if empty string

* remove debug console.log

* move code editor/pdf preview into their own folder

* Update api_version.py

* add support for multiple editors

* fix template editor error handleing while loading/saving code

* add documentation for the template editor
2024-03-05 07:58:12 +11:00

68 lines
1.6 KiB
Python

"""API serializers for the label app."""
import label.models
from InvenTree.serializers import (
InvenTreeAttachmentSerializerField,
InvenTreeModelSerializer,
)
class LabelSerializerBase(InvenTreeModelSerializer):
"""Base class for label serializer."""
label = InvenTreeAttachmentSerializerField(required=True)
@staticmethod
def label_fields():
"""Generic serializer fields for a label template."""
return [
'pk',
'name',
'description',
'label',
'filters',
'width',
'height',
'enabled',
]
class StockItemLabelSerializer(LabelSerializerBase):
"""Serializes a StockItemLabel object."""
class Meta:
"""Metaclass options."""
model = label.models.StockItemLabel
fields = LabelSerializerBase.label_fields()
class StockLocationLabelSerializer(LabelSerializerBase):
"""Serializes a StockLocationLabel object."""
class Meta:
"""Metaclass options."""
model = label.models.StockLocationLabel
fields = LabelSerializerBase.label_fields()
class PartLabelSerializer(LabelSerializerBase):
"""Serializes a PartLabel object."""
class Meta:
"""Metaclass options."""
model = label.models.PartLabel
fields = LabelSerializerBase.label_fields()
class BuildLineLabelSerializer(LabelSerializerBase):
"""Serializes a BuildLineLabel object."""
class Meta:
"""Metaclass options."""
model = label.models.BuildLineLabel
fields = LabelSerializerBase.label_fields()