Commit e8e93ed4 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Supprime les machines orphelines

parent fc7f1ddb
......@@ -137,5 +137,7 @@ def interface_post_save(sender, **kwargs):
@receiver(post_delete, sender=Interface)
def interface_post_delete(sender, **kwargs):
user = kwargs['instance'].machine.user
interface = kwargs['instance']
user = interface.machine.user
user.ldap_sync(base=False, access_refresh=False, mac_refresh=True)
......@@ -217,8 +217,11 @@ def del_interface(request, interfaceid):
messages.error(request, "Vous ne pouvez pas éditer une machine d'un autre user que vous sans droit")
return redirect("/users/profil/" + str(request.user.id))
if request.method == "POST":
machine = interface.machine
with transaction.atomic(), reversion.create_revision():
interface.delete()
if not machine.interface_set.all():
machine.delete()
reversion.set_user(request.user)
messages.success(request, "L'interface a été détruite")
return redirect("/users/profil/" + str(request.user.id))
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('topologie', '0021_port_radius'),
]
operations = [
migrations.AlterField(
model_name='port',
name='radius',
field=models.CharField(max_length=32, default='NO', choices=[('NO', 'NO'), ('STRICT', 'STRICT'), ('BLOQ', 'BLOQ'), ('COMMON', 'COMMON'), ('7', '7'), ('8', '8'), ('42', '42'), ('69', '69')]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('users', '0041_listright_details'),
]
operations = [
migrations.AlterField(
model_name='ldapserviceuser',
name='dn',
field=models.CharField(serialize=False, primary_key=True, max_length=200),
),
migrations.AlterField(
model_name='ldapuser',
name='dn',
field=models.CharField(serialize=False, primary_key=True, max_length=200),
),
migrations.AlterField(
model_name='ldapusergroup',
name='dn',
field=models.CharField(serialize=False, primary_key=True, max_length=200),
),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment