diff --git a/Website/__init__.py b/Website/__init__.py index 87ec39c..1ec1223 100644 --- a/Website/__init__.py +++ b/Website/__init__.py @@ -5,7 +5,7 @@ from flask_session import Session from markupsafe import escape from .db import get_db from datetime import datetime - +finished = None #flask_config DATABASE = './Website/mate.db' @@ -134,7 +134,7 @@ def create_app(test_config=None): {escape(user[1])}

user and tag list | Documentation

-

{escape(user[1])} : {user[2]}€

+

{escape(user[1])} : {escape(user[2])}€

@@ -206,6 +206,7 @@ def create_app(test_config=None): try: user_id = request.form["id"] change = float(request.form["change"]) + print(change) except: return render_template("error.html", error_code="095") c.execute(f"SELECT * FROM users WHERE id=?", [user_id]) @@ -345,7 +346,7 @@ def create_app(test_config=None): state = queue_item[1] c.execute(f"SELECT * FROM users WHERE id=?", [user]) - user = c.fetchall() + user = c.fetchone() user_id = user[0] username = user[1] if state == "add": @@ -355,17 +356,19 @@ def create_app(test_config=None): finished = queue_item return make_response(json.dumps({"mode":"error","error":"170"})) else: - c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, ?)", [user]) + c.execute(f"INSERT OR IGNORE INTO tags (tagid, userid) VALUES ({tag_id}, ?)", [user_id]) db.commit() + message = f"Added {tag_id} to {username}" log(type="addtag", userid=user_id ,after=tag_id) finished = queue_item return make_response(json.dumps({"mode":"message","username":"{}".format(username),"message":"A tag was added"})) elif state == "remove": - c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = ?)", [user]) + c.execute(f"SELECT * FROM tags WHERE (tagid = {tag_id} AND userid = ?)", [user_id]) tags = c.fetchall() if tags != []: - 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_id]) db.commit() + message = f"Removed {tag_id} from {username}" log(type="removetag", userid=user_id, before=tag_id) finished = queue_item return make_response(json.dumps({"mode":"message","username":"{}".format(username),"message":"A tag was removed"})) diff --git a/Website/schema.sql b/Website/schema.sql index 55c7d1a..56a152e 100644 --- a/Website/schema.sql +++ b/Website/schema.sql @@ -6,7 +6,7 @@ CREATE TABLE IF NOT EXISTS "users" ( PRIMARY KEY("id") ); CREATE TABLE IF NOT EXISTS "tags" ( - "tagid" INTEGER NOT NULL, + "tagid" INEGER NOT NULL, "userid" INTEGER, FOREIGN KEY("userid") REFERENCES "users"("id"), PRIMARY KEY("tagid")