Adds selection custom field labels to UI

This commit is contained in:
sleepinggenius2
2023-10-04 11:52:21 -04:00
committed by Jeremy Stretch
parent 4d13f4d252
commit 285187542d
3 changed files with 14 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
from django import template
from django.http import QueryDict
from extras.choices import CustomFieldTypeChoices
from utilities.utils import dict_to_querydict
__all__ = (
@@ -38,6 +39,11 @@ def customfield_value(customfield, value):
customfield: A CustomField instance
value: The custom field value applied to an object
"""
if value:
if customfield.type == CustomFieldTypeChoices.TYPE_SELECT:
value = customfield.get_choice_label(value)
elif customfield.type == CustomFieldTypeChoices.TYPE_MULTISELECT:
value = [customfield.get_choice_label(v) for v in value]
return {
'customfield': customfield,
'value': value,