more bug fixing inside the change funktion
This commit is contained in:
parent
731aa9f1f5
commit
aa9eb5068a
1 changed files with 4 additions and 4 deletions
8
main.py
8
main.py
|
@ -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():
|
||||
|
|
Loading…
Reference in a new issue