diff --git a/Website/__init__.py b/Website/__init__.py index 307dace..d942b8e 100644 --- a/Website/__init__.py +++ b/Website/__init__.py @@ -283,6 +283,31 @@ def create_app(test_config=None): socketio.emit("error", "418", to=session[id]) leave_room(session[id]) + @app.route("/transfare") + def transfare(): + db = get_db() + c = db.cursor() + c.execute("SELECT * FROM users") + user_list = c.fetchall() + return render_template("transfare.html", user_list=user_list) + + @app.route("/api/transfare", methods=['POST']) + def api_transfare(): + db = get_db() + c = db.cursor() + transfare_from = request.form["transfarefrom"] + transfare_to = request.form["transfareto"] + change = int(request.form["change"]) * 100 + c.execute("SELECT * FROM users WHERE id=?", [transfare_from]) + if c.fetchall() == []: + return render_template("error.html", error_code="043") + c.execute("SELECT * FROM users WHERE id=?", [transfare_to]) + if c.fetchall() == []: + return render_template("error.html", error_code="043") + db_handler.change_balance(transfare_from, -change) + db_handler.change_balance(transfare_to, change) + return render_template("redirect.html") + @app.route("/api/balance", methods=['POST', 'GET']) def api_change(): if request.method == 'POST': diff --git a/Website/templates/base.html b/Website/templates/base.html index 69fdd57..cb34bcc 100644 --- a/Website/templates/base.html +++ b/Website/templates/base.html @@ -17,6 +17,7 @@ | user and tag list | Documentation | transactionlist + | transfare


diff --git a/Website/templates/transfare.html b/Website/templates/transfare.html new file mode 100644 index 0000000..22c1c73 --- /dev/null +++ b/Website/templates/transfare.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} + +{% block title %} + transfare +{% endblock %} +{% block content %} +
+

+ +

+

+ +

+

+ +

+

+ + +

+
+{% endblock %} +