mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #9451: Add export_raw argument for TemplateColumn
This commit is contained in:
@ -85,4 +85,5 @@ The table column classes listed below are supported for use in plugins. These cl
|
||||
|
||||
::: netbox.tables.TemplateColumn
|
||||
selection:
|
||||
members: false
|
||||
members:
|
||||
- __init__
|
||||
|
@ -11,6 +11,7 @@
|
||||
* [#9277](https://github.com/netbox-community/netbox/issues/9277) - Introduce `CSRF_COOKIE_NAME` configuration parameter
|
||||
* [#9347](https://github.com/netbox-community/netbox/issues/9347) - Include services in global search
|
||||
* [#9379](https://github.com/netbox-community/netbox/issues/9379) - Redirect to virtual chassis view after adding a member device
|
||||
* [#9451](https://github.com/netbox-community/netbox/issues/9451) - Add `export_raw` argument for TemplateColumn
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
@ -90,6 +90,15 @@ class TemplateColumn(tables.TemplateColumn):
|
||||
"""
|
||||
PLACEHOLDER = mark_safe('—')
|
||||
|
||||
def __init__(self, export_raw=False, **kwargs):
|
||||
"""
|
||||
Args:
|
||||
export_raw: If true, data export returns the raw field value rather than the rendered template. (Default:
|
||||
False)
|
||||
"""
|
||||
super().__init__(**kwargs)
|
||||
self.export_raw = export_raw
|
||||
|
||||
def render(self, *args, **kwargs):
|
||||
ret = super().render(*args, **kwargs)
|
||||
if not ret.strip():
|
||||
@ -97,6 +106,10 @@ class TemplateColumn(tables.TemplateColumn):
|
||||
return ret
|
||||
|
||||
def value(self, **kwargs):
|
||||
if self.export_raw:
|
||||
# Skip template rendering and export raw value
|
||||
return kwargs.get('value')
|
||||
|
||||
ret = super().value(**kwargs)
|
||||
if ret == self.PLACEHOLDER:
|
||||
return ''
|
||||
|
Reference in New Issue
Block a user