more bug fixing inside the change funktion

This commit is contained in:
2000-Trek 2023-06-09 20:17:30 +02:00
parent 731aa9f1f5
commit aa9eb5068a

View file

@ -70,18 +70,18 @@ def change():
change = int(request.args.get("change"))
except ValueError:
return '<p>Please enter a number!</p><a href="/list">tags and user list</a>'
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
conn.commit()
if change < 0:
text = "removed from"
change = change * -1
change_text = change * -1
elif change > 0:
text = "added to"
elif change == 0:
return "<p>Nothing was done!</p>"
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
conn.commit()
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_text} was {text} {user}</p> <a href="/list">back to the list</a>'
@app.route("/addtag", methods=['GET'])
def get_addtag_request():