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

Add locazione field in Servizio

This commit is contained in:
Lorenzo 2017-09-11 15:56:42 +02:00
parent 4970653e44
commit bcabb2b83c
4 changed files with 15 additions and 8 deletions

View file

@ -45,11 +45,13 @@ class Servizio(db.Model):
sid = db.Column(db.Integer, primary_key=True) sid = db.Column(db.Integer, primary_key=True)
eid = db.Column(db.Integer, db.ForeignKey('ente.eid')) eid = db.Column(db.Integer, db.ForeignKey('ente.eid'))
nomeservizio = db.Column(db.String(128)) nomeservizio = db.Column(db.String(128))
locazione = db.Column(db.String(128))
impiegati = db.relationship("Impiegato", backref='servizio', lazy='dynamic') impiegati = db.relationship("Impiegato", backref='servizio', lazy='dynamic')
def __init__(self, eid, nomeservizio): def __init__(self, eid, nomeservizio, locazione):
self.eid = eid self.eid = eid
self.nomeservizio = nomeservizio self.nomeservizio = nomeservizio
self.locazione = locazione
def __repr__(self): def __repr__(self):
return "<Servizio {}>".format(self.nomeservizio) return "<Servizio {}>".format(self.nomeservizio)
@ -229,7 +231,7 @@ def page_serv_add():
css = url_for("static", filename="style.css") css = url_for("static", filename="style.css")
return render_template("servizio/add.htm", css=css, enti=enti, type="serv", user=session["username"]) return render_template("servizio/add.htm", css=css, enti=enti, type="serv", user=session["username"])
else: else:
nuovoserv = Servizio(request.form['eid'], request.form['nomeservizio']) nuovoserv = Servizio(request.form['eid'], request.form['nomeservizio'], request.form['locazione'])
db.session.add(nuovoserv) db.session.add(nuovoserv)
db.session.commit() db.session.commit()
return redirect(url_for('page_serv_list')) return redirect(url_for('page_serv_list'))
@ -279,6 +281,7 @@ def page_serv_show(sid):
serv = Servizio.query.get(sid) serv = Servizio.query.get(sid)
serv.eid = request.form["eid"] serv.eid = request.form["eid"]
serv.nomeservizio = request.form["nomeservizio"] serv.nomeservizio = request.form["nomeservizio"]
serv.locazione = request.form["locazione"]
db.session.commit() db.session.commit()
return redirect(url_for('page_serv_list')) return redirect(url_for('page_serv_list'))
@ -425,10 +428,10 @@ def page_details_imp(iid):
return render_template("impiegato/details.htm", css=css, imp=impiegato, type="imp",user=session["username"]) return render_template("impiegato/details.htm", css=css, imp=impiegato, type="imp",user=session["username"])
if __name__ == "__main__": if __name__ == "__main__":
# db.create_all() #db.create_all()
# p = b"admin" #p = b"admin"
# cenere = bcrypt.hashpw(p, bcrypt.gensalt()) #cenere = bcrypt.hashpw(p, bcrypt.gensalt())
# nuovouser = User('admin', cenere) #nuovouser = User('admin', cenere)
# db.session.add(nuovouser) #db.session.add(nuovouser)
# db.session.commit() #db.session.commit()
app.run(debug=True) app.run(debug=True)

View file

@ -11,6 +11,7 @@
{% endfor %} {% endfor %}
</select> </select>
<input class="form-control" type="text" placeholder="Nome ente" name="nomeservizio"> <input class="form-control" type="text" placeholder="Nome ente" name="nomeservizio">
<input class="form-control" type="text" placeholder="Locazione" name="locazione">
<input class="form-control" type="submit"> <input class="form-control" type="submit">
</form> </form>
{% endblock %} {% endblock %}

View file

@ -9,6 +9,7 @@
<tr> <tr>
<th>Nome ente</th> <th>Nome ente</th>
<th>Nome servizio</th> <th>Nome servizio</th>
<th>Locazione</th>
<th>Ispeziona</th> <th>Ispeziona</th>
<th>Modifica</th> <th>Modifica</th>
<th>Elimina</th> <th>Elimina</th>
@ -18,6 +19,7 @@
<tr> <tr>
<td>{{ servizio.ente.nomeente }}</td> <td>{{ servizio.ente.nomeente }}</td>
<td>{{ servizio.nomeservizio }}</td> <td>{{ servizio.nomeservizio }}</td>
<td>{{ servizio.locazione }}</td>
<td><a href="/imp_list/{{ servizio.sid }}"><span class="glyphicon glyphicon-list-alt"></span></a></td> <td><a href="/imp_list/{{ servizio.sid }}"><span class="glyphicon glyphicon-list-alt"></span></a></td>
<td><a href="/serv_show/{{ servizio.sid }}"><span class="glyphicon glyphicon-pencil"></span></a></td> <td><a href="/serv_show/{{ servizio.sid }}"><span class="glyphicon glyphicon-pencil"></span></a></td>
<td><a href="/serv_del/{{ servizio.sid }}"><span class="glyphicon glyphicon-remove"></span></a></td> <td><a href="/serv_del/{{ servizio.sid }}"><span class="glyphicon glyphicon-remove"></span></a></td>

View file

@ -11,6 +11,7 @@
{% endfor %} {% endfor %}
</select> </select>
<input class="form-control" type="text" placeholder="Nome servizio" name="nomeservizio" value="{{serv.nomeservizio}}"> <input class="form-control" type="text" placeholder="Nome servizio" name="nomeservizio" value="{{serv.nomeservizio}}">
<input class="form-control" type="text" placeholder="locazione" name="locazione" value="{{serv.locazione}}">
<input class="btn btn-primary" type="submit"> <input class="btn btn-primary" type="submit">
</form> </form>
{% endblock %} {% endblock %}