2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-07 12:22:11 +00:00

Allow custom values

This commit is contained in:
Oliver Walters
2024-12-27 08:43:19 +00:00
parent b4955a93c7
commit 0663b7a659

View File

@@ -153,9 +153,18 @@ class StatusCode(BaseEnum):
return re.sub(r'(?<!^)(?=[A-Z])', '_', ref_name).lower() return re.sub(r'(?<!^)(?=[A-Z])', '_', ref_name).lower()
@classmethod @classmethod
def items(cls): def items(cls, custom=True):
"""All status code items.""" """All status code items."""
return [(x.value, x.label) for x in cls.values()] data = [(x.value, x.label) for x in cls.values()]
if custom:
try:
for item in cls.custom_values():
data.append((item.key, item.label))
except Exception:
pass
return data
@classmethod @classmethod
def keys(cls): def keys(cls):
@@ -189,7 +198,7 @@ class StatusCode(BaseEnum):
return filtered.label return filtered.label
@classmethod @classmethod
def dict(cls, key=None, custom=None): def dict(cls, key=None, custom=True):
"""Return a dict representation containing all required information.""" """Return a dict representation containing all required information."""
data = { data = {
x.name: {'color': x.color, 'key': x.value, 'label': x.label, 'name': x.name} x.name: {'color': x.color, 'key': x.value, 'label': x.label, 'name': x.name}