mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 08:38:59 +00:00
implemented bot deletion
This commit is contained in:
parent
494c1d8960
commit
46118ae9fa
2 changed files with 17 additions and 4 deletions
|
@ -12,7 +12,7 @@
|
|||
</div>
|
||||
|
||||
<div class="container centred">
|
||||
<form>
|
||||
<form method='POST'>
|
||||
<div class="panel-icon large"></div>
|
||||
<div class="container centred">
|
||||
<p>Are you sure you want to <strong>permanently</strong> delete this bot?</p>
|
||||
|
|
15
webui.py
15
webui.py
|
@ -69,6 +69,7 @@ def show_signup_page(error = None):
|
|||
|
||||
@app.route("/settings")
|
||||
def settings():
|
||||
return render_template("coming_soon.html")
|
||||
dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
|
||||
dc.execute("SELECT * FROM `users` WHERE id = %s", (session['user_id'],))
|
||||
user = dc.fetchone()
|
||||
|
@ -79,11 +80,23 @@ def settings():
|
|||
def bot_edit(id):
|
||||
return render_template("bot_edit.html")
|
||||
|
||||
@app.route("/bot/delete/<id>")
|
||||
@app.route("/bot/delete/<id>", methods=['GET', 'POST'])
|
||||
def bot_delete(id):
|
||||
if bot_check(id):
|
||||
if request.method == 'GET':
|
||||
instance = id.split("@")[2]
|
||||
return render_template("bot_delete.html", instance = instance)
|
||||
else:
|
||||
# delete bot by deleting its credentials
|
||||
# FK constraint will delete bot
|
||||
c = mysql.connection.cursor()
|
||||
c.execute("SELECT `credentials_id` FROM `bots` WHERE `handle` = %s", (id,))
|
||||
credentials_id = c.fetchone()[0]
|
||||
c.execute("DELETE FROM `credentials` WHERE `id` = %s", (credentials_id,))
|
||||
c.close()
|
||||
mysql.connection.commit()
|
||||
|
||||
return redirect(url_for("home"), 303)
|
||||
|
||||
@app.route("/bot/toggle/<id>")
|
||||
def bot_toggle(id):
|
||||
|
|
Loading…
Reference in a new issue