mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-21 03:27:21 -06:00
Limit inherited contacts to model
This commit is contained in:
parent
72adda1197
commit
ca6b686b88
@ -373,16 +373,14 @@ class ContactsMixin(models.Model):
|
|||||||
from tenancy.models import ContactAssignment
|
from tenancy.models import ContactAssignment
|
||||||
from . import NestedGroupModel
|
from . import NestedGroupModel
|
||||||
|
|
||||||
filter = Q()
|
filter = Q(
|
||||||
for obj in [self]:
|
object_type=ObjectType.objects.get_for_model(self),
|
||||||
filter |= Q(
|
object_id__in=(
|
||||||
object_type=ObjectType.objects.get_for_model(obj),
|
self.get_ancestors(include_self=True).values_list('pk', flat=True)
|
||||||
object_id__in=(
|
if (isinstance(self, NestedGroupModel) and inherited)
|
||||||
obj.get_ancestors(include_self=True).values_list('pk', flat=True)
|
else [self.pk]
|
||||||
if (isinstance(obj, NestedGroupModel) and inherited)
|
),
|
||||||
else [obj.pk]
|
)
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
return ContactAssignment.objects.filter(filter)
|
return ContactAssignment.objects.filter(filter)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user