From 95486e46ead3d9dc1de4175e9ddff2e806f6f6b0 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 2 May 2023 09:29:48 -0500 Subject: [PATCH 1/2] Fixes: #11715 - Fix Parent Prefix table display of global vrf prefixes that are **not** containers. --- netbox/ipam/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index a49c4aab3de..a9f65018de1 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -14,6 +14,7 @@ from virtualization.filtersets import VMInterfaceFilterSet from virtualization.models import VMInterface from . import filtersets, forms, tables +from .choices import PrefixStatusChoices from .constants import * from .models import * from .tables.l2vpn import L2VPNTable, L2VPNTerminationTable @@ -495,7 +496,7 @@ def get_extra_context(self, request, instance): # Parent prefixes table parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter( - Q(vrf=instance.vrf) | Q(vrf__isnull=True) + Q(vrf=instance.vrf) | Q(Q(vrf__isnull=True) & Q(status=PrefixStatusChoices.STATUS_CONTAINER)) ).filter( prefix__net_contains=str(instance.prefix) ).prefetch_related( From bfe7e0e9b68607ed4122f1a99bace7ff818577d5 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Thu, 4 May 2023 14:36:16 -0500 Subject: [PATCH 2/2] Combine AND into a single Q object Co-authored-by: Jeremy Stretch --- netbox/ipam/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/ipam/views.py b/netbox/ipam/views.py index a9f65018de1..93d0dc8bb1e 100644 --- a/netbox/ipam/views.py +++ b/netbox/ipam/views.py @@ -496,7 +496,7 @@ def get_extra_context(self, request, instance): # Parent prefixes table parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter( - Q(vrf=instance.vrf) | Q(Q(vrf__isnull=True) & Q(status=PrefixStatusChoices.STATUS_CONTAINER)) + Q(vrf=instance.vrf) | Q(vrf__isnull=True, status=PrefixStatusChoices.STATUS_CONTAINER) ).filter( prefix__net_contains=str(instance.prefix) ).prefetch_related(