mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 00:13:12 +00:00
Mass delete machine intelligent function
This commit is contained in:
parent
6e569566ed
commit
986cdcd90a
2 changed files with 11 additions and 1 deletions
|
@ -224,6 +224,16 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
|
||||||
"""Return a name : user provided name or first interface name"""
|
"""Return a name : user provided name or first interface name"""
|
||||||
return self.name or self.short_name
|
return self.name or self.short_name
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def mass_delete(cls, machine_queryset):
|
||||||
|
"""Mass delete for machine queryset"""
|
||||||
|
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)
|
||||||
|
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)._raw_delete(machine_queryset.db)
|
||||||
|
machine_queryset._raw_delete(machine_queryset.db)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def all_complete_names(self):
|
def all_complete_names(self):
|
||||||
"""Renvoie tous les tls complets de la machine"""
|
"""Renvoie tous les tls complets de la machine"""
|
||||||
|
|
|
@ -576,7 +576,7 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser,
|
||||||
def mass_delete_data(cls, queryset_users):
|
def mass_delete_data(cls, queryset_users):
|
||||||
"""This users will be completely archived, so only keep mandatory data"""
|
"""This users will be completely archived, so only keep mandatory data"""
|
||||||
cls.mass_disable_email(queryset_users)
|
cls.mass_disable_email(queryset_users)
|
||||||
Machine.objects.filter(user__in=queryset_users).delete()
|
Machine.mass_delete(Machine.objects.filter(user__in=queryset_users))
|
||||||
cls.ldap_delete_users(queryset_users)
|
cls.ldap_delete_users(queryset_users)
|
||||||
|
|
||||||
def disable_email(self):
|
def disable_email(self):
|
||||||
|
|
Loading…
Reference in a new issue