mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Override value() on custom table columns
This commit is contained in:
@ -133,6 +133,9 @@ class BooleanColumn(tables.Column):
|
|||||||
rendered = '<span class="text-danger"><i class="mdi mdi-close-thick"></i></span>'
|
rendered = '<span class="text-danger"><i class="mdi mdi-close-thick"></i></span>'
|
||||||
return mark_safe(rendered)
|
return mark_safe(rendered)
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
class ButtonsColumn(tables.TemplateColumn):
|
class ButtonsColumn(tables.TemplateColumn):
|
||||||
"""
|
"""
|
||||||
@ -177,6 +180,10 @@ class ButtonsColumn(tables.TemplateColumn):
|
|||||||
|
|
||||||
super().__init__(template_code=template_code, *args, **kwargs)
|
super().__init__(template_code=template_code, *args, **kwargs)
|
||||||
|
|
||||||
|
# Exclude from export by default
|
||||||
|
if 'exclude_from_export' not in kwargs:
|
||||||
|
self.exclude_from_export = True
|
||||||
|
|
||||||
self.extra_context.update({
|
self.extra_context.update({
|
||||||
'buttons': buttons or self.buttons,
|
'buttons': buttons or self.buttons,
|
||||||
'return_url_extra': return_url_extra,
|
'return_url_extra': return_url_extra,
|
||||||
@ -201,6 +208,9 @@ class ChoiceFieldColumn(tables.Column):
|
|||||||
)
|
)
|
||||||
return self.default
|
return self.default
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class ColorColumn(tables.Column):
|
class ColorColumn(tables.Column):
|
||||||
"""
|
"""
|
||||||
@ -211,6 +221,9 @@ class ColorColumn(tables.Column):
|
|||||||
f'<span class="label color-block" style="background-color: #{value}"> </span>'
|
f'<span class="label color-block" style="background-color: #{value}"> </span>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
return f'#{value}'
|
||||||
|
|
||||||
|
|
||||||
class ColoredLabelColumn(tables.TemplateColumn):
|
class ColoredLabelColumn(tables.TemplateColumn):
|
||||||
"""
|
"""
|
||||||
@ -224,6 +237,9 @@ class ColoredLabelColumn(tables.TemplateColumn):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(template_code=self.template_code, *args, **kwargs)
|
super().__init__(template_code=self.template_code, *args, **kwargs)
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
return str(value)
|
||||||
|
|
||||||
|
|
||||||
class LinkedCountColumn(tables.Column):
|
class LinkedCountColumn(tables.Column):
|
||||||
"""
|
"""
|
||||||
@ -247,6 +263,9 @@ class LinkedCountColumn(tables.Column):
|
|||||||
return mark_safe(f'<a href="{url}">{value}</a>')
|
return mark_safe(f'<a href="{url}">{value}</a>')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
class TagColumn(tables.TemplateColumn):
|
class TagColumn(tables.TemplateColumn):
|
||||||
"""
|
"""
|
||||||
@ -265,3 +284,6 @@ class TagColumn(tables.TemplateColumn):
|
|||||||
template_code=self.template_code,
|
template_code=self.template_code,
|
||||||
extra_context={'url_name': url_name}
|
extra_context={'url_name': url_name}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def value(self, value):
|
||||||
|
return ",".join([tag.name for tag in value.all()])
|
||||||
|
Reference in New Issue
Block a user