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

Clean up prefix hierarchy annotation

This commit is contained in:
Jeremy Stretch
2020-12-18 15:43:15 -05:00
parent 442dee72b5
commit 1e5778e6db
2 changed files with 13 additions and 7 deletions

View File

@ -18,13 +18,11 @@ UTILIZATION_GRAPH = """
"""
PREFIX_LINK = """
{% if record.children %}
<span class="text-nowrap" style="padding-left: {{ record.parents }}0px "><i class="mdi mdi-chevron-right"></i></a>
{% else %}
<span class="text-nowrap" style="padding-left: {{ record.parents }}9px">
{% endif %}
<a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if parent.vrf %}&vrf={{ parent.vrf.pk }}{% endif %}{% if parent.site %}&site={{ parent.site.pk }}{% endif %}{% if parent.tenant %}&tenant_group={{ parent.tenant.group.pk }}&tenant={{ parent.tenant.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a>
</span>
{% load helpers %}
{% for i in record.parents|as_range %}
<i class="mdi mdi-circle-small"></i>
{% endfor %}
<a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if parent.vrf %}&vrf={{ parent.vrf.pk }}{% endif %}{% if parent.site %}&site={{ parent.site.pk }}{% endif %}{% if parent.tenant %}&tenant_group={{ parent.tenant.group.pk }}&tenant={{ parent.tenant.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a>
"""
PREFIX_ROLE_LINK = """

View File

@ -208,6 +208,14 @@ def split(string, sep=','):
return string.split(sep)
@register.filter()
def as_range(n):
"""
Return a range of n items.
"""
return range(n)
#
# Tags
#