From 9233e716b21b98a99639715251496bd65fe08d20 Mon Sep 17 00:00:00 2001 From: 2000-Trek Date: Sat, 10 Jun 2023 00:09:52 +0200 Subject: [PATCH] Remove User tag list --- main.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 2537d4c..d6e4b1f 100644 --- a/main.py +++ b/main.py @@ -50,8 +50,13 @@ def user_info(): c.execute("SELECT * FROM users WHERE username = '%s'" % username) user = c.fetchall() if user != []: - user = user[0] - return f'

{user[1]}: {user[2]}

Change balance:

' + user[0] + c.execute(f"SELECT * FROM tags WHERE userid={user[0]}") + tags = c.fetchall() + text = "" + for tag in tags: + text = text + f"

{tag[0]}

" + return f'

{user[1]}: {user[2]}

Change balance:



Tags:

{text}

{text}' else: return "User does not exists" @@ -59,6 +64,13 @@ def user_info(): def new_user(): return render_template("adduser.html") +@app.route("/removeuser", methode=['GET']) +def remove_user(): + user_id = request.args.get("id") + c.execute(f"DELETE * FROM tags WHERE (userid = {user_id}) ") #Ist hier noch eine Bestätigung nötig? + c.execute(f"DELETE * FROM users WHERE (id={user_id})") + conn.commit() + @app.route("/adduser/user", methods=['GET']) def adduser(): user = request.args.get("username") @@ -122,9 +134,9 @@ def request_addtag(data): break else: finished = None - c.execute(f"SELECT * FROM users WHERE id ={user}") + c.execute(f"SELECT * FROM users WHERE id ={user[0]}") username = c.fetchall()[0][1] - c.execute(f"SELECT * FROM tags WHERE userid={user}") + c.execute(f"SELECT * FROM tags WHERE userid={user[0]}") tag_id = c.fetchall()[0][0] socketio.emit("finished", f"Added {tag_id} to {username}", to=session[id]) else: @@ -150,10 +162,11 @@ def request_removetag(data): global finished join_room(session[id]) if len(users.queue) > 0: - user = users.queue[len(users.queue) - 1] + queue_item = users.queue[len(users.queue) - 1] + user = queue[0] print(user) print(session[id]) - if user == [data["data"], "remove", session[id]]: + if queue_item == [data["data"], "remove", session[id]]: socketio.emit("wait", "wait", to=session[id]) i = 0 print(session[id]) @@ -195,7 +208,7 @@ def get_id(): if state == "add": c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, {user})") elif state == "remove": - c.execute(f"DELETE FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ") + c.execute(f"DELETE * FROM tags WHERE (tagid = {tag_id} AND userid = {user}) ") conn.commit() finished = queue_item return make_response("True")