mirror of
https://github.com/Lynnesbian/FediBooks/
synced 2024-11-25 16:48:58 +00:00
fix bot creation and home pages
This commit is contained in:
parent
879b53889d
commit
950db1de8e
2 changed files with 5 additions and 5 deletions
|
@ -22,10 +22,10 @@
|
||||||
<div class="panel-icon {% if bot['enabled'] %}online{% else %}offline{% endif %}"></div>
|
<div class="panel-icon {% if bot['enabled'] %}online{% else %}offline{% endif %}"></div>
|
||||||
<div class="panel-text">
|
<div class="panel-text">
|
||||||
<div class="panel-name">{{ bot['handle'] }}</div>
|
<div class="panel-name">{{ bot['handle'] }}</div>
|
||||||
<div class="panel-status">{% if bot['enabled'] %}Online{% else %}Offline{% endif %}, learning from {{ bot_users[bot['id']] }} accounts</div>
|
<div class="panel-status">{% if bot['enabled'] %}Online{% else %}Offline{% endif %}, learning from {{ bot_users[bot['handle']] }} accounts</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-actions">
|
<div class="panel-actions">
|
||||||
<a class="button btn-secondary" href="/bot/toggle/{{ bot['id'] }}" title="Turn on/off"><i class="fas fa-power-off"></i></a><a class="button btn-secondary" href="/bot/edit/{{ bot['id'] }}" title="Configure"><i class="fas fa-cog"></i></a><a class="button btn-secondary" href="/bot/accounts/{{ bot['id'] }}" title="Accounts learned from"><i class="fas fa-users"></i></a><a class="button btn-secondary" href="/bot/blacklist/{{ bot['id'] }}" title="Banned words"><i class="fas fa-strikethrough"></i></a><a class="button btn-secondary" href="/bot/chat/{{ bot['id'] }}" title="Chat"><i class="fas fa-comment"></i></a><a class="button btn-dangerous" href="/bot/delete/{{ bot['id'] }}" title="Delete"><i class="fas fa-trash"></i></a>
|
<a class="button btn-secondary" href="/bot/toggle/{{ bot['handle'] }}" title="Turn on/off"><i class="fas fa-power-off"></i></a><a class="button btn-secondary" href="/bot/edit/{{ bot['handle'] }}" title="Configure"><i class="fas fa-cog"></i></a><a class="button btn-secondary" href="/bot/accounts/{{ bot['handle'] }}" title="Accounts learned from"><i class="fas fa-users"></i></a><a class="button btn-secondary" href="/bot/blacklist/{{ bot['handle'] }}" title="Banned words"><i class="fas fa-strikethrough"></i></a><a class="button btn-secondary" href="/bot/chat/{{ bot['handle'] }}" title="Chat"><i class="fas fa-comment"></i></a><a class="button btn-dangerous" href="/bot/delete/{{ bot['handle'] }}" title="Delete"><i class="fas fa-trash"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
6
webui.py
6
webui.py
|
@ -35,7 +35,7 @@ def home():
|
||||||
c.execute("SELECT COUNT(*) FROM `bots` WHERE user_id = %s AND enabled = TRUE", (session['user_id'],))
|
c.execute("SELECT COUNT(*) FROM `bots` WHERE user_id = %s AND enabled = TRUE", (session['user_id'],))
|
||||||
active_count = c.fetchone()[0]
|
active_count = c.fetchone()[0]
|
||||||
dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
|
dc = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
|
||||||
dc.execute("SELECT handle` FROM `bots` WHERE user_id = %s", (session['user_id'],))
|
dc.execute("SELECT `handle` FROM `bots` WHERE user_id = %s", (session['user_id'],))
|
||||||
bots = dc.fetchall()
|
bots = dc.fetchall()
|
||||||
dc.close()
|
dc.close()
|
||||||
bot_users = {}
|
bot_users = {}
|
||||||
|
@ -156,7 +156,8 @@ def bot_create():
|
||||||
session['step'] = 1
|
session['step'] = 1
|
||||||
return bot_create()
|
return bot_create()
|
||||||
|
|
||||||
elif session['step'] == 4:
|
else:
|
||||||
|
if session['step'] == 4:
|
||||||
try:
|
try:
|
||||||
# test authentication
|
# test authentication
|
||||||
client = Mastodon(client_id=session['client_id'], client_secret=session['client_secret'], api_base_url=session['instance'])
|
client = Mastodon(client_id=session['client_id'], client_secret=session['client_secret'], api_base_url=session['instance'])
|
||||||
|
@ -175,7 +176,6 @@ def bot_create():
|
||||||
|
|
||||||
c.execute("INSERT INTO `bots` (handle, user_id, credentials_id) VALUES (%s, %s, %s)", (handle, session['user_id'], credentials_id))
|
c.execute("INSERT INTO `bots` (handle, user_id, credentials_id) VALUES (%s, %s, %s)", (handle, session['user_id'], credentials_id))
|
||||||
mysql.connection.commit()
|
mysql.connection.commit()
|
||||||
|
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
# clean up unneeded variables
|
# clean up unneeded variables
|
||||||
|
|
Loading…
Reference in a new issue