8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-24 20:33:11 +00:00

Supprime les machines orphelines

This commit is contained in:
Gabriel Detraz 2016-12-14 18:09:24 +01:00 committed by root
parent fc7f1ddb7f
commit e8e93ed4be
4 changed files with 54 additions and 1 deletions

View file

@ -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)

View file

@ -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))

View file

@ -0,0 +1,19 @@
# -*- 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')]),
),
]

View file

@ -0,0 +1,29 @@
# -*- 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),
),
]