File tree Expand file tree Collapse file tree 5 files changed +17
-2
lines changed
Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 2424* [ #7768 ] ( https://github.com/netbox-community/netbox/issues/7768 ) - Validate IP address status when creating a new FHRP group
2525* [ #7771 ] ( https://github.com/netbox-community/netbox/issues/7771 ) - Group assignment should be optional when creating contacts via REST API
2626* [ #7849 ] ( https://github.com/netbox-community/netbox/issues/7849 ) - Fix exception when creating an FHRPGroup with an invalid IP address
27+ * [ #7880 ] ( https://github.com/netbox-community/netbox/issues/7880 ) - Include assigned IP addresses in FHRP group object representation
2728
2829### REST API Changes
2930
Original file line number Diff line number Diff line change 5353INTERFACE_FHRPGROUPS = """
5454<div class="table-badge-group">
5555 {% for assignment in value.all %}
56- <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.group_id }} ( {{ assignment.group.get_protocol_display }}) </a>
56+ <a href="{{ assignment.group.get_absolute_url }}">{{ assignment.group.get_protocol_display }}: {{ assignment.group.group_id }}</a>
5757 {% endfor %}
5858</div>
5959"""
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ class FHRPGroupViewSet(CustomFieldModelViewSet):
138138 queryset = FHRPGroup .objects .prefetch_related ('ip_addresses' , 'tags' )
139139 serializer_class = serializers .FHRPGroupSerializer
140140 filterset_class = filtersets .FHRPGroupFilterSet
141+ brief_prefetch_fields = ('ip_addresses' ,)
141142
142143
143144class FHRPGroupAssignmentViewSet (CustomFieldModelViewSet ):
Original file line number Diff line number Diff line change @@ -56,7 +56,17 @@ class Meta:
5656 verbose_name = 'FHRP group'
5757
5858 def __str__ (self ):
59- return f'{ self .get_protocol_display ()} group { self .group_id } '
59+ name = f'{ self .get_protocol_display ()} : { self .group_id } '
60+
61+ # Append the list of assigned IP addresses to serve as an additional identifier
62+ if self .pk :
63+ ip_addresses = [
64+ str (ip .address ) for ip in self .ip_addresses .all ()
65+ ]
66+ if ip_addresses :
67+ return f"{ name } ({ ', ' .join (ip_addresses )} )"
68+
69+ return name
6070
6171 def get_absolute_url (self ):
6272 return reverse ('ipam:fhrpgroup' , args = [self .pk ])
Original file line number Diff line number Diff line change 33{% load plugins %}
44{% load render_table from django_tables2 %}
55
6+ {# Omit assigned IP addresses from object representation #}
7+ {% block title %}{{ object.get_protocol_display }}: {{ object.group_id }}{% endblock %}
8+
69{% block breadcrumbs %}
710 {{ block.super }}
811 < li class ="breadcrumb-item "> < a href ="{% url 'ipam:fhrpgroup_list' %}?protocol={{ object.protocol }} "> {{ object.get_protocol_display }}</ a > </ li >
You can’t perform that action at this time.
0 commit comments