mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
re-enable markup in longtext custom columns
This commit is contained in:
@ -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))
|
||||||
|
@ -181,7 +181,8 @@ class NetBoxTable(BaseTable):
|
|||||||
content_type = ContentType.objects.get_for_model(self._meta.model)
|
content_type = ContentType.objects.get_for_model(self._meta.model)
|
||||||
custom_fields = CustomField.objects.filter(content_types=content_type)
|
custom_fields = CustomField.objects.filter(content_types=content_type)
|
||||||
extra_columns.extend([
|
extra_columns.extend([
|
||||||
(f'cf_{cf.name}', columns.CustomFieldMarkdownColumn(cf) if cf.type == CustomFieldTypeChoices.TYPE_LONGTEXT else columns.CustomFieldColumn(cf)) for cf in custom_fields
|
# (f'cf_{cf.name}', columns.CustomFieldMarkdownColumn(cf) if cf.type == CustomFieldTypeChoices.TYPE_LONGTEXT else columns.CustomFieldColumn(cf)) for cf in custom_fields
|
||||||
|
(f'cf_{cf.name}', columns.CustomFieldColumn(cf)) for cf in custom_fields
|
||||||
])
|
])
|
||||||
custom_links = CustomLink.objects.filter(content_type=content_type, enabled=True)
|
custom_links = CustomLink.objects.filter(content_type=content_type, enabled=True)
|
||||||
extra_columns.extend([
|
extra_columns.extend([
|
||||||
|
Reference in New Issue
Block a user