mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
détection de la modification des objects du graph
This commit is contained in:
parent
4f4d10b799
commit
f7a74d3576
2 changed files with 37 additions and 7 deletions
|
@ -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")
|
||||
|
|
|
@ -12,8 +12,9 @@ fontsize=15;
|
|||
label="Batiment {{ sub.bat_name }}";
|
||||
|
||||
{% if sub.bornes %}
|
||||
{% block bornes %}
|
||||
node [label=<
|
||||
<TABLE BGCOLOR="{{ colors.back}}" BORDER="1" COLOR="#021f87" CELLBORDER="0" CELLSPACING="0">
|
||||
<TABLE BGCOLOR="{{ colors.back}}" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR>
|
||||
<TD COLSPAN="2" CELLPADDING="4" ALIGN="CENTER" BGCOLOR="{{ colors.head_bornes }}">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">Borne</FONT></TD>
|
||||
|
@ -22,8 +23,6 @@ node [label=<
|
|||
<TD COLSPAN="2" CELLPADDING="4" ALIGN="CENTER" BGCOLOR="{{ colors.head_bornes }}">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">Port</FONT></TD>
|
||||
</TR>
|
||||
|
||||
{% block bornes %}
|
||||
{% for borne in sub.bornes %}
|
||||
<TR>
|
||||
<TD COLSPAN="2" CELLPADDING="4" ALIGN="CENTER" BORDER="0">
|
||||
|
@ -37,9 +36,15 @@ node [label=<
|
|||
</TD>
|
||||
</TR>
|
||||
{% endfor %}
|
||||
</TABLE>
|
||||
>] {{sub.bat_name}}bornes;
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
{% if sub.machines %}
|
||||
{% block machines %}
|
||||
node [label=<
|
||||
<TABLE BGCOLOR="{{ colors.back}}" BORDER="0" CELLBORDER="0" CELLSPACING="0">
|
||||
<TR>
|
||||
<TD COLSPAN="2" CELLPADDING="4" ALIGN="CENTER" BGCOLOR="{{ colors.head_server }}">
|
||||
<FONT FACE="Helvetica Bold" COLOR="white">Machine</FONT></TD>
|
||||
|
@ -62,10 +67,9 @@ node [label=<
|
|||
</TD>
|
||||
</TR>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</TABLE>
|
||||
>] {{sub.bat_name}}bornes;
|
||||
>] {{sub.bat_name}}machines;
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue