mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-18 13:06:30 -06:00
Merge pull request #9981 from chcon/develop
re-enable markdown in custom columns
This commit is contained in:
commit
a8dd809f8e
@ -418,6 +418,14 @@ class CustomFieldColumn(tables.Column):
|
|||||||
"""
|
"""
|
||||||
Display custom fields in the appropriate format.
|
Display custom fields in the appropriate format.
|
||||||
"""
|
"""
|
||||||
|
template_code = """
|
||||||
|
{% if value %}
|
||||||
|
{{ value|markdown }}
|
||||||
|
{% else %}
|
||||||
|
—
|
||||||
|
{% endif %}
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, customfield, *args, **kwargs):
|
def __init__(self, customfield, *args, **kwargs):
|
||||||
self.customfield = customfield
|
self.customfield = customfield
|
||||||
kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}')
|
kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}')
|
||||||
@ -445,6 +453,8 @@ class CustomFieldColumn(tables.Column):
|
|||||||
return mark_safe(', '.join(
|
return mark_safe(', '.join(
|
||||||
self._likify_item(obj) for obj in self.customfield.deserialize(value)
|
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:
|
if value is not None:
|
||||||
obj = self.customfield.deserialize(value)
|
obj = self.customfield.deserialize(value)
|
||||||
return mark_safe(self._likify_item(obj))
|
return mark_safe(self._likify_item(obj))
|
||||||
|
Loading…
Reference in New Issue
Block a user