1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduce MPTTColumn to represent MPTT models

This commit is contained in:
Jeremy Stretch
2021-03-04 20:47:24 -05:00
parent 6149ba6e36
commit 32501c96e5
5 changed files with 25 additions and 35 deletions

View File

@ -287,3 +287,20 @@ class TagColumn(tables.TemplateColumn):
def value(self, value):
return ",".join([tag.name for tag in value.all()])
class MPTTColumn(tables.TemplateColumn):
template_code = """{% for i in record.get_ancestors %}<i class="mdi mdi-circle-small"></i>{% endfor %}""" \
"""<a href="{{ record.get_absolute_url }}">{{ record.name }}</a>"""
def __init__(self, *args, **kwargs):
super().__init__(
template_code=self.template_code,
orderable=False,
attrs={'td': {'class': 'text-nowrap'}},
*args,
**kwargs
)
def value(self, value):
return value