diff --git a/Website/__init__.py b/Website/__init__.py index 307dace..dd06e73 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(float(request.form["change"]) * float(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