From a9b1db699a1b9275012f2ae64ca71f189f5e16fa Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 13 Sep 2017 10:53:29 +0200 Subject: [PATCH] Some more bugfixes about the default network --- server.py | 4 ++++ templates/net/details.htm | 7 ++++++- templates/net/list.htm | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 6c09653..04dd688 100644 --- a/server.py +++ b/server.py @@ -598,6 +598,10 @@ def page_net_del(nid): if Rete.query.count() <= 1: return render_template("error.htm", error="Non puoi cancellare l'ultima rete rimasta!") rete = Rete.query.get_or_404(nid) + defaultrete = Rete.query.filter_by(network_ip="0.0.0.0").first() + dispositivi = Dispositivo.query.filter_by(nid=rete.nid).all() + for dispositivo in dispositivi: + dispositivo.nid = defaultrete.nid db.session.delete(rete) db.session.commit() return redirect(url_for('page_net_list')) diff --git a/templates/net/details.htm b/templates/net/details.htm index d539edf..7869f20 100644 --- a/templates/net/details.htm +++ b/templates/net/details.htm @@ -42,7 +42,12 @@ + + + {% endblock %} \ No newline at end of file diff --git a/templates/net/list.htm b/templates/net/list.htm index ee241f4..2b651a7 100644 --- a/templates/net/list.htm +++ b/templates/net/list.htm @@ -4,6 +4,9 @@

Reti esistenti

+
+ La rete con IP 0.0.0.0 sarĂ  usata come rete di default durante l'eliminazione di altre reti con dispositivi assegnati. Cancellarla potrebbe avere effetti indesiderati. +
Aggiungi @@ -19,7 +22,7 @@ - + {% endfor %}
{{ rete.nome }} {{ rete.network_ip }}/{{ rete.subnet }} {% if not rete.network_ip == "0.0.0.0" %}{% endif %}{% if reti|length > 2 %}{% endif %}