1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-22 15:44:19 +00:00

Tante cose

This commit is contained in:
Lorenzo 2017-09-19 11:28:08 +02:00 committed by Stefano
parent 1df9ba3af2
commit 7b92db202a
5 changed files with 74 additions and 31 deletions

View file

@ -851,8 +851,9 @@ def page_order_list():
"""Pagina di elenco degli ordini registrati nel database.""" """Pagina di elenco degli ordini registrati nel database."""
if 'username' not in session: if 'username' not in session:
return abort(403) return abort(403)
ordini = Ordine.query.order_by(Ordine.data).all() ordini = Ordine.query.order_by(Ordine.data.desc()).all()
return render_template("ordine/list.htm", orders=ordini, pagetype="order", user=session.get("username")) return render_template("ordine/list.htm", orders=ordini, pagetype="order", user=session.get("username"),
today=datetime.date.today(), soon=datetime.date.today() + datetime.timedelta(7))
@app.route('/order_add', methods=['GET', 'POST']) @app.route('/order_add', methods=['GET', 'POST'])
@ -905,14 +906,28 @@ def page_order_show(oid):
return redirect(url_for("page_order_list")) return redirect(url_for("page_order_list"))
@app.route('/order_del/<int:oid>')
def page_order_del(oid):
if 'username' not in session:
return abort(403)
ordine = Ordine.query.get_or_404(oid)
dispositivi = Dispositivo.query.filter_by(oid=oid).all()
for dispositivo in dispositivi:
dispositivo.oid = None
db.session.delete(ordine)
db.session.commit()
return redirect(url_for('page_order_list'))
@app.route('/order_details/<int:oid>') @app.route('/order_details/<int:oid>')
def page_order_details(oid): def page_order_details(oid):
if 'username' not in session: if 'username' not in session:
return abort(403) return abort(403)
ordine = Ordine.query.get_or_404(oid) ordine = Ordine.query.get_or_404(oid)
dispositivi = Dispositivo.query.join(Ordine).filter_by(oid=oid).all() dispositivi = Dispositivo.query.join(Ordine).filter_by(oid=oid).all()
return render_template("ordine/details.htm", dispositivi=dispositivi, pagetype="order", return render_template("ordine/details.htm", dispositivi=dispositivi, pagetype="order", today=datetime.date.today(),
user=session.get("username"), ordine=ordine) user=session.get("username"), ordine=ordine,
soon=datetime.date.today() + datetime.timedelta(7))
@app.route('/query', methods=['GET', 'POST']) @app.route('/query', methods=['GET', 'POST'])
@ -952,6 +967,7 @@ def page_pheesh():
dispositivi = Dispositivo.query.all() dispositivi = Dispositivo.query.all()
reti = Rete.query.all() reti = Rete.query.all()
utenti = User.query.all() utenti = User.query.all()
ordini = Ordine.query.all()
pesci = [] pesci = []
for obj in enti: for obj in enti:
random.seed(hash(obj.nomeente)) random.seed(hash(obj.nomeente))
@ -964,18 +980,16 @@ def page_pheesh():
pesci.append(Pesce(obj, 1.5, 0.4, f"/net_details/{obj.nid}")) pesci.append(Pesce(obj, 1.5, 0.4, f"/net_details/{obj.nid}"))
for obj in impiegati: for obj in impiegati:
random.seed(hash(obj.nomeimpiegato)) random.seed(hash(obj.nomeimpiegato))
pesci.append(Pesce(obj, 1, 0.3, f"/imp_list")) pesci.append(Pesce(obj, 1, 0.3, f"/imp_details/{obj.iid}"))
for obj in dispositivi: for obj in dispositivi:
random.seed(hash(obj.did)) random.seed(hash(obj.did))
if obj.marca != "" and obj.modello != "":
pesci.append(Pesce(obj, 0.8, 0.2, f"/disp_details/{obj.did}"))
elif obj.seriale != "":
pesci.append(Pesce(obj, 0.8, 0.2, f"/disp_details/{obj.did}"))
else:
pesci.append(Pesce(obj, 0.8, 0.2, f"/disp_details/{obj.did}")) pesci.append(Pesce(obj, 0.8, 0.2, f"/disp_details/{obj.did}"))
for obj in utenti: for obj in utenti:
random.seed(hash(obj.username)) random.seed(hash(obj.username))
pesci.append(Pesce(obj, 1.5, 0.1, f"/user_list")) pesci.append(Pesce(obj, 1.5, 0.1, f"/user_list"))
for obj in ordini:
random.seed(hash(obj.numero_ordine))
pesci.append(Pesce(obj, 1.2, 0.4, f"/order_details/{obj.oid}"))
return render_template("pheesh.htm", user=session.get("username"), pheesh=pesci, footer=False) return render_template("pheesh.htm", user=session.get("username"), pheesh=pesci, footer=False)

View file

@ -39,7 +39,7 @@
Ordine Ordine
</h4> </h4>
<div class="list-group-item-text"> <div class="list-group-item-text">
<a href="/order_details/{{ disp.ordine.oid }}">{{ disp.ordine.numero_ordine }}</a> <a href="/order_details/{{ disp.ordine.oid }}">{{ disp.ordine }}</a>
</div> </div>
</li> </li>
{% endif %} {% endif %}
@ -81,7 +81,7 @@
Codice Inventario CED Codice Inventario CED
</h4> </h4>
<div class="list-group-item-text"> <div class="list-group-item-text">
<code>{{ disp.inv_ced }}</code> {{ disp.inv_ced }}
</div> </div>
</li> </li>
{% endif %} {% endif %}

View file

@ -1,10 +1,11 @@
{% extends "base.htm" %} {% extends "base.htm" %}
{% block title %}Dettagli Ordine • estus{% endblock %} {% block title %}Dettagli dell'ordine • estus{% endblock %}
{% block content %} {% block content %}
<h1> <h1>
Dettagli dell'impiegato Dettagli dell'ordine
</h1> </h1>
<ul class="list-group"> <ul class="list-group">
{% if ordine.numero_ordine %}
<li class="list-group-item"> <li class="list-group-item">
<h4 class="list-group-item-heading"> <h4 class="list-group-item-heading">
Numero ordine Numero ordine
@ -13,31 +14,46 @@
{{ ordine.numero_ordine }} {{ ordine.numero_ordine }}
</div> </div>
</li> </li>
{% endif %}
{% if ordine.data %}
<li class="list-group-item"> <li class="list-group-item">
<h4 class="list-group-item-heading"> <h4 class="list-group-item-heading">
Data dell'ordine (AAAA-MM-GG) Data dell'ordine
</h4> </h4>
<div class="list-group-item-text"> <div class="list-group-item-text">
{{ ordine.data }} {{ ordine.data }}
</div> </div>
</li> </li>
{% endif %}
{% if ordine.garanzia %}
<li class="list-group-item"> <li class="list-group-item">
<h4 class="list-group-item-heading"> <h4 class="list-group-item-heading">
Fine garanzia (AAAA-MM-GG) Garanzia
</h4> </h4>
<div class="list-group-item-text"> <div class="list-group-item-text">
<code>{{ ordine.garanzia }}</code> {% if ordine.garanzia > soon %}
<span class="label label-success">Valida</span>
{% elif ordine.garanzia > today %}
<span class="label label-warning">In scadenza</span>
{% else %}
<span class="label label-danger">Scaduta</span>
{% endif %}
{{ ordine.garanzia }}
</div> </div>
</li> </li>
{% endif %}
{% if dispositivi %}
<li class="list-group-item"> <li class="list-group-item">
<h4 class="list-group-item-heading"> <h4 class="list-group-item-heading">
Dispositivi associati Dispositivi associati
</h4> </h4>
<div class="list-group-item-text"> <div class="list-group-item-text">
{% for dispositivo in dispositivi %} <a href="/disp_details/{{ dispositivo.did }}">{{ dispositivo.tipo }}</a> <br>{% endfor %} {% for dispositivo in dispositivi %} <a href="/disp_details/{{ dispositivo.did }}">{{ dispositivo }}</a> <br>{% endfor %}
</div> </div>
</li>
{% endif %}
</ul> </ul>
<a href="/ordine_show/{{ ordine.iid }}" class="btn btn-primary"> <a href="/ordine_show/{{ ordine.oid }}" class="btn btn-primary">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Modifica <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Modifica
</a> </a>
{% endblock %} {% endblock %}

View file

@ -10,6 +10,7 @@
<tr> <tr>
<th>Data dell'ordine</th> <th>Data dell'ordine</th>
<th>Numero dell'ordine</th> <th>Numero dell'ordine</th>
<th>Stato garanzia</th>
<th>Azioni</th> <th>Azioni</th>
</tr> </tr>
</thead> </thead>
@ -18,6 +19,18 @@
<tr> <tr>
<td>{% if order.data %}{{ order.data }}{% endif %}</td> <td>{% if order.data %}{{ order.data }}{% endif %}</td>
<td>{% if order.numero_ordine %}{{ order.numero_ordine }}{% endif %}</td> <td>{% if order.numero_ordine %}{{ order.numero_ordine }}{% endif %}</td>
<td>
{% if order.garanzia %}
{% if order.garanzia > soon %}
<span class="label label-success">Valida</span>
{% elif order.garanzia > today %}
<span class="label label-warning">In scadenza</span>
{% else %}
<span class="label label-danger">Scaduta</span>
{% endif %}
{{ order.garanzia }}
{% endif %}
</td>
<td><a href="/order_details/{{ order.oid }}" title="Dettagli"><span class="glyphicon glyphicon-zoom-in"></span></a> <a href="/order_show/{{ order.oid }}"><span class="glyphicon glyphicon-pencil"></span></a> <a href="/order_del/{{ order.oid }}"><span class="glyphicon glyphicon-remove"></span></a></td> <td><a href="/order_details/{{ order.oid }}" title="Dettagli"><span class="glyphicon glyphicon-zoom-in"></span></a> <a href="/order_show/{{ order.oid }}"><span class="glyphicon glyphicon-pencil"></span></a> <a href="/order_del/{{ order.oid }}"><span class="glyphicon glyphicon-remove"></span></a></td>
</tr> </tr>
{% endfor %} {% endfor %}

View file

@ -9,7 +9,7 @@
{% endif %} {% endif %}
</h1> </h1>
<div class="alert alert-warning"> <div class="alert alert-warning">
Il campo data non è ancora <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1366188">correttamente supportato da Firefox</a> e altri Browser. Se il calendario non viene fuori, inserite le date nel formato AAAA-MM-GG. Il campo data non è ancora <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1366188">correttamente supportato da Firefox</a> e altri browser. Se il calendario non viene fuori, inserite le date nel formato AAAA-MM-GG.
</div> </div>
<form class="form-inline" {% if order %}action="/order_show/{{ order.oid }}"{% endif %} method="post"> <form class="form-inline" {% if order %}action="/order_show/{{ order.oid }}"{% endif %} method="post">
<input class="form-control" type="date" placeholder="yyyy-mm-dd" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}" name="data" {% if order %}value="{{ order.data }}"{% endif %}> <input class="form-control" type="date" placeholder="yyyy-mm-dd" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}" name="data" {% if order %}value="{{ order.data }}"{% endif %}>