Fixed Flask code, changed first button to update first person, added function to update buttons for all but the first person
This commit is contained in:
parent
f798a27a90
commit
140d01a460
2 changed files with 20 additions and 9 deletions
18
main.py
18
main.py
|
@ -44,11 +44,17 @@ def home():
|
|||
@app.route("/statusUpdate", methods=["POST", "GET"])
|
||||
def statusUpdate():
|
||||
if people and request.method == "POST":
|
||||
index = people.index(Person(request.form["name"]))
|
||||
print(index)
|
||||
people[index].status += 1
|
||||
if people[index].status == 3:
|
||||
people.remove(people[index])
|
||||
if request.form.has_key("index"):
|
||||
index = int(request.form["index"])
|
||||
people[index].status += 1
|
||||
if people[index].status == 3:
|
||||
people.remove(people[index])
|
||||
if request.form.has_key("name"):
|
||||
index = people.index(Person(request.form["name"]))
|
||||
print(index)
|
||||
people[index].status += 1
|
||||
if people[index].status == 3:
|
||||
people.remove(people[index])
|
||||
return redirect("/")
|
||||
|
||||
|
||||
|
@ -56,7 +62,7 @@ def statusUpdate():
|
|||
def addPerson():
|
||||
if request.method == "POST":
|
||||
result = request.form
|
||||
if result["name"]:
|
||||
if result.has_key("name"):
|
||||
newPerson = Person(result["name"], result["remark"])
|
||||
if newPerson not in people:
|
||||
people.append(newPerson)
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
</form>
|
||||
|
||||
<form action="/statusUpdate" method="POST">
|
||||
<p>Up te daten persoon <input type="text" name="name"></p>
|
||||
<p><input type="submit" value="Updaten"></p>
|
||||
<input type="hidden" name="index" value="0">
|
||||
<p><input type="submit" value="Update First Person"></p>
|
||||
</form>
|
||||
|
||||
<h2>Zie hieronder de lijst van personen die een pannenkoek willen</h2>
|
||||
|
@ -37,7 +37,12 @@
|
|||
<table>
|
||||
{% for person in people[1:] %}
|
||||
<tr>
|
||||
<td><button>Update</button></td>
|
||||
<td>
|
||||
<form action="/statusUpdate" method="POST">
|
||||
<input type="hidden" name="name" value="{{ person.getName() }}">
|
||||
<input type="submit" value="Update">
|
||||
</form>
|
||||
</td>
|
||||
<th>{{ person.getName() + person.getRemark() + ": " }}</th>
|
||||
<td>{{ "Huidige status: " + person.getStatus() }}</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue