mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-07 12:22:11 +00:00
Add 'custom' attribute
This commit is contained in:
@@ -83,6 +83,7 @@ class StatusView(GenericAPIView):
|
|||||||
'key': item.key,
|
'key': item.key,
|
||||||
'label': item.label,
|
'label': item.label,
|
||||||
'name': item.name,
|
'name': item.name,
|
||||||
|
'custom': True,
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
@@ -114,12 +115,14 @@ class AllStatusViews(StatusView):
|
|||||||
for item in cls.custom_values():
|
for item in cls.custom_values():
|
||||||
label = str(item.name)
|
label = str(item.name)
|
||||||
if label not in cls_data['values']:
|
if label not in cls_data['values']:
|
||||||
|
print('custom value:', item)
|
||||||
cls_data['values'][label] = {
|
cls_data['values'][label] = {
|
||||||
'color': item.color,
|
'color': item.color,
|
||||||
'logical_key': item.logical_key,
|
'logical_key': item.logical_key,
|
||||||
'key': item.key,
|
'key': item.key,
|
||||||
'label': item.label,
|
'label': item.label,
|
||||||
'name': item.name,
|
'name': item.name,
|
||||||
|
'custom': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
data[cls.__name__] = GenericStateClassSerializer(cls_data, many=False).data
|
data[cls.__name__] = GenericStateClassSerializer(cls_data, many=False).data
|
||||||
|
@@ -11,7 +11,7 @@ class GenericStateValueSerializer(serializers.Serializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
"""Meta class for GenericStateValueSerializer."""
|
"""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)
|
key = serializers.IntegerField(label=_('Key'), required=True)
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ class GenericStateValueSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
color = serializers.CharField(label=_('Color'), required=False)
|
color = serializers.CharField(label=_('Color'), required=False)
|
||||||
|
|
||||||
|
custom = serializers.BooleanField(label=_('Custom'), required=False)
|
||||||
|
|
||||||
|
|
||||||
class GenericStateClassSerializer(serializers.Serializer):
|
class GenericStateClassSerializer(serializers.Serializer):
|
||||||
"""API serializer for generic state class information."""
|
"""API serializer for generic state class information."""
|
||||||
|
@@ -214,6 +214,7 @@ class StatusCode(BaseEnum):
|
|||||||
'key': item.key,
|
'key': item.key,
|
||||||
'label': item.label,
|
'label': item.label,
|
||||||
'name': item.name,
|
'name': item.name,
|
||||||
|
'custom': True,
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
Reference in New Issue
Block a user