2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-06 12:01:41 +00:00

Add 'custom' attribute

This commit is contained in:
Oliver Walters
2024-12-28 01:55:54 +00:00
parent b260128cd5
commit cf9d71f86c
3 changed files with 7 additions and 1 deletions

View File

@@ -83,6 +83,7 @@ class StatusView(GenericAPIView):
'key': item.key,
'label': item.label,
'name': item.name,
'custom': True,
}
except Exception:
pass
@@ -114,12 +115,14 @@ class AllStatusViews(StatusView):
for item in cls.custom_values():
label = str(item.name)
if label not in cls_data['values']:
print('custom value:', item)
cls_data['values'][label] = {
'color': item.color,
'logical_key': item.logical_key,
'key': item.key,
'label': item.label,
'name': item.name,
'custom': True,
}
data[cls.__name__] = GenericStateClassSerializer(cls_data, many=False).data

View File

@@ -11,7 +11,7 @@ class GenericStateValueSerializer(serializers.Serializer):
class Meta:
"""Meta class for GenericStateValueSerializer."""
fields = ['key', 'logical_key', 'name', 'label', 'color']
fields = ['key', 'logical_key', 'name', 'label', 'color', 'custom']
key = serializers.IntegerField(label=_('Key'), required=True)
@@ -23,6 +23,8 @@ class GenericStateValueSerializer(serializers.Serializer):
color = serializers.CharField(label=_('Color'), required=False)
custom = serializers.BooleanField(label=_('Custom'), required=False)
class GenericStateClassSerializer(serializers.Serializer):
"""API serializer for generic state class information."""

View File

@@ -214,6 +214,7 @@ class StatusCode(BaseEnum):
'key': item.key,
'label': item.label,
'name': item.name,
'custom': True,
}
except Exception:
pass