forked from bton/matekasse
Ahhhh
This commit is contained in:
parent
ce8acc10b1
commit
6f0edf0feb
1 changed files with 13 additions and 13 deletions
|
@ -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_socketio import SocketIO, join_room, leave_room
|
||||||
from flask_session import Session
|
from flask_session import Session
|
||||||
from Website.db import get_db
|
from Website.db import get_db
|
||||||
import Website.db as db
|
import Website.db as db_handler
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
finished = None
|
finished = None
|
||||||
preis = 150 #Ein Getraenk
|
preis = 150 #Ein Getraenk
|
||||||
|
@ -141,7 +141,7 @@ def create_app(test_config=None):
|
||||||
user = c.fetchone()
|
user = c.fetchone()
|
||||||
if user != None:
|
if user != None:
|
||||||
user_name = user[1]
|
user_name = user[1]
|
||||||
db.remove_user(user_id)
|
db_handler.remove_user(user_id)
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
return render_template("removeuser.html", user_name=user_name)
|
return render_template("removeuser.html", user_name=user_name)
|
||||||
else:
|
else:
|
||||||
|
@ -156,7 +156,7 @@ def create_app(test_config=None):
|
||||||
return render_template("error.html", error_code="418")
|
return render_template("error.html", error_code="418")
|
||||||
c.execute("SELECT * FROM users WHERE username=?", [username])
|
c.execute("SELECT * FROM users WHERE username=?", [username])
|
||||||
if c.fetchall() == []:
|
if c.fetchall() == []:
|
||||||
db.add_user(username)
|
db_handler.add_user(username)
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
c.execute(f"SELECT * FROM users WHERE username=?", [username])
|
c.execute(f"SELECT * FROM users WHERE username=?", [username])
|
||||||
user = c.fetchone()
|
user = c.fetchone()
|
||||||
|
@ -178,7 +178,7 @@ def create_app(test_config=None):
|
||||||
users = c.fetchall()
|
users = c.fetchall()
|
||||||
if users != []:
|
if users != []:
|
||||||
balance_old = users[0][2]
|
balance_old = users[0][2]
|
||||||
db.change_balance(user_id, change)
|
db_handler.change_balance(user_id, change)
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
return render_template("redirect.html")
|
return render_template("redirect.html")
|
||||||
else:
|
else:
|
||||||
|
@ -240,7 +240,7 @@ def create_app(test_config=None):
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
c.execute(f"SELECT * FROM tags WHERE (tagid = ? AND userid = ?)", [tag_id, user_id])
|
c.execute(f"SELECT * FROM tags WHERE (tagid = ? AND userid = ?)", [tag_id, user_id])
|
||||||
if c.fetchall != []:
|
if c.fetchall != []:
|
||||||
db.remove_tag(tag_id)
|
db_handler.remove_tag(tag_id)
|
||||||
message = f"Removed {tag_id} from user {user_id}"
|
message = f"Removed {tag_id} from user {user_id}"
|
||||||
return render_template("redirect.html")
|
return render_template("redirect.html")
|
||||||
else:
|
else:
|
||||||
|
@ -287,7 +287,7 @@ def create_app(test_config=None):
|
||||||
change = int(request.args.get("change"))
|
change = int(request.args.get("change"))
|
||||||
except:
|
except:
|
||||||
change = preis
|
change = preis
|
||||||
db.change_balance(user_id, change)
|
db_handler.change_balance(user_id, change)
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user_new[2]}))
|
return make_response(json.dumps({"mode":"balance", "username":user[1], "balance":user_new[2]}))
|
||||||
else:
|
else:
|
||||||
|
@ -335,7 +335,7 @@ def create_app(test_config=None):
|
||||||
finished = queue_item
|
finished = queue_item
|
||||||
return make_response(json.dumps({"mode":"error","error":"170"}))
|
return make_response(json.dumps({"mode":"error","error":"170"}))
|
||||||
else:
|
else:
|
||||||
db.add_tag(user_id, tag_id)
|
db_handler.add_tag(user_id, tag_id)
|
||||||
message = f"Added {tag_id} to {username}"
|
message = f"Added {tag_id} to {username}"
|
||||||
finished = queue_item
|
finished = queue_item
|
||||||
return make_response(json.dumps({"mode":"message","username":"{}".format(username),"message":"A tag was added"}))
|
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 != []:
|
if user_list != []:
|
||||||
balance_old = user_list[0][2]
|
balance_old = user_list[0][2]
|
||||||
if user_queue.qsize() == 0:
|
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]}")
|
c.execute(f"SELECT * FROM users WHERE id={tag[1]}")
|
||||||
user = c.fetchone()
|
user = c.fetchone()
|
||||||
socketio.emit("update", "update")
|
socketio.emit("update", "update")
|
||||||
|
@ -382,15 +382,15 @@ def create_app(test_config=None):
|
||||||
change = request.form["change"]
|
change = request.form["change"]
|
||||||
|
|
||||||
if statement == "adduser":
|
if statement == "adduser":
|
||||||
db.add_user(after)
|
db_handler.add_user(after)
|
||||||
elif statement == "removeuser":
|
elif statement == "removeuser":
|
||||||
db.remove_user(user_id)
|
db_handler.remove_user(user_id)
|
||||||
elif statement == "addtag":
|
elif statement == "addtag":
|
||||||
db.add_tag(user_id, after)
|
db_handler.add_tag(user_id, after)
|
||||||
elif statement == "removetag":
|
elif statement == "removetag":
|
||||||
db.remove_tag(befor)
|
db_handler.remove_tag(befor)
|
||||||
elif statement == "balance":
|
elif statement == "balance":
|
||||||
db.change_balance(user_id, change)
|
db_handler.change_balance(user_id, change)
|
||||||
else:
|
else:
|
||||||
return make_response(json.dumps({"mode":"error", "error":"418"})) #Error code
|
return make_response(json.dumps({"mode":"error", "error":"418"})) #Error code
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue