diff --git a/server.py b/server.py index 7f796e0..ba28a82 100644 --- a/server.py +++ b/server.py @@ -204,6 +204,7 @@ def page_dashboard(): enti = Ente.query.all() conteggioservizi = dict() goldfish = url_for("static", filename="goldfish.png") + terredicastello = url_for("static", filename="UTdClogo.png") for ente in enti: conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count() conteggioutenti = dict() @@ -211,7 +212,7 @@ def page_dashboard(): conteggioutenti[ente.nomeente] = Impiegato.query.join(Servizio).join(Ente).filter_by(eid=ente.eid).count() css = url_for("static", filename="style.css") return render_template("dashboard.htm", css=css, type="main", user=session["username"], - conteggioutenti=conteggioutenti, conteggioservizi=conteggioservizi, goldfish=goldfish) + conteggioutenti=conteggioutenti, conteggioservizi=conteggioservizi, goldfish=goldfish, terredicastello=terredicastello) @app.route('/ente_add', methods=['GET', 'POST']) @@ -525,6 +526,41 @@ def page_net_details(nid): user=session["username"]) +@app.route('/user_list') +def page_user_list(): + if 'username' not in session: + return redirect(url_for('page_login')) + utenti = User.query.all() + css = url_for("static", filename="style.css") + return render_template("user/list.htm", css=css, utenti=utenti, type="user", user=session["username"]) + + +@app.route('/user_del/') +def page_user_del(uid): + if 'username' not in session: + return redirect(url_for('page_login')) + utente = User.query.get(uid) + db.session.delete(utente) + db.session.commit() + return redirect(url_for('page_user_list')) + + +@app.route('/user_add', methods=['GET', 'POST']) +def page_user_add(): + if 'username' not in session: + return redirect(url_for('page_login')) + if request.method == 'GET': + css = url_for("static", filename="style.css") + return render_template("user/add.htm", css=css, type="user", user=session["username"]) + else: + p = bytes(request.form["passwd"], encoding="utf-8") + cenere = bcrypt.hashpw(p, bcrypt.gensalt()) + nuovo = User(request.form['username'], cenere) + db.session.add(nuovo) + db.session.commit() + return redirect(url_for('page_user_list')) + + if __name__ == "__main__": if not os.path.isfile("data.db"): db.create_all() diff --git a/static/UTdClogo.png b/static/UTdClogo.png new file mode 100644 index 0000000..4fef1f7 Binary files /dev/null and b/static/UTdClogo.png differ diff --git a/templates/dashboard.htm b/templates/dashboard.htm index 6fe4d6a..1f7f1a3 100644 --- a/templates/dashboard.htm +++ b/templates/dashboard.htm @@ -1,6 +1,7 @@ {% extends "base.htm" %} {% block title %}Dashboard - Estus{% endblock %} {% block content %} +

@@ -29,4 +30,5 @@

+ {% endblock %} \ No newline at end of file diff --git a/templates/dispositivo/add.htm b/templates/dispositivo/add.htm index 0f39513..03699bc 100644 --- a/templates/dispositivo/add.htm +++ b/templates/dispositivo/add.htm @@ -89,7 +89,7 @@
diff --git a/templates/dispositivo/details.htm b/templates/dispositivo/details.htm index 5880fdb..bd4d7e4 100644 --- a/templates/dispositivo/details.htm +++ b/templates/dispositivo/details.htm @@ -76,7 +76,7 @@ Network
- {{ disp.rete.nome }} - {{ disp.rete.ip }} + {{ disp.rete.nome }} - {{ disp.rete.network_ip }}/{{ disp.rete.subnet }}
diff --git a/templates/nav.htm b/templates/nav.htm index a1d9e13..b8b11da 100644 --- a/templates/nav.htm +++ b/templates/nav.htm @@ -14,6 +14,7 @@
  • Impiegati
  • Dispositivi
  • Reti
  • +
  • Utenti