diff --git a/server.py b/server.py index 04dd688..c0f865c 100644 --- a/server.py +++ b/server.py @@ -582,6 +582,11 @@ def page_net_add(): if request.method == 'GET': return render_template("net/add.htm", type="net", user=session["username"]) else: + try: + int(request.form["subnet"]) + except ValueError: + return render_template("error.htm", error="Il campo Subnet deve contenere il numero di bit della subnet. " + "(8, 16, 24...)") nuovonet = Rete(nome=request.form["nome"], network_ip=request.form["network_ip"], subnet=request.form["subnet"], primary_dns=request.form["primary_dns"], secondary_dns=request.form["secondary_dns"]) db.session.add(nuovonet) @@ -626,6 +631,25 @@ def page_net_details(nid): user=session["username"]) +@app.route('/net_show/', methods=['GET', 'POST']) +def page_net_show(nid): + if 'username' not in session: + return abort(403) + if request.method == 'GET': + net = Rete.query.filter_by(nid=nid).first_or_404() + return render_template("net/show.htm", net=net, type="net", user=session["username"]) + else: + net = Rete.query.filter_by(nid=nid).first_or_404() + net.nome = request.form['nome'] + net.network_ip = request.form['network_ip'] + net.subnet = request.form['subnet'] + net.primary_dns = request.form['primary_dns'] + net.secondary_dns = request.form['secondary_dns'] + db.session.commit() + return redirect(url_for('page_net_list')) + + + @app.route('/user_list') def page_user_list(): """Pagina di elenco degli utenti che possono connettersi al sito. diff --git a/templates/dispositivo/details.htm b/templates/dispositivo/details.htm index bfa5cc1..81d275c 100644 --- a/templates/dispositivo/details.htm +++ b/templates/dispositivo/details.htm @@ -88,9 +88,7 @@ - - + + Modifica {% endblock %} \ No newline at end of file diff --git a/templates/net/details.htm b/templates/net/details.htm index 7869f20..6a7ac6f 100644 --- a/templates/net/details.htm +++ b/templates/net/details.htm @@ -40,14 +40,10 @@ - - + + Modifica - - + + Elimina {% endblock %} \ No newline at end of file diff --git a/templates/net/list.htm b/templates/net/list.htm index 2b651a7..584b7cd 100644 --- a/templates/net/list.htm +++ b/templates/net/list.htm @@ -14,16 +14,18 @@ Nome Rete IP Ispeziona + Modifica Elimina - - {% for rete in reti %} + {% for rete in reti %} + {{ rete.nome }} {{ rete.network_ip }}/{{ rete.subnet }} - {% if reti|length > 2 %}{% endif %} - {% endfor %} - + + {% if reti|length > 1 %}{% endif %} + + {% endfor %} {% endblock %} diff --git a/templates/net/show.htm b/templates/net/show.htm new file mode 100644 index 0000000..d79ecfc --- /dev/null +++ b/templates/net/show.htm @@ -0,0 +1,15 @@ +{% extends "base.htm" %} +{% block title %}Aggiungi rete • estus{% endblock %} +{% block content %} +

+ Aggiungi nuova rete +

+
+ + + + + + +
+{% endblock %}