Updatelist if balance is changed
This commit is contained in:
parent
d9bdf63119
commit
4b73ce61d6
1 changed files with 14 additions and 5 deletions
19
main.py
19
main.py
|
@ -42,7 +42,18 @@ def list():
|
||||||
text = ""
|
text = ""
|
||||||
for i in users:
|
for i in users:
|
||||||
text = text + f'<p><a href="list/user?user={i[1]}">{i[1]}</a>: {i[2]} <form action="/change" method="get"><input name="id" type="hidden" value="{i[0]}"> Change balance: <input name="change"><input type="submit"></form></p> <br style="line-height: 50%;"></br>'
|
text = text + f'<p><a href="list/user?user={i[1]}">{i[1]}</a>: {i[2]} <form action="/change" method="get"><input name="id" type="hidden" value="{i[0]}"> Change balance: <input name="change"><input type="submit"></form></p> <br style="line-height: 50%;"></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
|
return '''<!DOCTYPE html>
|
||||||
|
<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>
|
||||||
|
<script type="text/javascript" charset="utf-8">
|
||||||
|
var socket = io();
|
||||||
|
socket.on("update", function(){
|
||||||
|
window.location="http://matekasse.server.c3h/list"
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<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 + '</html>'
|
||||||
|
|
||||||
@app.route("/list/user", methods=['GET'])
|
@app.route("/list/user", methods=['GET'])
|
||||||
def user_info():
|
def user_info():
|
||||||
|
@ -56,7 +67,7 @@ def user_info():
|
||||||
text = ""
|
text = ""
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
text = text + f"<p>{tag[0]}</p>"
|
text = text + f"<p>{tag[0]}</p>"
|
||||||
return f'<p>{user[1]}: {user[2]} <p><form action="/addtag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Add Tag</button></form><form action="/removetag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove Tag</button></form></p><form action="/change" method="get"><input name="id" type="hidden" value="{user[0]}"> Change balance: <input name="change"><input type="submit"></form></p><br></br><p>Tags:</p>{text}<br></br><form action="/removeuser/confirmation" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove User</button></form>{text}'
|
return f'<p>{user[1]}: {user[2]} <p><form action="/addtag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Add Tag</button></form><form action="/removetag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove Tag</button></form></p><form action="/change" method="get"><input name="id" type="hidden" value="{user[0]}"> Change balance: <input name="change"><input type="submit"></form></p><br></br><p>Tags:</p>{text}<br></br><form action="/removeuser/confirmation" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove User</button></form>'
|
||||||
else:
|
else:
|
||||||
return "User does not exists"
|
return "User does not exists"
|
||||||
|
|
||||||
|
@ -144,9 +155,7 @@ def request_addtag(data):
|
||||||
finished = None
|
finished = None
|
||||||
c.execute(f"SELECT * FROM users WHERE id ={user[0]}")
|
c.execute(f"SELECT * FROM users WHERE id ={user[0]}")
|
||||||
username = c.fetchall()[0][1]
|
username = c.fetchall()[0][1]
|
||||||
c.execute(f"SELECT * FROM tags WHERE userid={user[0]}")
|
socketio.emit("finished", f"Added tag to {username}", to=session[id]) #print tagid
|
||||||
tag_id = c.fetchall()[0][0]
|
|
||||||
socketio.emit("finished", f"Added {tag_id} to {username}", to=session[id])
|
|
||||||
else:
|
else:
|
||||||
socketio.emit("busy", "busy", to=session[id])
|
socketio.emit("busy", "busy", to=session[id])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue