1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-21 23:24:18 +00:00

Some more bugfixes about the default network

This commit is contained in:
Steffo 2017-09-13 10:53:29 +02:00
parent 9ca51a03ad
commit a9b1db699a
3 changed files with 14 additions and 2 deletions

View file

@ -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'))

View file

@ -42,7 +42,12 @@
</ul>
<a href="/net_show/{{ net.nid }}">
<button type="button" class="btn btn-primary">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Modifica
<span class="glyphicon glyphicon-pencil"></span> Modifica
</button>
</a>
<a href="/net_del/{{ net.nid }}">
<button type="button" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span> Elimina
</button>
</a>
{% endblock %}

View file

@ -4,6 +4,9 @@
<h1>
Reti esistenti
</h1>
<div class="alert alert-info">
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.
</div>
<a class="btn btn-success" href="/net_add"><span class="glyphicon glyphicon-plus"></span> Aggiungi</a>
<table class="table table-hover">
<thead>
@ -19,7 +22,7 @@
<td>{{ rete.nome }}</td>
<td>{{ rete.network_ip }}/{{ rete.subnet }}</td>
<td><a href="/net_details/{{ rete.nid }}"><span class="glyphicon glyphicon-list-alt"></span></a></td>
<td>{% if not rete.network_ip == "0.0.0.0" %}<a href="/net_del/{{ rete.nid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
<td>{% if reti|length > 2 %}<a href="/net_del/{{ rete.nid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
{% endfor %}
</tr>
</table>