From ec758d9d8f3292cd683adfdde7341155c8547645 Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 2 Sep 2019 20:44:03 +1000 Subject: [PATCH] users can now toggle accounts the bot learns from --- templates/bot_accounts.html | 2 +- webui.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/templates/bot_accounts.html b/templates/bot_accounts.html index 43eae1c..180ab7d 100644 --- a/templates/bot_accounts.html +++ b/templates/bot_accounts.html @@ -26,7 +26,7 @@
{{ "Active" if user['enabled'] else "Inactive" }}
- +
{% endfor %} diff --git a/webui.py b/webui.py index 0f7b5e9..6897ad9 100644 --- a/webui.py +++ b/webui.py @@ -172,10 +172,19 @@ def bot_accounts_add(): c.close() mysql.connection.commit() - return redirect("/bot/accounts/{}".format(session['bot'])) + return redirect("/bot/accounts/{}".format(session['bot']), 303) return render_template("bot_accounts_add.html") +@app.route("/bot/accounts/toggle/") +def bot_accounts_toggle(id): + c = mysql.connection.cursor() + c.execute("UPDATE `bot_learned_accounts` SET `enabled` = NOT `enabled` WHERE `fedi_id` = %s AND `bot_id` = %s", (id, session['bot'])) + mysql.connection.commit() + c.close() + return redirect("/bot/accounts/{}".format(session['bot']), 303) + + @app.route("/bot/create/", methods=['GET', 'POST']) def bot_create(): #TODO: error handling