mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
allow users to stop learning from fedi accounts
This commit is contained in:
parent
8f476ca981
commit
c25e0764fe
2 changed files with 45 additions and 0 deletions
27
templates/bot_accounts_delete.html
Normal file
27
templates/bot_accounts_delete.html
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>FediBooks</title>
|
||||||
|
{% include 'imports.html' %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="container centred">
|
||||||
|
<h1 class="thin centred">Stop learning from account</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container centred">
|
||||||
|
<form method='POST'>
|
||||||
|
<div class="panel-icon large"></div>
|
||||||
|
<div class="container centred">
|
||||||
|
<p>Are you sure you want {{ bot }} to stop learning from {{ user }}?</p>
|
||||||
|
<a class="button btn-secondary" href="/"><i class="fas fa-times"></i> Cancel</a>
|
||||||
|
<button class="button btn-dangerous"><i class="fas fa-trash"></i> Stop learning</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% include 'footer.html' %}
|
||||||
|
</body>
|
||||||
|
</html>
|
18
webui.py
18
webui.py
|
@ -184,6 +184,24 @@ def bot_accounts_toggle(id):
|
||||||
c.close()
|
c.close()
|
||||||
return redirect("/bot/accounts/{}".format(session['bot']), 303)
|
return redirect("/bot/accounts/{}".format(session['bot']), 303)
|
||||||
|
|
||||||
|
@app.route("/bot/accounts/delete/<id>", methods=['GET', 'POST'])
|
||||||
|
def bot_accounts_delete(id):
|
||||||
|
if request.method == 'GET':
|
||||||
|
instance = id.split("@")[2]
|
||||||
|
return render_template("bot_accounts_delete.html", user = id, instance = instance)
|
||||||
|
else:
|
||||||
|
#NOTE: when user credential support is added, we'll need to delete the creds too
|
||||||
|
c = mysql.connection.cursor()
|
||||||
|
c.execute("DELETE FROM `bot_learned_accounts` WHERE `fedi_id` = %s AND bot_id = %s", (id, session['bot']))
|
||||||
|
# check to see if anyone else is learning from this account
|
||||||
|
c.execute("SELECT COUNT(*) FROM `bot_learned_accounts` WHERE `fedi_id` = %s", (id,))
|
||||||
|
if c.fetchone()[0] == 0:
|
||||||
|
# nobody else learns from this account, remove it from the db
|
||||||
|
c.execute("DELETE FROM `fedi_accounts` WHERE `handle` = %s", (id,))
|
||||||
|
c.close()
|
||||||
|
mysql.connection.commit()
|
||||||
|
|
||||||
|
return redirect(url_for("/bot/accounts/{}".format(session['bot'])), 303)
|
||||||
|
|
||||||
@app.route("/bot/create/", methods=['GET', 'POST'])
|
@app.route("/bot/create/", methods=['GET', 'POST'])
|
||||||
def bot_create():
|
def bot_create():
|
||||||
|
|
Loading…
Reference in a new issue