FHRP groups cleanup

This commit is contained in:
jeremystretch 2021-11-04 14:19:10 -04:00
parent 2e75a111ed
commit bd3d2c60d9
5 changed files with 19 additions and 11 deletions

View File

@ -529,7 +529,7 @@ class FHRPGroupForm(BootstrapMixin, CustomFieldModelForm):
required=False required=False
) )
# Optionally create a new IPAddress along with the NHRPGroup # Optionally create a new IPAddress along with the FHRPGroup
ip_vrf = DynamicModelChoiceField( ip_vrf = DynamicModelChoiceField(
queryset=VRF.objects.all(), queryset=VRF.objects.all(),
required=False, required=False,

View File

@ -47,7 +47,7 @@ class FHRPGroup(PrimaryModel):
to='ipam.IPAddress', to='ipam.IPAddress',
content_type_field='assigned_object_type', content_type_field='assigned_object_type',
object_id_field='assigned_object_id', object_id_field='assigned_object_id',
related_query_name='nhrp_group' related_query_name='fhrp_group'
) )
objects = RestrictedQuerySet.as_manager() objects = RestrictedQuerySet.as_manager()

View File

@ -981,16 +981,10 @@ class FHRPGroupAssignmentEditView(generic.ObjectEditView):
instance.interface = get_object_or_404(content_type.model_class(), pk=request.GET.get('interface_id')) instance.interface = get_object_or_404(content_type.model_class(), pk=request.GET.get('interface_id'))
return instance return instance
def get_return_url(self, request, obj=None):
return obj.interface.get_absolute_url() if obj else super().get_return_url(request)
class FHRPGroupAssignmentDeleteView(generic.ObjectDeleteView): class FHRPGroupAssignmentDeleteView(generic.ObjectDeleteView):
queryset = FHRPGroupAssignment.objects.all() queryset = FHRPGroupAssignment.objects.all()
def get_return_url(self, request, obj=None):
return obj.interface.get_absolute_url() if obj else super().get_return_url(request)
# #
# VLANs # VLANs

View File

@ -72,12 +72,13 @@
<div class="card"> <div class="card">
<h5 class="card-header">Members</h5> <h5 class="card-header">Members</h5>
<div class="card-body"> <div class="card-body">
{% if ipaddress_table.rows %} {% if members_table.rows %}
{% render_table members_table 'inc/table.html' %} {% render_table members_table 'inc/table.html' %}
{% else %} {% else %}
<div class="text-muted">None</div> <div class="text-muted">None</div>
{% endif %} {% endif %}
</div> </div>
</div>
{% plugin_full_width_page object %} {% plugin_full_width_page object %}
</div> </div>
</div> </div>

View File

@ -1,7 +1,7 @@
{% load helpers %} {% load helpers %}
<div class="card"> <div class="card">
<h5 class="card-header">NHRP Groups</h5> <h5 class="card-header">FHRP Groups</h5>
<div class="card-body"> <div class="card-body">
<table class="table table-hover table-headings"> <table class="table table-hover table-headings">
<thead> <thead>
@ -10,6 +10,7 @@
<th>Protocol</th> <th>Protocol</th>
<th>Virtual IPs</th> <th>Virtual IPs</th>
<th>Priority</th> <th>Priority</th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -30,6 +31,18 @@
<td> <td>
{{ assignment.priority }} {{ assignment.priority }}
</td> </td>
<td class="text-end noprint">
{% if perms.ipam.change_fhrpgroupassignment %}
<a href="{% url 'ipam:fhrpgroupassignment_edit' pk=assignment.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-warning btn-sm lh-1" title="Edit">
<i class="mdi mdi-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.ipam.delete_fhrpgroupassignment %}
<a href="{% url 'ipam:fhrpgroupassignment_delete' pk=assignment.pk %}?return_url={{ object.get_absolute_url }}" class="btn btn-danger btn-sm lh-1" title="Delete">
<i class="mdi mdi-trash-can-outline" aria-hidden="true"></i>
</a>
{% endif %}
</td>
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
@ -46,7 +59,7 @@
</a> </a>
{% endif %} {% endif %}
{% if perms.ipam.add_fhrpgroupassignment %} {% if perms.ipam.add_fhrpgroupassignment %}
<a href="{% url 'ipam:fhrpgroupassignment_add' %}?interface_type={{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}&interface_id={{ object.pk }}" class="btn btn-sm btn-primary"> <a href="{% url 'ipam:fhrpgroupassignment_add' %}?interface_type={{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}&interface_id={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-sm btn-primary">
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> Assign Group <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Assign Group
</a> </a>
{% endif %} {% endif %}