From 3cc0857973d95f9941f6c73b7a69575921f67256 Mon Sep 17 00:00:00 2001 From: hannes-kl Date: Wed, 13 Feb 2019 21:40:23 +0100 Subject: [PATCH 1/7] Added distinction between first and other people --- templates/home.html | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/templates/home.html b/templates/home.html index 2eaddbc..d08815c 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,6 +1,12 @@ + Pannenkoekenwachtrij @@ -20,8 +26,16 @@

Zie hieronder de lijst van personen die een pannenkoek willen

+

Volgende Persoon:

+ {% if people %} + + {{ people[0].getName() + people[0].getRemark() + ": " }} + {{ "Huidige status: " + people[0].getStatus() }} + + {% endif %} +

Andere Personen:

- {% for person in people %} + {% for person in people[1:] %} @@ -30,4 +44,4 @@
{{ person.getName() + person.getRemark() + ": " }} {{ "Huidige status: " + person.getStatus() }}
- \ No newline at end of file + From f798a27a90792fba591b7f668c3e8c096eb7dc94 Mon Sep 17 00:00:00 2001 From: hannes-kl Date: Wed, 13 Feb 2019 21:41:15 +0100 Subject: [PATCH 2/7] added test button for people who are not the first person --- templates/home.html | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/home.html b/templates/home.html index d08815c..d189d95 100644 --- a/templates/home.html +++ b/templates/home.html @@ -37,6 +37,7 @@ {% for person in people[1:] %} + From 6871bfd3bfd796dcbae8da46450344b4856fa616 Mon Sep 17 00:00:00 2001 From: Jan-Pieter Baert Date: Wed, 13 Feb 2019 22:02:14 +0100 Subject: [PATCH 3/7] fixed that when the person isn't in the queue the site doesn't crash --- main.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b9fd26f..f209a9c 100644 --- a/main.py +++ b/main.py @@ -44,11 +44,13 @@ 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]) + newPerson = Person(request.form["name"]) + if newPerson in people: + index = people.index(newPerson) + print(index) + people[index].status += 1 + if people[index].status == 3: + people.remove(people[index]) return redirect("/") From 140d01a460f2fa8fee557b091b813eecc8ef716c Mon Sep 17 00:00:00 2001 From: hannes-kl Date: Wed, 13 Feb 2019 23:29:58 +0100 Subject: [PATCH 4/7] Fixed Flask code, changed first button to update first person, added function to update buttons for all but the first person --- main.py | 18 ++++++++++++------ templates/home.html | 11 ++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index b9fd26f..88943e4 100644 --- a/main.py +++ b/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) diff --git a/templates/home.html b/templates/home.html index d189d95..2c73561 100644 --- a/templates/home.html +++ b/templates/home.html @@ -21,8 +21,8 @@
-

Up te daten persoon

-

+ +

Zie hieronder de lijst van personen die een pannenkoek willen

@@ -37,7 +37,12 @@
{{ person.getName() + person.getRemark() + ": " }} {{ "Huidige status: " + person.getStatus() }}
{% for person in people[1:] %} - + From 59e852f516c72dba2fa6ea1e999460cfacd3c98f Mon Sep 17 00:00:00 2001 From: hannes-kl Date: Wed, 13 Feb 2019 23:40:07 +0100 Subject: [PATCH 5/7] Added to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9f11b75..ee64372 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/ +*.pyc From 59c3e8475c52fc62f26f4017b3111028093b0e93 Mon Sep 17 00:00:00 2001 From: Jan-Pieter Baert Date: Thu, 14 Feb 2019 22:29:25 +0100 Subject: [PATCH 6/7] request.form.has_key() is depricated, so I changed it --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 88943e4..f20f432 100644 --- a/main.py +++ b/main.py @@ -44,12 +44,13 @@ def home(): @app.route("/statusUpdate", methods=["POST", "GET"]) def statusUpdate(): if people and request.method == "POST": - if request.form.has_key("index"): + result = request.form + if "index" in result: index = int(request.form["index"]) people[index].status += 1 if people[index].status == 3: people.remove(people[index]) - if request.form.has_key("name"): + if "name" in result: index = people.index(Person(request.form["name"])) print(index) people[index].status += 1 @@ -62,7 +63,7 @@ def statusUpdate(): def addPerson(): if request.method == "POST": result = request.form - if result.has_key("name"): + if "name" in result: newPerson = Person(result["name"], result["remark"]) if newPerson not in people: people.append(newPerson) From fbe17e5c808951274acd1904d8ac34ea50f59a10 Mon Sep 17 00:00:00 2001 From: Jan-Pieter Baert Date: Thu, 5 Sep 2019 00:07:05 +0200 Subject: [PATCH 7/7] Update gitignore and add requirements-file --- .gitignore | 1 + requirements.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index ee64372..e6a15fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea/ *.pyc +venv/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7e10602 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask
+
+ + +
+
{{ person.getName() + person.getRemark() + ": " }} {{ "Huidige status: " + person.getStatus() }}