Don't show a message after change
This commit is contained in:
parent
e5964c6143
commit
be29750c85
1 changed files with 25 additions and 14 deletions
37
main.py
37
main.py
|
@ -1,6 +1,6 @@
|
||||||
import queue
|
import queue
|
||||||
from flask import Flask, render_template, request, make_response, session
|
from flask import Flask, render_template, request, make_response, session
|
||||||
from flask_socketio import SocketIO, join_room, leave_room #https://pythonprogramminglanguage.com/python-flask-websocket/
|
from flask_socketio import SocketIO, join_room, leave_room
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import time
|
import time
|
||||||
|
@ -107,6 +107,7 @@ def remove_user():
|
||||||
c.execute(f"DELETE FROM tags WHERE userid={user_id}")
|
c.execute(f"DELETE FROM tags WHERE userid={user_id}")
|
||||||
c.execute(f"DELETE FROM users WHERE id={user_id}")
|
c.execute(f"DELETE FROM users WHERE id={user_id}")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
socketio.emit("update", "update")
|
||||||
return f'<p>Deleted user {user_name}</p><a href="/list">return to the tags and user list</a>'
|
return f'<p>Deleted user {user_name}</p><a href="/list">return to the tags and user list</a>'
|
||||||
|
|
||||||
@app.route("/adduser/user", methods=['GET'])
|
@app.route("/adduser/user", methods=['GET'])
|
||||||
|
@ -116,6 +117,7 @@ def adduser():
|
||||||
if c.fetchall() == []:
|
if c.fetchall() == []:
|
||||||
c.execute("INSERT or IGNORE INTO users (username, balance) VALUES (?, 0)", [user])
|
c.execute("INSERT or IGNORE INTO users (username, balance) VALUES (?, 0)", [user])
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
socketio.emit("update", "update")
|
||||||
return 'Added user <a href="/list">user and tag list</a> <p>The creator of this website accepts no liability for any linguistic or technical errors!</p>'
|
return 'Added user <a href="/list">user and tag list</a> <p>The creator of this website accepts no liability for any linguistic or technical errors!</p>'
|
||||||
else:
|
else:
|
||||||
return '<p>User already exists</p> <a href="/list">user and tag list</a>'
|
return '<p>User already exists</p> <a href="/list">user and tag list</a>'
|
||||||
|
@ -129,18 +131,27 @@ def change():
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return '<p>Please 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>'
|
||||||
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
|
c.execute(f"UPDATE users SET balance = balance + {change} WHERE id={user_id}")
|
||||||
conn.commit()
|
socketio.emit("update", "update")
|
||||||
if change < 0:
|
return """<html>
|
||||||
text = "removed from"
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
|
||||||
change_text = change * -1
|
<script type="text/javascript" charset="utf-8">
|
||||||
elif change > 0:
|
window.location="http://matekasse.server.c3h/list";
|
||||||
text = "added to"
|
</script>
|
||||||
change_text = change
|
</html>
|
||||||
elif change == 0:
|
"""
|
||||||
return "<p>Nothing was done!</p>"
|
#socketio.emit("update", "update")
|
||||||
c.execute(f"SELECT * FROM users WHERE id={user_id}")
|
#conn.commit()
|
||||||
user = c.fetchall()[0][1]
|
#if change < 0:
|
||||||
return f'<p>{change_text} was {text} {user}</p> <a href="/list">back to the list</a>'
|
# text = "removed from"
|
||||||
|
# change_text = change * -1
|
||||||
|
#elif change > 0:
|
||||||
|
# text = "added to"
|
||||||
|
# change_text = change
|
||||||
|
#elif change == 0:
|
||||||
|
# return "<p>Nothing was done!</p>"
|
||||||
|
#c.execute(f"SELECT * FROM users WHERE id={user_id}")
|
||||||
|
#user = c.fetchall()[0][1]
|
||||||
|
#return f'<p>{change_text} was {text} {user}</p> <a href="/list">back to the list</a>'
|
||||||
|
|
||||||
@app.route("/addtag", methods=['GET'])
|
@app.route("/addtag", methods=['GET'])
|
||||||
def get_addtag_request():
|
def get_addtag_request():
|
||||||
|
|
Loading…
Reference in a new issue