mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #7880: Include assigned IP addresses in FHRP group object representation
This commit is contained in:
@ -24,6 +24,7 @@
|
|||||||
* [#7768](https://github.com/netbox-community/netbox/issues/7768) - Validate IP address status when creating a new FHRP group
|
* [#7768](https://github.com/netbox-community/netbox/issues/7768) - Validate IP address status when creating a new FHRP group
|
||||||
* [#7771](https://github.com/netbox-community/netbox/issues/7771) - Group assignment should be optional when creating contacts via REST API
|
* [#7771](https://github.com/netbox-community/netbox/issues/7771) - Group assignment should be optional when creating contacts via REST API
|
||||||
* [#7849](https://github.com/netbox-community/netbox/issues/7849) - Fix exception when creating an FHRPGroup with an invalid IP address
|
* [#7849](https://github.com/netbox-community/netbox/issues/7849) - Fix exception when creating an FHRPGroup with an invalid IP address
|
||||||
|
* [#7880](https://github.com/netbox-community/netbox/issues/7880) - Include assigned IP addresses in FHRP group object representation
|
||||||
|
|
||||||
### REST API Changes
|
### REST API Changes
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ INTERFACE_IPADDRESSES = """
|
|||||||
INTERFACE_FHRPGROUPS = """
|
INTERFACE_FHRPGROUPS = """
|
||||||
<div class="table-badge-group">
|
<div class="table-badge-group">
|
||||||
{% for assignment in value.all %}
|
{% for assignment in value.all %}
|
||||||
<a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.group_id }} ({{ assignment.group.get_protocol_display }})</a>
|
<a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.get_protocol_display }}: {{ assignment.group.group_id }}</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
@ -138,6 +138,7 @@ class FHRPGroupViewSet(CustomFieldModelViewSet):
|
|||||||
queryset = FHRPGroup.objects.prefetch_related('ip_addresses', 'tags')
|
queryset = FHRPGroup.objects.prefetch_related('ip_addresses', 'tags')
|
||||||
serializer_class = serializers.FHRPGroupSerializer
|
serializer_class = serializers.FHRPGroupSerializer
|
||||||
filterset_class = filtersets.FHRPGroupFilterSet
|
filterset_class = filtersets.FHRPGroupFilterSet
|
||||||
|
brief_prefetch_fields = ('ip_addresses',)
|
||||||
|
|
||||||
|
|
||||||
class FHRPGroupAssignmentViewSet(CustomFieldModelViewSet):
|
class FHRPGroupAssignmentViewSet(CustomFieldModelViewSet):
|
||||||
|
@ -56,7 +56,17 @@ class FHRPGroup(PrimaryModel):
|
|||||||
verbose_name = 'FHRP group'
|
verbose_name = 'FHRP group'
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.get_protocol_display()} group {self.group_id}'
|
name = f'{self.get_protocol_display()}: {self.group_id}'
|
||||||
|
|
||||||
|
# Append the list of assigned IP addresses to serve as an additional identifier
|
||||||
|
if self.pk:
|
||||||
|
ip_addresses = [
|
||||||
|
str(ip.address) for ip in self.ip_addresses.all()
|
||||||
|
]
|
||||||
|
if ip_addresses:
|
||||||
|
return f"{name} ({', '.join(ip_addresses)})"
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('ipam:fhrpgroup', args=[self.pk])
|
return reverse('ipam:fhrpgroup', args=[self.pk])
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
{% load plugins %}
|
{% load plugins %}
|
||||||
{% load render_table from django_tables2 %}
|
{% load render_table from django_tables2 %}
|
||||||
|
|
||||||
|
{# Omit assigned IP addresses from object representation #}
|
||||||
|
{% block title %}{{ object.get_protocol_display }}: {{ object.group_id }}{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumbs %}
|
{% block breadcrumbs %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<li class="breadcrumb-item"><a href="{% url 'ipam:fhrpgroup_list' %}?protocol={{ object.protocol }}">{{ object.get_protocol_display }}</a></li>
|
<li class="breadcrumb-item"><a href="{% url 'ipam:fhrpgroup_list' %}?protocol={{ object.protocol }}">{{ object.get_protocol_display }}</a></li>
|
||||||
|
Reference in New Issue
Block a user