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
commit a8dd809f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))