1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-29 02:34:20 +00:00

Fix altro bug che non mi ricordo

This commit is contained in:
Steffo 2017-09-18 14:54:52 +02:00
parent e85cbba7ce
commit f2a695aafa
3 changed files with 19 additions and 17 deletions

View file

@ -96,8 +96,8 @@ class Dispositivo(db.Model):
tipo = db.Column(db.String) tipo = db.Column(db.String)
marca = db.Column(db.String) marca = db.Column(db.String)
modello = db.Column(db.String) modello = db.Column(db.String)
inv_ced = db.Column(db.Integer) inv_ced = db.Column(db.Integer, unique=True)
inv_ente = db.Column(db.Integer) inv_ente = db.Column(db.Integer, unique=True)
fornitore = db.Column(db.String) fornitore = db.Column(db.String)
seriale = db.Column(db.String) seriale = db.Column(db.String)
ip = db.Column(db.String) ip = db.Column(db.String)
@ -550,23 +550,25 @@ def page_disp_show(did):
return render_template("dispositivo/show.htm", dispositivo=disp, accessi=accessi, impiegati=impiegati, return render_template("dispositivo/show.htm", dispositivo=disp, accessi=accessi, impiegati=impiegati,
pagetype="disp", user=session.get("username"), opzioni=opzioni, reti=reti) pagetype="disp", user=session.get("username"), opzioni=opzioni, reti=reti)
else: else:
if request.form["inv_ced"]:
try:
int(request.form["inv_ced"])
except ValueError:
return render_template("error.htm", error="Il campo Inventario CED deve contenere un numero.")
if request.form["inv_ente"]:
try:
int(request.form["inv_ente"])
except ValueError:
return render_template("error.htm", error="Il campo Inventario ente deve contenere un numero.")
disp = Dispositivo.query.get_or_404(did) disp = Dispositivo.query.get_or_404(did)
accessi = Accesso.query.filter_by(did=did).all() accessi = Accesso.query.filter_by(did=did).all()
if request.form["inv_ced"]:
try:
disp.inv_ced = int(request.form["inv_ced"])
except ValueError:
return render_template("error.htm", error="Il campo Inventario CED deve contenere un numero.")
else:
disp.inv_ced = None
if request.form["inv_ente"]:
try:
disp.inv_ente = int(request.form["inv_ente"])
except ValueError:
return render_template("error.htm", error="Il campo Inventario ente deve contenere un numero.")
else:
disp.inv_ente = None
disp.tipo = request.form['tipo'] disp.tipo = request.form['tipo']
disp.marca = request.form['marca'] disp.marca = request.form['marca']
disp.modello = request.form['modello'] disp.modello = request.form['modello']
disp.inv_ced = int(request.form['inv_ced']) if request.form["inv_ced"] else None
disp.inv_ente = int(request.form['inv_ente']) if request.form["inv_ced"] else None
disp.fornitore = request.form['fornitore'] disp.fornitore = request.form['fornitore']
disp.nid = int(request.form['rete']) disp.nid = int(request.form['rete'])
disp.ip = request.form['ip'] disp.ip = request.form['ip']

View file

@ -22,7 +22,7 @@
<tr> <tr>
<td>{{ d[0].dispositivo.tipo }}</td> <td>{{ d[0].dispositivo.tipo }}</td>
<td>{% for u in d %}<p>{{ u.impiegato.nomeimpiegato }}</p>{% endfor %}</td> <td>{% for u in d %}<p>{{ u.impiegato.nomeimpiegato }}</p>{% endfor %}</td>
<td>{{ d[0].dispositivo.inv_ced }}</td> <td>{% if d[0].dispositivo.inv_ced %}{{ d[0].dispositivo.inv_ced }}{% endif %}</td>
<td>{{ d[0].dispositivo.marca }}</td> <td>{{ d[0].dispositivo.marca }}</td>
<td>{{ d[0].dispositivo.modello }}</td> <td>{{ d[0].dispositivo.modello }}</td>
<td>{{ d[0].dispositivo.fornitore }}</td> <td>{{ d[0].dispositivo.fornitore }}</td>

View file

@ -73,13 +73,13 @@
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-ced">Inventario CED</label> <label class="col-xs-2" for="form-ced">Inventario CED</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-ced" class="form-control" type="text" placeholder="Inventario CED" name="inv_ced" value="{{ dispositivo.inv_ced }}"> <input id="form-ced" class="form-control" type="text" placeholder="Inventario CED" name="inv_ced" {% if dispositivo.inv_ced %}value="{{ dispositivo.inv_ced }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-xs-2" for="form-ente">Inventario ente</label> <label class="col-xs-2" for="form-ente">Inventario ente</label>
<div class="col-xs-10"> <div class="col-xs-10">
<input id="form-ente" class="form-control" type="text" placeholder="Inventario ente" name="inv_ente" value="{{ dispositivo.inv_ente }}"> <input id="form-ente" class="form-control" type="text" placeholder="Inventario ente" name="inv_ente" {% if dispositivo.inv_ente %}value="{{ dispositivo.inv_ente }}"{% endif %}>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">