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

Tweaked links to ensure that new child prefixes inherit the VRF and site of their parent by default

This commit is contained in:
Jeremy Stretch
2016-03-02 22:15:23 -05:00
parent 337815f81d
commit 7776ce5266
3 changed files with 10 additions and 3 deletions

View File

@ -21,13 +21,13 @@ PREFIX_LINK = """
{% else %} {% else %}
<span style="padding-left: {{ record.depth }}9px"> <span style="padding-left: {{ record.depth }}9px">
{% endif %} {% endif %}
<a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if site %}&site={{ site.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a> <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 %}{% endif %}">{{ record.prefix }}</a>
</span> </span>
""" """
PREFIX_LINK_BRIEF = """ PREFIX_LINK_BRIEF = """
<span style="padding-left: {{ record.depth }}0px"> <span style="padding-left: {{ record.depth }}0px">
<a href="{% if record.pk %}{% url 'ipam:prefix' pk=record.pk %}{% else %}{% url 'ipam:prefix_add' %}?prefix={{ record }}{% if site %}&site={{ site.pk }}{% endif %}{% endif %}">{{ record.prefix }}</a> <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 %}{% endif %}">{{ record.prefix }}</a>
</span> </span>
""" """

View File

@ -447,6 +447,7 @@ def prefix_add(request):
else: else:
form = PrefixForm(initial={ form = PrefixForm(initial={
'site': request.GET.get('site'), 'site': request.GET.get('site'),
'vrf': request.GET.get('vrf'),
'prefix': request.GET.get('prefix'), 'prefix': request.GET.get('prefix'),
}) })

View File

@ -86,7 +86,13 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{% include 'ipam/inc/prefix_table.html' with table=child_prefix_table table_template='panel_table.html' heading='Child Prefixes' site=prefix.site %} {% if child_prefix_table.rows %}
{% include 'ipam/inc/prefix_table.html' with table=child_prefix_table table_template='panel_table.html' heading='Child Prefixes' parent=prefix %}
{% elif prefix.new_subnet %}
<a href="{% url 'ipam:prefix_add' %}?prefix={{ prefix.new_subnet }}{% if prefix.vrf %}&vrf={{ prefix.vrf.pk }}{% endif %}{% if prefix.site %}&site={{ prefix.site.pk }}{% endif %}" class="btn btn-success">
<i class="glyphicon glyphicon-plus" aria-hidden="true"></i> Add Child Prefix
</a>
{% endif %}
</div> </div>
</div> </div>
{% endblock %} {% endblock %}