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

Add Unione Terre di Castelli and User config

This commit is contained in:
Lorenzo 2017-09-12 10:48:21 +02:00
parent ba83b60907
commit 4ad4f7b926
8 changed files with 74 additions and 3 deletions

View file

@ -204,6 +204,7 @@ def page_dashboard():
enti = Ente.query.all() enti = Ente.query.all()
conteggioservizi = dict() conteggioservizi = dict()
goldfish = url_for("static", filename="goldfish.png") goldfish = url_for("static", filename="goldfish.png")
terredicastello = url_for("static", filename="UTdClogo.png")
for ente in enti: for ente in enti:
conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count() conteggioservizi[ente.nomeente] = Servizio.query.join(Ente).filter_by(eid=ente.eid).count()
conteggioutenti = dict() conteggioutenti = dict()
@ -211,7 +212,7 @@ def page_dashboard():
conteggioutenti[ente.nomeente] = Impiegato.query.join(Servizio).join(Ente).filter_by(eid=ente.eid).count() conteggioutenti[ente.nomeente] = Impiegato.query.join(Servizio).join(Ente).filter_by(eid=ente.eid).count()
css = url_for("static", filename="style.css") css = url_for("static", filename="style.css")
return render_template("dashboard.htm", css=css, type="main", user=session["username"], 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']) @app.route('/ente_add', methods=['GET', 'POST'])
@ -525,6 +526,41 @@ def page_net_details(nid):
user=session["username"]) 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/<int:uid>')
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 __name__ == "__main__":
if not os.path.isfile("data.db"): if not os.path.isfile("data.db"):
db.create_all() db.create_all()

BIN
static/UTdClogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -1,6 +1,7 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block title %}Dashboard - Estus{% endblock %} {% block title %}Dashboard - Estus{% endblock %}
{% block content %} {% block content %}
<center> <img src="{{terredicastello}}"> </center>
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<h2> <h2>
@ -29,4 +30,5 @@
</ul> </ul>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -89,7 +89,7 @@
<div class="col-xs-10"> <div class="col-xs-10">
<select id="form-rete" class="form-control" name="rete"> <select id="form-rete" class="form-control" name="rete">
{% for rete in reti %} {% for rete in reti %}
<option value="{{ rete.nid }}">{{ rete.nome }} - {{ rete.ip }}</option> <option value="{{ rete.nid }}">{{ rete.nome }} - {{ rete.network_ip }}/{{ rete.subnet }}</option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>

View file

@ -76,7 +76,7 @@
Network Network
</h4> </h4>
<div class="list-group-item-text"> <div class="list-group-item-text">
<a href="/net_details/{{ disp.rete.nid }}"><code>{{ disp.rete.nome }} - {{ disp.rete.ip }}</code></a> <a href="/net_details/{{ disp.rete.nid }}"><code>{{ disp.rete.nome }} - {{ disp.rete.network_ip }}/{{ disp.rete.subnet }}</code></a>
</div> </div>
</li> </li>
</ul> </ul>

View file

@ -14,6 +14,7 @@
<li class="{% if type is equalto "imp" %}active{% endif %}"><a href="/imp_list">Impiegati</a></li> <li class="{% if type is equalto "imp" %}active{% endif %}"><a href="/imp_list">Impiegati</a></li>
<li class="{% if type is equalto "disp" %}active{% endif %}"><a href="/disp_list">Dispositivi</a></li> <li class="{% if type is equalto "disp" %}active{% endif %}"><a href="/disp_list">Dispositivi</a></li>
<li class="{% if type is equalto "net" %}active{% endif %}"><a href="/net_list">Reti</a></li> <li class="{% if type is equalto "net" %}active{% endif %}"><a href="/net_list">Reti</a></li>
<li class="{% if type is equalto "user" %}active{% endif %}"><a href="/user_list">Utenti</a></li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<p class="navbar-text"> <p class="navbar-text">

11
templates/user/add.htm Normal file
View file

@ -0,0 +1,11 @@
{% extends "base.htm" %}
{% block content %}
<h1>
Aggiunta nuovo utente dell'inventario
</h1>
<form class="form-inline" action="/user_add" method="post">
<input class="form-control" type="text" placeholder="Nome utente" name="username">
<input class="form-control" type="password" placeholder="Password" name="passwd">
<input class="btn btn-primary" type="submit">
</form>
{% endblock %}

21
templates/user/list.htm Normal file
View file

@ -0,0 +1,21 @@
{% extends "base.htm" %}
{% block content %}
<h1>
Utenti dell'inventario esistenti
</h1>
<table class="table table-hover">
<thead>
<tr>
<th>Nome utente</th>
<th>Elimina</th>
</tr>
</thead>
<tr>
{% for utente in utenti %}
<td>{{ utente.username }}</td>
<td>{% if utenti|length >= 2 %}<a href="/user_del/{{ utente.uid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
</tr>
{% endfor %}
</table>
<a class="btn btn-success" href="/user_add">Aggiungi</a>
{% endblock %}