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

Merge branch 'feature' of https://github.com/netbox-community/netbox into feature

# Conflicts:
#	netbox/dcim/tables/template_code.py
#	netbox/netbox/forms.py
#	netbox/templates/dcim/cable_connect.html
#	netbox/templates/dcim/consoleport.html
#	netbox/templates/dcim/consoleserverport.html
#	netbox/templates/dcim/device.html
#	netbox/templates/dcim/device/base.html
#	netbox/templates/dcim/device_edit.html
#	netbox/templates/dcim/interface.html
#	netbox/templates/dcim/rack.html
#	netbox/templates/dcim/rack_edit.html
#	netbox/templates/dcim/site.html
#	netbox/templates/extras/configcontext.html
#	netbox/templates/extras/objectchange.html
#	netbox/templates/generic/object.html
#	netbox/templates/inc/nav_menu.html
#	netbox/templates/ipam/ipaddress_edit.html
#	netbox/templates/ipam/vrf.html
#	netbox/utilities/templates/buttons/export.html
This commit is contained in:
checktheroads
2021-03-17 22:02:43 -07:00
197 changed files with 6374 additions and 2288 deletions

View File

@@ -133,6 +133,9 @@ class BooleanColumn(tables.Column):
rendered = '<span class="text-danger"><i class="mdi mdi-close-thick"></i></span>'
return mark_safe(rendered)
def value(self, value):
return str(value)
class ButtonsColumn(tables.TemplateColumn):
"""
@@ -177,6 +180,10 @@ class ButtonsColumn(tables.TemplateColumn):
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({
'buttons': buttons or self.buttons,
'return_url_extra': return_url_extra,
@@ -201,6 +208,9 @@ class ChoiceFieldColumn(tables.Column):
)
return self.default
def value(self, value):
return value
class ColorColumn(tables.Column):
"""
@@ -211,6 +221,9 @@ class ColorColumn(tables.Column):
f'<span class="color-label" style="background-color: #{value}">&nbsp;</span>'
)
def value(self, value):
return f'#{value}'
class ColoredLabelColumn(tables.TemplateColumn):
"""
@@ -230,6 +243,9 @@ class ColoredLabelColumn(tables.TemplateColumn):
def __init__(self, *args, **kwargs):
super().__init__(template_code=self.template_code, *args, **kwargs)
def value(self, value):
return str(value)
class LinkedCountColumn(tables.Column):
"""
@@ -253,6 +269,9 @@ class LinkedCountColumn(tables.Column):
return mark_safe(f'<a href="{url}">{value}</a>')
return value
def value(self, value):
return value
class TagColumn(tables.TemplateColumn):
"""
@@ -271,3 +290,39 @@ class TagColumn(tables.TemplateColumn):
template_code=self.template_code,
extra_context={'url_name': url_name}
)
def value(self, value):
return ",".join([tag.name for tag in value.all()])
class MPTTColumn(tables.TemplateColumn):
"""
Display a nested hierarchy for MPTT-enabled models.
"""
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
class UtilizationColumn(tables.TemplateColumn):
"""
Display a colored utilization bar graph.
"""
template_code = """{% load helpers %}{% if record.pk %}{% utilization_graph value %}{% endif %}"""
def __init__(self, *args, **kwargs):
super().__init__(template_code=self.template_code, *args, **kwargs)
def value(self, value):
return f'{value}%'