diff --git a/topologie/models.py b/topologie/models.py
index 57f66901..8640e6fc 100644
--- a/topologie/models.py
+++ b/topologie/models.py
@@ -40,7 +40,7 @@ from __future__ import unicode_literals
import itertools
from django.db import models
-from django.db.models.signals import post_save, post_delete
+from django.db.models.signals import pre_save, post_save, post_delete
from django.utils.functional import cached_property
from django.dispatch import receiver
from django.core.exceptions import ValidationError
@@ -51,6 +51,9 @@ from reversion import revisions as reversion
from machines.models import Machine, regen
from re2o.mixins import AclMixin, RevMixin
+from os.path import isfile
+from os import remove
+
@@ -106,6 +109,12 @@ class AccessPoint(AclMixin, Machine):
("view_accesspoint", "Peut voir une borne"),
)
+ def port(self):
+ """Return the queryset of ports for this device"""
+ return Port.objects.filter(
+ machine_interface__machine=self
+ )
+
def switch(self):
"""Return the switch where this is plugged"""
return Switch.objects.filter(
@@ -137,6 +146,12 @@ class Server(Machine):
class Meta:
proxy = True
+ def port(self):
+ """Return the queryset of ports for this device"""
+ return Port.objects.filter(
+ machine_interface__machine=self
+ )
+
def switch(self):
"""Return the switch where this is plugged"""
return Switch.objects.filter(
@@ -489,3 +504,14 @@ def ap_post_delete(**_kwargs):
def stack_post_delete(**_kwargs):
"""Vide les id des switches membres d'une stack supprimée"""
Switch.objects.filter(stack=None).update(stack_member_id=None)
+
+#@receiver(post_save, sender=Port)
+#@receiver(post_save, sender=AccessPoint)
+#@receiver(post_save, sender=ModelSwitch)
+#@receiver(post_save, sender=Building)
+#@receiver(post_save, sender=Building)
+#@receiver(post_save, sender=Server)
+@receiver(pre_save, sender=Switch)
+def delete_graph(**_kwargs):
+ if isfile("media/images/switchs.png"):
+ remove("media/images/switchs.png")
diff --git a/topologie/templates/topologie/graph_switch.dot b/topologie/templates/topologie/graph_switch.dot
index 2529e739..bf638d70 100644
--- a/topologie/templates/topologie/graph_switch.dot
+++ b/topologie/templates/topologie/graph_switch.dot
@@ -12,8 +12,9 @@ fontsize=15;
label="Batiment {{ sub.bat_name }}";
{% if sub.bornes %}
+{% block bornes %}
node [label=<
-
+
Borne |
@@ -22,8 +23,6 @@ node [label=<
Port |
-
-{% block bornes %}
{% for borne in sub.bornes %}
@@ -37,9 +36,15 @@ node [label=<
|
{% endfor %}
+
+>] {{sub.bat_name}}bornes;
{% endblock %}
+{% endif %}
{% if sub.machines %}
+{% block machines %}
+node [label=<
+
Machine |
@@ -62,10 +67,9 @@ node [label=<
{% endfor %}
-{% endif %}
-
->] {{sub.bat_name}}bornes;
+>] {{sub.bat_name}}machines;
+{% endblock %}
{% endif %}