From 27c398156933bf8e2c4574f427494ae7a94ad411 Mon Sep 17 00:00:00 2001
From: 2000-Trek
Date: Sat, 25 Nov 2023 19:28:05 +0100
Subject: [PATCH] remove tag button
---
Website/__init__.py | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/Website/__init__.py b/Website/__init__.py
index ac88ef2..8d93fe3 100644
--- a/Website/__init__.py
+++ b/Website/__init__.py
@@ -124,7 +124,7 @@ def create_app(test_config=None):
tags = c.fetchall()
text = ""
for tag in tags:
- text = text + f"{tag[0]}
"
+ text = text + f'
'
return f"""
@@ -273,11 +273,26 @@ def create_app(test_config=None):
user_id = int(request.form["id"])
except: #except im Normalen Code!
return render_template("error.html", error_code="043")
- session_id = uuid.uuid4()
- session[id] = session_id
- user_queue.put([user_id, "remove", session_id])
- return render_template("removetag.html", user=user_id)
-
+ try:
+ tag_id = int(request.form["tagid"])
+ except:
+ session_id = uuid.uuid4()
+ session[id] = session_id
+ user_queue.put([user_id, "remove", session_id])
+ return render_template("removetag.html", user=user_id)
+ else:
+ db = get_db()
+ c = db.cursor()
+ c.execute(f"SELECT * FROM tags WHERE (tagid = ? AND userid = ?)", [tag_id, user_id])
+ if c.fetchall != []:
+ c.execute(f"DELETE FROM tags WHERE (tagid = ? AND userid = ?)", [tag_id, user_id])
+ db.commit()
+ message = f"Removed {tag_id} from user {user_id}"
+ log(type="removetag", userid=user_id, before=tag_id)
+ return message
+ else:
+ return render_template("error.html", error_code="054")
+
@socketio.on('removetag')
def request_removetag(data):
global finished