From d6fcd22752ef510b0fdf602cb48889c6f5001ffb Mon Sep 17 00:00:00 2001 From: jeremystretch Date: Thu, 8 Apr 2021 10:30:13 -0400 Subject: [PATCH] Fixes #6110: Fix handling of TemplateColumn values for table export --- docs/release-notes/version-2.11.md | 1 + netbox/utilities/tables.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/release-notes/version-2.11.md b/docs/release-notes/version-2.11.md index 8183431bc..5038cf299 100644 --- a/docs/release-notes/version-2.11.md +++ b/docs/release-notes/version-2.11.md @@ -13,6 +13,7 @@ * [#6105](https://github.com/netbox-community/netbox/issues/6105) - Hide checkboxes for VMs under cluster VMs view * [#6106](https://github.com/netbox-community/netbox/issues/6106) - Allow assigning a virtual interface as the parent of an existing interface * [#6107](https://github.com/netbox-community/netbox/issues/6107) - Fix rack selection field on device form +* [#6110](https://github.com/netbox-community/netbox/issues/6110) - Fix handling of TemplateColumn values for table export --- diff --git a/netbox/utilities/tables.py b/netbox/utilities/tables.py index 7e9cc9c30..5bb5e9bbf 100644 --- a/netbox/utilities/tables.py +++ b/netbox/utilities/tables.py @@ -15,15 +15,16 @@ from extras.models import CustomField from .paginator import EnhancedPaginator, get_paginate_count -def stripped_value(self, value): +def stripped_value(self, **kwargs): """ Replaces TemplateColumn's value() method to both strip HTML tags and remove any leading/trailing whitespace. """ - return strip_tags(value).strip() + html = super(tables.TemplateColumn, self).value(**kwargs) + return strip_tags(html).strip() if isinstance(html, str) else html # TODO: We're monkey-patching TemplateColumn here to strip leading/trailing whitespace. This will no longer -# be necessary if django-tables2 PR #794 is accepted. (See #5926) +# be necessary under django-tables2 v2.3.5+. (See #5926) tables.TemplateColumn.value = stripped_value