Remove User tag list
This commit is contained in:
parent
54b3f8c049
commit
9233e716b2
1 changed files with 20 additions and 7 deletions
27
main.py
27
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'<p>{user[1]}: {user[2]} <p><form action="/addtag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Add Tag</button></form><form action="/removetag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove Tag</button></form></p><form action="/change" method="get"><input name="id" type="hidden" value="{user[0]}"> Change balance: <input name="change"><input type="submit"></form></p>'
|
||||
user[0]
|
||||
c.execute(f"SELECT * FROM tags WHERE userid={user[0]}")
|
||||
tags = c.fetchall()
|
||||
text = ""
|
||||
for tag in tags:
|
||||
text = text + f"<p>{tag[0]}</p>"
|
||||
return f'<p>{user[1]}: {user[2]} <p><form action="/addtag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Add Tag</button></form><form action="/removetag" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove Tag</button></form></p><form action="/change" method="get"><input name="id" type="hidden" value="{user[0]}"> Change balance: <input name="change"><input type="submit"></form></p><br></br><p>Tags:</p>{text}<br></br><form action="/removeuser" method="get"><input name="id" type="hidden" value="{user[0]}"><button type="submit">Remove User</button></form>{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")
|
||||
|
|
Loading…
Reference in a new issue