1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-25 00:54:18 +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."""
if 'username' not in session:
return abort(403)
ordini = Ordine.query.order_by(Ordine.data).all()
return render_template("ordine/list.htm", orders=ordini, pagetype="order", user=session.get("username"))
ordini = Ordine.query.order_by(Ordine.data.desc()).all()
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'])
@ -905,14 +906,28 @@ def page_order_show(oid):
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>')
def page_order_details(oid):
if 'username' not in session:
return abort(403)
ordine = Ordine.query.get_or_404(oid)
dispositivi = Dispositivo.query.join(Ordine).filter_by(oid=oid).all()
return render_template("ordine/details.htm", dispositivi=dispositivi, pagetype="order",
user=session.get("username"), ordine=ordine)
return render_template("ordine/details.htm", dispositivi=dispositivi, pagetype="order", today=datetime.date.today(),
user=session.get("username"), ordine=ordine,
soon=datetime.date.today() + datetime.timedelta(7))
@app.route('/query', methods=['GET', 'POST'])
@ -952,6 +967,7 @@ def page_pheesh():
dispositivi = Dispositivo.query.all()
reti = Rete.query.all()
utenti = User.query.all()
ordini = Ordine.query.all()
pesci = []
for obj in enti:
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}"))
for obj in impiegati:
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:
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:
random.seed(hash(obj.username))
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)

View file

@ -39,7 +39,7 @@
Ordine
</h4>
<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>
</li>
{% endif %}
@ -81,7 +81,7 @@
Codice Inventario CED
</h4>
<div class="list-group-item-text">
<code>{{ disp.inv_ced }}</code>
{{ disp.inv_ced }}
</div>
</li>
{% endif %}

View file

@ -1,10 +1,11 @@
{% extends "base.htm" %}
{% block title %}Dettagli Ordine • estus{% endblock %}
{% block title %}Dettagli dell'ordine • estus{% endblock %}
{% block content %}
<h1>
Dettagli dell'impiegato
Dettagli dell'ordine
</h1>
<ul class="list-group">
{% if ordine.numero_ordine %}
<li class="list-group-item">
<h4 class="list-group-item-heading">
Numero ordine
@ -13,31 +14,46 @@
{{ ordine.numero_ordine }}
</div>
</li>
<li class="list-group-item">
{% endif %}
{% if ordine.data %}
<li class="list-group-item">
<h4 class="list-group-item-heading">
Data dell'ordine (AAAA-MM-GG)
Data dell'ordine
</h4>
<div class="list-group-item-text">
{{ ordine.data }}
</div>
</li>
<li class="list-group-item">
</li>
{% endif %}
{% if ordine.garanzia %}
<li class="list-group-item">
<h4 class="list-group-item-heading">
Fine garanzia (AAAA-MM-GG)
Garanzia
</h4>
<div class="list-group-item-text">
<code>{{ ordine.garanzia }}</code>
</div>
</li>
<li class="list-group-item">
<h4 class="list-group-item-heading">
Dispositivi associati
</h4>
<div class="list-group-item-text">
{% for dispositivo in dispositivi %} <a href="/disp_details/{{ dispositivo.did }}">{{ dispositivo.tipo }}</a> <br>{% endfor %}
{% 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>
</li>
{% endif %}
{% if dispositivi %}
<li class="list-group-item">
<h4 class="list-group-item-heading">
Dispositivi associati
</h4>
<div class="list-group-item-text">
{% for dispositivo in dispositivi %} <a href="/disp_details/{{ dispositivo.did }}">{{ dispositivo }}</a> <br>{% endfor %}
</div>
</li>
{% endif %}
</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
</a>
{% endblock %}

View file

@ -10,6 +10,7 @@
<tr>
<th>Data dell'ordine</th>
<th>Numero dell'ordine</th>
<th>Stato garanzia</th>
<th>Azioni</th>
</tr>
</thead>
@ -18,6 +19,18 @@
<tr>
<td>{% if order.data %}{{ order.data }}{% 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>
</tr>
{% endfor %}

View file

@ -9,7 +9,7 @@
{% endif %}
</h1>
<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>
<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 %}>