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 @@
{{ rete.nome }} | {{ rete.network_ip }}/{{ rete.subnet }} | - | {% if not rete.network_ip == "0.0.0.0" %}{% endif %} | +{% if reti|length > 2 %}{% endif %} | {% endfor %}