From ff9d3201aa5e1935dbd6b62e31be4d867b49f54b Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Tue, 19 Sep 2017 15:49:01 +0200 Subject: [PATCH] Fornitore is now a field of Ordine class --- server.py | 14 +++++++------- templates/dispositivo/details.htm | 10 ---------- templates/dispositivo/list.htm | 2 -- templates/dispositivo/show.htm | 6 ------ templates/ordine/details.htm | 10 ++++++++++ templates/ordine/list.htm | 2 ++ templates/ordine/show.htm | 1 + 7 files changed, 20 insertions(+), 25 deletions(-) diff --git a/server.py b/server.py index 6b2a70d..4467d5e 100644 --- a/server.py +++ b/server.py @@ -117,7 +117,6 @@ class Dispositivo(db.Model): modello = db.Column(db.String) inv_ced = db.Column(db.Integer, unique=True) inv_ente = db.Column(db.Integer, unique=True) - fornitore = db.Column(db.String) seriale = db.Column(db.String) ip = db.Column(db.String) nid = db.Column(db.Integer, db.ForeignKey('reti.nid')) @@ -126,13 +125,12 @@ 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, fornitore, nid, seriale, ip, hostname, so, 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.fornitore = fornitore self.nid = nid self.seriale = seriale self.ip = ip @@ -203,6 +201,7 @@ class Ordine(db.Model): numero_ordine = db.Column(db.String) garanzia = db.Column(db.Date) dispositivo = db.relationship("Dispositivo", backref='ordine', lazy='dynamic', cascade="delete") + fornitore = db.Column(db.String) def __str__(self): if self.numero_ordine is not None: @@ -546,7 +545,7 @@ def page_disp_add(): 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['fornitore'], request.form['rete'], request.form['seriale'], + 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) db.session.add(nuovodisp) @@ -646,7 +645,6 @@ def page_disp_show(did): disp.tipo = request.form['tipo'] disp.marca = request.form['marca'] disp.modello = request.form['modello'] - disp.fornitore = request.form['fornitore'] disp.nid = int(request.form['rete']) disp.ip = request.form['ip'] disp.hostname = request.form['hostname'] if request.form['hostname'] else None @@ -699,7 +697,7 @@ def page_disp_clone(did): 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['fornitore'], request.form['rete'], request.form['seriale'], + 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) db.session.add(nuovodisp) @@ -874,7 +872,8 @@ def page_order_add(): garanzia = datetime.date(int(yyyy), int(mm), int(dd)) else: garanzia = None - nuovoordine = Ordine(data=data, numero_ordine=request.form["numero_ordine"], garanzia=garanzia) + nuovoordine = Ordine(data=data, numero_ordine=request.form["numero_ordine"], garanzia=garanzia, + fornitore=request.form['fornitore']) db.session.add(nuovoordine) db.session.commit() return redirect(url_for("page_order_list")) @@ -902,6 +901,7 @@ def page_order_show(oid): else: order.garanzia = None order.numero_ordine = request.form["numero_ordine"] + order.fornitore = request.form['fornitore'] db.session.commit() return redirect(url_for("page_order_list")) diff --git a/templates/dispositivo/details.htm b/templates/dispositivo/details.htm index 1e31ac7..30372e6 100644 --- a/templates/dispositivo/details.htm +++ b/templates/dispositivo/details.htm @@ -53,16 +53,6 @@ {% endif %} - {% if disp.fornitore %} -
  • -

    - Fornitore -

    -
    - {{ disp.fornitore }} -
    -
  • - {% endif %} {% if accessi %}
  • diff --git a/templates/dispositivo/list.htm b/templates/dispositivo/list.htm index 17ce29f..08f4cb4 100644 --- a/templates/dispositivo/list.htm +++ b/templates/dispositivo/list.htm @@ -13,7 +13,6 @@ Inventario CED Marca Modello - Fornitore Seriale Azioni @@ -25,7 +24,6 @@ {% if d[0].dispositivo.inv_ced %}{{ d[0].dispositivo.inv_ced }}{% endif %} {{ d[0].dispositivo.marca }} {{ d[0].dispositivo.modello }} - {{ d[0].dispositivo.fornitore }} {{ d[0].dispositivo.seriale }} diff --git a/templates/dispositivo/show.htm b/templates/dispositivo/show.htm index 486db7e..8bfd90d 100644 --- a/templates/dispositivo/show.htm +++ b/templates/dispositivo/show.htm @@ -128,12 +128,6 @@ -
    - -
    - -
    -
    diff --git a/templates/ordine/details.htm b/templates/ordine/details.htm index a5cab31..5aae704 100644 --- a/templates/ordine/details.htm +++ b/templates/ordine/details.htm @@ -42,6 +42,16 @@

  • {% endif %} + {% if ordine.fornitore %} +
  • +

    + Fornitore +

    +
    + {{ ordine.fornitore }} +
    +
  • + {% endif %} {% if dispositivi %}
  • diff --git a/templates/ordine/list.htm b/templates/ordine/list.htm index 45e1e58..120833d 100644 --- a/templates/ordine/list.htm +++ b/templates/ordine/list.htm @@ -10,6 +10,7 @@ Data dell'ordine Numero dell'ordine + Fornitore Stato garanzia Azioni @@ -19,6 +20,7 @@ {% if order.data %}{{ order.data }}{% endif %} {% if order.numero_ordine %}{{ order.numero_ordine }}{% endif %} + {% if order.fornitore %}{{ order.fornitore }}{% endif %} {% if order.garanzia %} {% if order.garanzia > soon %} diff --git a/templates/ordine/show.htm b/templates/ordine/show.htm index c7a9342..1cafb71 100644 --- a/templates/ordine/show.htm +++ b/templates/ordine/show.htm @@ -15,6 +15,7 @@ + {% endblock %}