8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-27 09:23:47 +00:00

Fix mass_delete of machine so that AccessPoint deletion is possible.

This commit is contained in:
Hugo Levy-Falk 2019-09-29 17:57:10 +02:00 committed by chirac
parent 1ec299037e
commit e1575c09d4

View file

@ -258,11 +258,13 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
@classmethod @classmethod
def mass_delete(cls, machine_queryset): def mass_delete(cls, machine_queryset):
"""Mass delete for machine queryset""" """Mass delete for machine queryset"""
from topologie.models import AccessPoint
Domain.objects.filter(cname__interface_parent__machine__in=machine_queryset)._raw_delete(machine_queryset.db) Domain.objects.filter(cname__interface_parent__machine__in=machine_queryset)._raw_delete(machine_queryset.db)
Domain.objects.filter(interface_parent__machine__in=machine_queryset)._raw_delete(machine_queryset.db) Domain.objects.filter(interface_parent__machine__in=machine_queryset)._raw_delete(machine_queryset.db)
Ipv6List.objects.filter(interface__machine__in=machine_queryset)._raw_delete(machine_queryset.db) Ipv6List.objects.filter(interface__machine__in=machine_queryset)._raw_delete(machine_queryset.db)
Interface.objects.filter(machine__in=machine_queryset).filter(port_lists__isnull=False).delete() Interface.objects.filter(machine__in=machine_queryset).filter(port_lists__isnull=False).delete()
Interface.objects.filter(machine__in=machine_queryset)._raw_delete(machine_queryset.db) Interface.objects.filter(machine__in=machine_queryset)._raw_delete(machine_queryset.db)
AccessPoint.objects.filter(machine_ptr__in=machine_queryset)._raw_delete(machine_queryset.db)
machine_queryset._raw_delete(machine_queryset.db) machine_queryset._raw_delete(machine_queryset.db)
@cached_property @cached_property