mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 19:33:11 +00:00
Supprime les machines orphelines
This commit is contained in:
parent
e95d3ec8c5
commit
e1844a5ab6
4 changed files with 54 additions and 1 deletions
|
@ -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))
|
||||
|
|
19
topologie/migrations/0022_auto_20161211_1622.py
Normal file
19
topologie/migrations/0022_auto_20161211_1622.py
Normal 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')]),
|
||||
),
|
||||
]
|
29
users/migrations/0042_auto_20161126_2028.py
Normal file
29
users/migrations/0042_auto_20161126_2028.py
Normal 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),
|
||||
),
|
||||
]
|
Loading…
Reference in a new issue