added initial very ugly version, it works...
This commit is contained in:
parent
0ccb204dc7
commit
b2490eac05
2 changed files with 97 additions and 0 deletions
64
main.py
Normal file
64
main.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
from flask import Flask, render_template, request, redirect, url_for
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
class Person:
|
||||
statusses = ["Pannenkoek besteld", "Pannenkoek aan het bakken", "Pannenkoek klaar", "Pannenkoek afgegeven"]
|
||||
|
||||
def __init__(self, name, remark=""):
|
||||
self.name = name
|
||||
self.remark = remark.strip()
|
||||
self.status = 0
|
||||
|
||||
def getRemark(self):
|
||||
return "({})".format(self.remark) if self.remark else self.remark
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
||||
def __eq__(self, other):
|
||||
return self.name == other.name
|
||||
|
||||
def getStatus(self):
|
||||
return self.statusses[self.status]
|
||||
|
||||
def nextStatus(self):
|
||||
return self.statusses[self.status + 1]
|
||||
|
||||
def __str__(self):
|
||||
return "Persoon: {} met status: {}".format(self.name, self.status)
|
||||
|
||||
def __repr__(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
people = []
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return render_template("home.html", people=people)
|
||||
|
||||
|
||||
@app.route("/statusUpdate")
|
||||
def statusUpdate():
|
||||
if people:
|
||||
people[0].status += 1
|
||||
if people[0].status == 3:
|
||||
people.remove(people[0])
|
||||
return redirect("/")
|
||||
|
||||
|
||||
@app.route("/addPerson", methods=["POST", "GET"])
|
||||
def addPerson():
|
||||
if request.method == "POST":
|
||||
result = request.form
|
||||
newPerson = Person(request.form["name"], request.form["remark"])
|
||||
if newPerson not in people:
|
||||
people.append(newPerson)
|
||||
return redirect("/")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
33
templates/home.html
Normal file
33
templates/home.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Pannenkoekenwachtrij</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Welkom bij de pannenkoekenwachtrij</h1>
|
||||
|
||||
<form action="/addPerson" method="POST">
|
||||
<p>Naam van de volgende <input type="text" name="name"></p>
|
||||
<p>Specifieke opmerkingen <input type="text" name="remark"></p>
|
||||
<p><input type="submit" value="Persoon toevoegen"></p>
|
||||
</form>
|
||||
|
||||
<h2>Zie hieronder de lijst van personen die een pannenkoek willen</h2>
|
||||
<table>
|
||||
{% for person in people %}
|
||||
<tr>
|
||||
<th>{{ person.getName() + person.getRemark() + ": " }}</th>
|
||||
<td>
|
||||
<a href="/statusUpdate">
|
||||
<input type="button" value="{{ person.nextStatus() }}"/>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ "Huidige status: " + person.getStatus() }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</header>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue