From 6f0edf0feb122c2490a3bbee03992ccc0d05c20c Mon Sep 17 00:00:00 2001 From: bton Date: Wed, 13 Mar 2024 19:26:21 +0100 Subject: [PATCH] Ahhhh --- Website/__init__.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Website/__init__.py b/Website/__init__.py index 84dc176..3e310e1 100644 --- a/Website/__init__.py +++ b/Website/__init__.py @@ -3,7 +3,7 @@ from flask import Flask, render_template, render_template_string, request, make_ from flask_socketio import SocketIO, join_room, leave_room from flask_session import Session from Website.db import get_db -import Website.db as db +import Website.db as db_handler from datetime import datetime finished = None preis = 150 #Ein Getraenk @@ -141,7 +141,7 @@ def create_app(test_config=None): user = c.fetchone() if user != None: user_name = user[1] - db.remove_user(user_id) + db_handler.remove_user(user_id) socketio.emit("update", "update") return render_template("removeuser.html", user_name=user_name) else: @@ -156,7 +156,7 @@ def create_app(test_config=None): return render_template("error.html", error_code="418") c.execute("SELECT * FROM users WHERE username=?", [username]) if c.fetchall() == []: - db.add_user(username) + db_handler.add_user(username) socketio.emit("update", "update") c.execute(f"SELECT * FROM users WHERE username=?", [username]) user = c.fetchone() @@ -178,7 +178,7 @@ def create_app(test_config=None): users = c.fetchall() if users != []: balance_old = users[0][2] - db.change_balance(user_id, change) + db_handler.change_balance(user_id, change) socketio.emit("update", "update") return render_template("redirect.html") else: @@ -240,7 +240,7 @@ def create_app(test_config=None): c = db.cursor() c.execute(f"SELECT * FROM tags WHERE (tagid = ? AND userid = ?)", [tag_id, user_id]) if c.fetchall != []: - db.remove_tag(tag_id) + db_handler.remove_tag(tag_id) message = f"Removed {tag_id} from user {user_id}" return render_template("redirect.html") else: @@ -287,7 +287,7 @@ def create_app(test_config=None): change = int(request.args.get("change")) except: change = preis - db.change_balance(user_id, change) + db_handler.change_balance(user_id, change) socketio.emit("update", "update") return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user_new[2]})) else: @@ -335,7 +335,7 @@ def create_app(test_config=None): finished = queue_item return make_response(json.dumps({"mode":"error","error":"170"})) else: - db.add_tag(user_id, tag_id) + db_handler.add_tag(user_id, tag_id) message = f"Added {tag_id} to {username}" finished = queue_item return make_response(json.dumps({"mode":"message","username":"{}".format(username),"message":"A tag was added"})) @@ -362,7 +362,7 @@ def create_app(test_config=None): if user_list != []: balance_old = user_list[0][2] if user_queue.qsize() == 0: - db.change_balance(tag[1], preis) + db_handler.change_balance(tag[1], preis) c.execute(f"SELECT * FROM users WHERE id={tag[1]}") user = c.fetchone() socketio.emit("update", "update") @@ -382,15 +382,15 @@ def create_app(test_config=None): change = request.form["change"] if statement == "adduser": - db.add_user(after) + db_handler.add_user(after) elif statement == "removeuser": - db.remove_user(user_id) + db_handler.remove_user(user_id) elif statement == "addtag": - db.add_tag(user_id, after) + db_handler.add_tag(user_id, after) elif statement == "removetag": - db.remove_tag(befor) + db_handler.remove_tag(befor) elif statement == "balance": - db.change_balance(user_id, change) + db_handler.change_balance(user_id, change) else: return make_response(json.dumps({"mode":"error", "error":"418"})) #Error code