1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Merge pull request #9981 from chcon/develop

re-enable markdown in custom columns
This commit is contained in:
Jeremy Stretch
2022-08-16 08:57:37 -04:00
committed by GitHub

View File

@ -418,6 +418,14 @@ class CustomFieldColumn(tables.Column):
"""
Display custom fields in the appropriate format.
"""
template_code = """
{% if value %}
{{ value|markdown }}
{% else %}
—
{% endif %}
"""
def __init__(self, customfield, *args, **kwargs):
self.customfield = customfield
kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}')
@ -445,6 +453,8 @@ class CustomFieldColumn(tables.Column):
return mark_safe(', '.join(
self._likify_item(obj) for obj in self.customfield.deserialize(value)
))
if self.customfield.type == CustomFieldTypeChoices.TYPE_LONGTEXT:
return Template(self.template_code).render(Context({"value": value}))
if value is not None:
obj = self.customfield.deserialize(value)
return mark_safe(self._likify_item(obj))