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

Fix "None" serial code bug (closes #16)

This commit is contained in:
Steffo 2017-09-19 17:30:14 +02:00
parent 906de4cb77
commit 805a5ef3bf
2 changed files with 23 additions and 28 deletions

View file

@ -125,19 +125,6 @@ class Dispositivo(db.Model):
so = db.Column(db.String)
oid = db.Column(db.Integer, db.ForeignKey('ordini.oid'))
def __init__(self, tipo, marca, modello, inv_ced, inv_ente, nid, seriale, ip, hostname, so, oid):
self.tipo = tipo
self.marca = marca
self.modello = modello
self.inv_ced = inv_ced
self.inv_ente = inv_ente
self.nid = nid
self.seriale = seriale
self.ip = ip
self.hostname = hostname
self.so = so
self.oid = oid
def __str__(self):
if self.marca != "" and self.modello != "":
return f"{self.marca} {self.modello}"
@ -542,13 +529,17 @@ def page_disp_add():
int(request.form["inv_ente"])
except ValueError:
return render_template("error.htm", error="Il campo Inventario ente deve contenere un numero.")
nuovodisp = Dispositivo(request.form['tipo'], request.form['marca'], request.form['modello'],
int(request.form['inv_ced']) if request.form['inv_ced'] else None,
int(request.form['inv_ente']) if request.form['inv_ente'] else None,
request.form['rete'], request.form['seriale'],
request.form['ip'], request.form['hostname'] if request.form['hostname'] else None,
request.form['so'],
int(request.form['ordine']) if request.form['ordine'] else None)
nuovodisp = Dispositivo(tipo=request.form['tipo'],
marca=request.form['marca'],
modello=request.form['modello'],
inv_ced=int(request.form['inv_ced']) if request.form['inv_ced'] else None,
inv_ente=int(request.form['inv_ente']) if request.form['inv_ente'] else None,
nid=request.form['rete'],
seriale=request.form['seriale'] if request.form['seriale'] else None,
ip=request.form['ip'],
hostname=request.form['hostname'] if request.form['hostname'] else None,
so=request.form['so'],
oid=int(request.form['ordine']) if request.form['ordine'] else None)
db.session.add(nuovodisp)
db.session.commit()
# Trova tutti gli utenti, edizione sporco hack in html
@ -695,13 +686,17 @@ def page_disp_clone(did):
int(request.form["inv_ente"])
except ValueError:
return render_template("error.htm", error="Il campo Inventario ente deve contenere un numero.")
nuovodisp = Dispositivo(request.form['tipo'], request.form['marca'], request.form['modello'],
int(request.form['inv_ced']) if request.form['inv_ced'] else None,
int(request.form['inv_ente']) if request.form['inv_ente'] else None,
request.form['rete'], request.form['seriale'],
request.form['ip'], request.form['hostname'] if request.form['hostname'] else None,
request.form['so'],
int(request.form['ordine']) if request.form['ordine'] else None)
nuovodisp = Dispositivo(tipo=request.form['tipo'],
marca=request.form['marca'],
modello=request.form['modello'],
inv_ced=int(request.form['inv_ced']) if request.form['inv_ced'] else None,
inv_ente=int(request.form['inv_ente']) if request.form['inv_ente'] else None,
nid=request.form['rete'],
seriale=request.form['seriale'] if request.form['seriale'] else None,
ip=request.form['ip'],
hostname=request.form['hostname'] if request.form['hostname'] else None,
so=request.form['so'],
oid=int(request.form['ordine']) if request.form['ordine'] else None)
db.session.add(nuovodisp)
db.session.commit()
# Trova tutti gli utenti, edizione sporco hack in html

View file

@ -131,7 +131,7 @@
<div class="form-group">
<label class="col-xs-2" for="form-seriale">Numero Seriale</label>
<div class="col-xs-10">
<input id="form-seriale" class="form-control" type="text" placeholder="Seriale" name="seriale" {% if dispositivo %}value="{{ dispositivo.seriale }}"{% endif %} value="{{ request.args.get('scanned_barcode') }}">
<input id="form-seriale" class="form-control" type="text" placeholder="Seriale" name="seriale" {% if dispositivo %}value="{{ dispositivo.seriale }}"{% elif request.args.get("scanned_barcode") %}value="{{ request.args.get('scanned_barcode') }}{% endif %}">
</div>
</div>
<div class="form-group">