|
@@ -30,13 +30,12 @@ class IPResourceManager(models.Manager):
|
|
|
def get_queryset(self):
|
|
|
qs = super().get_queryset()
|
|
|
# On rajoute une super annotation « in_use » pour savoir si l’IP est dispo ou non :-)
|
|
|
- query = Q(resource=models.OuterRef('pk')) & get_active_filter()
|
|
|
qs = qs.annotate(
|
|
|
in_use_by_service=models.Exists(
|
|
|
- ServiceAllocation.objects.filter(query)
|
|
|
+ ServiceAllocation.actives.filter(resource=models.OuterRef('pk'), active=True)
|
|
|
),
|
|
|
in_use_by_antenna=models.Exists(
|
|
|
- AntennaAllocation.objects.filter(query)
|
|
|
+ ServiceAllocation.actives.filter(resource=models.OuterRef('pk'), active=True)
|
|
|
)
|
|
|
)
|
|
|
qs = qs.annotate(
|