Limit inherited contacts to model

This commit is contained in:
Alexander Haase 2025-02-22 00:06:44 +01:00
parent 72adda1197
commit ca6b686b88

View File

@ -373,14 +373,12 @@ class ContactsMixin(models.Model):
from tenancy.models import ContactAssignment
from . import NestedGroupModel
filter = Q()
for obj in [self]:
filter |= Q(
object_type=ObjectType.objects.get_for_model(obj),
filter = Q(
object_type=ObjectType.objects.get_for_model(self),
object_id__in=(
obj.get_ancestors(include_self=True).values_list('pk', flat=True)
if (isinstance(obj, NestedGroupModel) and inherited)
else [obj.pk]
self.get_ancestors(include_self=True).values_list('pk', flat=True)
if (isinstance(self, NestedGroupModel) and inherited)
else [self.pk]
),
)