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

Remove serv_add page

This commit is contained in:
Steffo 2017-09-18 16:35:42 +02:00 committed by Stefano Pigozzi
parent 4f0354b94e
commit d0f8c08363
3 changed files with 12 additions and 25 deletions

View file

@ -324,7 +324,7 @@ def page_serv_add():
return abort(403) return abort(403)
if request.method == 'GET': if request.method == 'GET':
enti = Ente.query.order_by(Ente.nomeente).all() enti = Ente.query.order_by(Ente.nomeente).all()
return render_template("servizio/add.htm", enti=enti, pagetype="serv", user=session.get("username")) return render_template("servizio/show.htm", action="add", enti=enti, pagetype="serv", user=session.get("username"))
else: else:
nuovoserv = Servizio(request.form['eid'], request.form['nomeservizio'], request.form['locazione']) nuovoserv = Servizio(request.form['eid'], request.form['nomeservizio'], request.form['locazione'])
db.session.add(nuovoserv) db.session.add(nuovoserv)
@ -372,7 +372,7 @@ def page_serv_show(sid):
if request.method == "GET": if request.method == "GET":
serv = Servizio.query.get_or_404(sid) serv = Servizio.query.get_or_404(sid)
enti = Ente.query.all() enti = Ente.query.all()
return render_template("servizio/show.htm", serv=serv, enti=enti, user=session.get("username")) return render_template("servizio/show.htm", action="show", serv=serv, enti=enti, user=session.get("username"))
else: else:
serv = Servizio.query.get_or_404(sid) serv = Servizio.query.get_or_404(sid)
serv.eid = request.form["eid"] serv.eid = request.form["eid"]

View file

@ -1,17 +0,0 @@
{% extends "base.htm" %}
{% block title %}Aggiungi servizio • estus{% endblock %}
{% block content %}
<h1>
Aggiungi nuovo servizio
</h1>
<form class="form-inline" action="/serv_add" method="post">
<select class="form-control" name="eid">
{% for ente in enti %}
<option value="{{ ente.eid }}">{{ ente.nomeente }}</option>
{% endfor %}
</select>
<input class="form-control" type="text" placeholder="Nome servizio" name="nomeservizio">
<input class="form-control" type="text" placeholder="Locazione" name="locazione">
<input class="form-control" type="submit">
</form>
{% endblock %}

View file

@ -2,16 +2,20 @@
{% block title %}Modifica servizio • estus{% endblock %} {% block title %}Modifica servizio • estus{% endblock %}
{% block content %} {% block content %}
<h1> <h1>
Modifica servizio {% if action == "add" %}
Aggiungi servizio
{% elif action == "show" %}
Modifica servizio
{% endif %}
</h1> </h1>
<form class="form-inline" action="/serv_show/{{serv.sid}}" method="post"> <form class="form-inline" {% if serv %}action="/serv_show/{{serv.sid}}"{% endif %} method="post">
<select class="form-control" name="eid" value="serv.eid"> <select class="form-control" name="eid">
{% for ente in enti %} {% for ente in enti %}
<option value="{{ente.eid}}" {% if serv.eid == ente.eid %}selected="selected"{% endif %}>{{ente.nomeente}}</option> <option value="{{ente.eid}}" {% if serv and serv.eid == ente.eid %}selected="selected"{% endif %}>{{ente.nomeente}}</option>
{% 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" {% if serv %}value="{{serv.nomeservizio}}"{% endif %}>
<input class="form-control" type="text" placeholder="locazione" name="locazione" value="{{serv.locazione}}"> <input class="form-control" type="text" placeholder="locazione" name="locazione" {% if serv %}value="{{serv.locazione}}"{% endif %}>
<input class="btn btn-primary" type="submit"> <input class="btn btn-primary" type="submit">
</form> </form>
{% endblock %} {% endblock %}