show profile picture on bot delete page, clean up icon display code

This commit is contained in:
Lynne Megido 2019-09-21 15:54:57 +10:00
parent 11d6d06695
commit 8f6dbfeaf4
3 changed files with 8 additions and 5 deletions

View File

@ -13,10 +13,10 @@
<div class="container centred">
<form method='POST'>
<div class="panel-icon large"></div>
<div class="panel-icon large" style="{{ 'background-image: url(\'' + icon + '\')' if icon else '' }}"></div>
<div class="container centred">
<p>Are you sure you want to <strong>permanently</strong> delete this bot?</p>
<p>The account on {{ instance }} will remain open, but your bot will stop posting from it.</p>
<p>The account on {{ instance }} will remain open, but FediBooks will stop posting from it.</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> Delete bot</button>
</div>

View File

@ -19,7 +19,7 @@
<div class="container" style="min-height: 300px;">
{% for bot in bots %}
<div class="row light">
<div class="panel-icon {{ "online" if bot['enabled'] else "offline"}}" style="{{ "background-image: url('" + bot['icon'] + "')" if bot['icon'] else "" }}"></div>
<div class="panel-icon {{ 'online' if bot['enabled'] else 'offline'}}" style="{{ 'background-image: url(\'' + bot['icon'] + '\')' if bot['icon'] else '' }}"></div>
<div class="panel-text">
{% set handle_list = bot['handle'].split('@') %}
<div class="panel-name">@{{ handle_list[1] }}<span class="subtle tiny">@{{ handle_list[2] }}</span></div>

View File

@ -70,12 +70,15 @@ def bot_delete(id):
if bot_check(id):
if request.method == 'GET':
instance = id.split("@")[2]
return render_template("bot/delete.html", instance = instance)
c = mysql.connection.cursor()
c.execute("SELECT icon FROM bots WHERE handle = %s", (id,))
icon = c.fetchone()[0]
return render_template("bot/delete.html", instance = instance, icon = icon)
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,))
c.execute("SELECT credentials_id FROM bots WHERE handle = %s", (id,))
credentials_id = c.fetchone()[0]
c.execute("SELECT client_id, client_secret, secret FROM credentials WHERE id = %s", (credentials_id,))
credentials = c.fetchone()