From 9b5f75c7d29df52b945b4ed03e345c2aa2aa88ce Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 12 Sep 2017 12:50:28 +0200 Subject: [PATCH] Part 1 of dev show --- server.py | 46 +++++++++++++++ static/joke.png | Bin 0 -> 1307 bytes templates/dispositivo/show.htm | 104 +++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 static/joke.png create mode 100644 templates/dispositivo/show.htm diff --git a/server.py b/server.py index e184549..8fe40bd 100644 --- a/server.py +++ b/server.py @@ -519,6 +519,52 @@ def page_disp_details(did): user=session["username"]) +@app.route('/disp_show/', methods=['GET', 'POST']) +def page_disp_show(did): + if 'username' not in session: + return redirect(url_for('page_login')) + if request.method == 'GET': + disp = Dispositivo.query.filter_by(did=did).first_or_404() + return render_template("dispositivo/show.htm", disp=disp, accessi=accessi, type="disp", + user=session["username"]) + else: + if request.form["inv_ced"]: + try: + int(request.form["inv_ced"]) + except ValueError: + return render_template("error.htm", error="Il campo Inventario CED deve contenere un numero.") + if request.form["inv_ente"]: + try: + int(request.form["inv_ente"]) + except ValueError: + return render_template("error.htm", error="Il campo Inventario ente deve contenere un numero.") + disp = Dispositivo.query.filter_by(did=did).first_or_404() + disp.tipo = request.form['tipo'] + disp.marca = request.form['marca'] + disp.modello = request.form['modello'] + disp.inv_ced = request.form['inv_ced'] + disp.inv_ente = request.form['inv_ente'] + disp.fornitore = request.form['fornitore'] + disp.rete = request.form['rete'] + db.session.commit() + # Trova tutti gli utenti, edizione sporco hack in html + users = list() + while True: + # Trova tutti gli utenti esistenti + userstring = 'utente{}'.format(len(users)) + if userstring in request.form: + users.append(request.form[userstring]) + else: + break + for user in users: + nuovologin = Accesso(int(user), nuovodisp.did) + db.session.add(nuovologin) + db.session.commit() + # TODO: se un dispositivo non ha utenti si incasina parecchio + return redirect(url_for('page_disp_list')) + + + @app.route('/net_add', methods=['GET', 'POST']) def page_net_add(): """Pagina di creazione nuova rete: diff --git a/static/joke.png b/static/joke.png new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h+Moa5-yYl%pg267l9CenUq(-xCYzIMYHBd2*2vanX|r%m39;+kfFtWER(}~O zOArKHQO74T#r3z>q`aQg>`t+uc#U?e*^Iy|cIR{xc$puseYzJ~^Va&APs(>A6@j@R$3u7>C51JBO6|j?#ljB~S za(`(F)axr})x{)6+vw`!(6x{{VkfAmz5A Rp!5I$002ovPDHLkV1i$4b6Wra literal 0 HcmV?d00001 diff --git a/templates/dispositivo/show.htm b/templates/dispositivo/show.htm new file mode 100644 index 0000000..d464f1e --- /dev/null +++ b/templates/dispositivo/show.htm @@ -0,0 +1,104 @@ +{% extends "base.htm" %} +{% block extrahead %} + + +{% endblock %} +{% block content %} +

+ Modifica dispositivo +

+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+{% endblock %} \ No newline at end of file