1
0
Fork 0
forked from anton/matekasse

list and change

This commit is contained in:
2000-Trek 2023-06-09 19:53:27 +02:00
parent 51f3d5a4d7
commit 97064df670

View file

@ -33,7 +33,7 @@ def list():
users = c.fetchall()
text = ""
for i in users:
text = text + f'<p>{i[1]}: {i[2]} <form action="/addtag" method="get"><input name="id" type="hidden" value="{i[0]}"><button type="submit">Add Tag</button></form><form action="/change" method="get"><input name="id" type="hidden" value="{i[0]}"> Change balance: <input name="change"><input type="submit"></form></p><br></br>'
text = text + f'<p><a href="/user?user={i[1]}">{i[1]}</a>: {i[2]} <form action="/addtag" method="get"><input name="id" type="hidden" value="{i[0]}"><button type="submit">Add Tag</button></form><form action="/change" method="get"><input name="id" type="hidden" value="{i[0]}"> Change balance: <input name="change"><input type="submit"></form></p><br></br>'
return '<form action="/list/user" method="get"> Search for User: <input name="user"><input type="submit"></form> <form action="/adduser" method="get"><button type="submit">Add User</button></form> <br></br>' + text
@app.route("/list/user", methods=['GET'])
@ -69,7 +69,7 @@ def change():
try:
change = int(request.args.get("change"))
except ValueError:
return '<p>Pleas enter a number!</p><a href="/list">tags and user list</a>'
return '<p>Please enter a number!</p><a href="/list">tags and user list</a>'
if change < 0:
text = "removed from"
change = change * -1
@ -80,7 +80,7 @@ def change():
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
c.execute(f"SELECT * FROM users WHERE id={user_id}")
user = c.fetchall()[0][1]
return f'<p>{change} was {text} {user}</p> <a href="/list">back to the list></a>'
return f'<p>{change} was {text} {user}</p> <a href="/list">back to the list</a>'
@app.route("/addtag", methods=['GET'])
def get_addtag_request():