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