diff --git a/server.py b/server.py index 414571a..80a96ad 100644 --- a/server.py +++ b/server.py @@ -96,7 +96,15 @@ def page_login(): @app.route('/dashboard') def page_dashboard(): - return "Buongiornissimo {}".format(session['username']) + enti = Ente.query.all() + conteggioservizi = dict() + for ente in enti: + conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count() + conteggioutenti = dict() + for ente in enti: + 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.html.j2", css=css, type="main", user=session["username"], conteggioutenti=conteggioutenti, conteggioservizi=conteggioservizi) @app.route('/ente_add', methods=['GET', 'POST']) def page_ente_add(): @@ -104,7 +112,7 @@ def page_ente_add(): return redirect(url_for('page_login')) if request.method == 'GET': css = url_for("static", filename="style.css") - return render_template("ente/add.html.j2", css=css, type="ente") + return render_template("ente/add.html.j2", css=css, type="ente", user=session["username"]) else: nuovoent = Ente(request.form['nomeente'], request.form['nomebreveente']) db.session.add(nuovoent) diff --git a/templates/dashboard.html.j2 b/templates/dashboard.html.j2 new file mode 100644 index 0000000..2c82de0 --- /dev/null +++ b/templates/dashboard.html.j2 @@ -0,0 +1,43 @@ + + + Elenco enti - Inventario + + + + + {% include 'nav.html.j2' %} +
+
+
+

+ Servizi per ente +

+
    + {% for ente in conteggioservizi %} +
  • + {{ente}} + {{conteggioservizi[ente]}} +
  • + {% endfor %} +
+
+
+

+ Utenti per ente +

+
    + {% for ente in conteggioutenti %} +
  • + {{ente}} + {{conteggioutenti[ente]}} +
  • + {% endfor %} +
+
+
+ Destra +
+
+
+ + diff --git a/templates/login.html.j2 b/templates/login.html.j2 index 944480b..e4b8033 100644 --- a/templates/login.html.j2 +++ b/templates/login.html.j2 @@ -5,6 +5,7 @@ + {% include 'nav.html.j2' %}

Login diff --git a/templates/nav.html.j2 b/templates/nav.html.j2 index 83a03db..262fb26 100644 --- a/templates/nav.html.j2 +++ b/templates/nav.html.j2 @@ -1,18 +1,24 @@