|
|
@@ -2,7 +2,7 @@ from flask import flash, render_template, Blueprint, current_app, redirect, requ
|
|
|
from datetime import timezone
|
|
|
from ownchatbot.db import get_db, reread_goals, reread_votes, rem_vote, reset_vote, reset_goal, clear_fulfilled_rewards, clear_reward_queue, rem_cool, rem_from_queue
|
|
|
from ownchatbot.reward_handlers import all_active_votes, all_active_goals, all_active_rewards, get_queue, fulfill_reward, save_rewards, activate_category, deactivate_category, refund_reward, reread_categories, save_config
|
|
|
-from ownchatbot.user_handlers import get_all_users, get_all_users_by_name, refund_points, adjust_points, change_email, get_email_code, del_email_code
|
|
|
+from ownchatbot.user_handlers import get_all_users, get_all_users_by_name, refund_points, adjust_points, change_email, get_email_code, del_email_code, save_todolist, save_todocss
|
|
|
from ownchatbot.bot_messages import save_announce
|
|
|
from ownchatbot.owncast_com import send_private_chat
|
|
|
import json
|
|
|
@@ -103,6 +103,9 @@ def mgmt():
|
|
|
announce_enable = current_app.config['ANNOUNCE_ENABLE']
|
|
|
announce_interval = current_app.config['ANNOUNCE_INTERVAL']
|
|
|
announcements = current_app.config['ANNOUNCEMENTS']
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
+ todo_css = current_app.config['CSS']
|
|
|
+ active_tab = request.args.get('activeTab')
|
|
|
settings_info = [
|
|
|
access_id,
|
|
|
points_interval,
|
|
|
@@ -116,7 +119,7 @@ def mgmt():
|
|
|
announce_enable,
|
|
|
announce_interval
|
|
|
]
|
|
|
-
|
|
|
+
|
|
|
return render_template('mgmt.html',
|
|
|
queue=get_queue(db),
|
|
|
votes=all_active_votes(db),
|
|
|
@@ -132,7 +135,10 @@ def mgmt():
|
|
|
utc_timezone=utc_timezone,
|
|
|
active_categories=active_categories,
|
|
|
inactive_categories=inactive_categories,
|
|
|
- settings_info=settings_info)
|
|
|
+ settings_info=settings_info,
|
|
|
+ items=todolist_items,
|
|
|
+ todo_css=todo_css,
|
|
|
+ activeTab=active_tab)
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt_queue', methods=['GET']) # The streamer's management panel
|
|
|
@@ -231,7 +237,7 @@ def edit_account(user_id):
|
|
|
current_app.logger.info(f'Removed {name}\'s email')
|
|
|
else:
|
|
|
current_app.logger.info(f'Changed {name}\'s email to {newemail}')
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='accounts'))
|
|
|
|
|
|
return render_template('edit_account.html',
|
|
|
name=name,
|
|
|
@@ -251,7 +257,7 @@ def delete(reward_name):
|
|
|
if reread_votes():
|
|
|
if reread_goals():
|
|
|
pass
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='managerewards'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/edit/<reward_name>', methods=['GET', 'POST'])
|
|
|
@@ -300,7 +306,7 @@ def edit(reward_name):
|
|
|
reread_goals()
|
|
|
if reward_data['type'] == 'vote':
|
|
|
reread_votes()
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='managerewards'))
|
|
|
|
|
|
return render_template('edit.html',
|
|
|
all_cats=all_cats,
|
|
|
@@ -312,6 +318,7 @@ def edit(reward_name):
|
|
|
@ocb.route('/mgmt/settings', methods=['GET', 'POST']) # OwnchatBot settings panel
|
|
|
@requires_login
|
|
|
def settings():
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
points_interval = int(request.form['points_interval'])
|
|
|
points_award = int(request.form['points_award'])
|
|
|
gunicorn_logging = 'gunicorn_logging' in request.form
|
|
|
@@ -335,7 +342,7 @@ def settings():
|
|
|
if save_config(config_dict): # Save new config.py
|
|
|
current_app.logger.info('Saved new config.')
|
|
|
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='settings'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/announcements', methods=['GET', 'POST']) # OwnchatBot settings panel
|
|
|
@@ -353,7 +360,7 @@ def announcements():
|
|
|
if save_announce(announce_dict): # Save new announce.py
|
|
|
current_app.logger.info('Saved new announcements.')
|
|
|
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='announcements'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/ksettings', methods=['GET', 'POST']) # OwnchatBot settings panel
|
|
|
@@ -376,7 +383,7 @@ def ksettings():
|
|
|
if save_kofi_settings(kofi_settings_dict):
|
|
|
current_app.logger.info(f'Saved Kofi settings')
|
|
|
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='kofi-settings'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/add/<reward_type>', methods=['GET', 'POST'])
|
|
|
@@ -459,7 +466,7 @@ def add(reward_type):
|
|
|
inactive_categories = current_app.config['INACTIVE_CAT']
|
|
|
inactive_categories.append(name) # Add it to the INACTIVE_CAT variable
|
|
|
reread_categories() # Write it to categories.py
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='managerewards'))
|
|
|
|
|
|
return render_template('add.html',
|
|
|
all_cats=all_cats,
|
|
|
@@ -491,13 +498,13 @@ def set_viewer_email():
|
|
|
@ocb.route('/mgmt/activate/<category>', methods=['GET', 'POST'])
|
|
|
def activate(category):
|
|
|
activate_category(category)
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='categories'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/deactivate/<category>', methods=['GET', 'POST'])
|
|
|
def deactivate(category):
|
|
|
deactivate_category(category)
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='categories'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/delcat/<cat_name>/<cat_act>', methods=['GET', 'POST'])
|
|
|
@@ -514,7 +521,7 @@ def delcat(cat_name, cat_act):
|
|
|
if cat_name in details['categories']:
|
|
|
details['categories'].remove(cat_name)
|
|
|
save_rewards(current_rewards)
|
|
|
- return redirect(url_for('web_panels.mgmt'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='categories'))
|
|
|
|
|
|
|
|
|
@ocb.route('/mgmt/reset/<reward_name>/<reward_type>', methods=['GET', 'POST']) # Reset votes and goals to zero
|
|
|
@@ -544,6 +551,63 @@ def clear_queue():
|
|
|
return redirect(url_for('web_panels.mgmtqueue'))
|
|
|
|
|
|
|
|
|
+@ocb.route('/mgmt/addtodocss', methods=['POST'])
|
|
|
+def add_todo_css():
|
|
|
+ if request.method == 'POST':
|
|
|
+ new_css = request.form.get('todo_css')
|
|
|
+ if not new_css:
|
|
|
+ new_css = """body {
|
|
|
+ background-color: transparent;
|
|
|
+ color: white;
|
|
|
+}"""
|
|
|
+ if save_todocss(new_css): # Save todo list
|
|
|
+ current_app.logger.info('Saved to-do CSS.')
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+
|
|
|
+
|
|
|
+@ocb.route('/mgmt/addtodoitem', methods=['POST'])
|
|
|
+def add_todo_item():
|
|
|
+ if request.method == 'POST':
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
+ item = request.form.get('item')
|
|
|
+ if item:
|
|
|
+ todolist_items.append({'name': item, 'crossed': 'no'})
|
|
|
+ if save_todolist(todolist_items): # Save todo list
|
|
|
+ current_app.logger.info('Saved to-do list.')
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+
|
|
|
+
|
|
|
+@ocb.route('/mgmt/cross/<int:item_id>')
|
|
|
+def cross(item_id):
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
+ if 0 <= item_id < len(todolist_items):
|
|
|
+ todolist_items[item_id]['crossed'] = 'yes'
|
|
|
+ if save_todolist(todolist_items): # Save todo list
|
|
|
+ current_app.logger.info('Saved to-do list.')
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+
|
|
|
+
|
|
|
+@ocb.route('/mgmt/uncross/<int:item_id>')
|
|
|
+def uncross(item_id):
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
+ if 0 <= item_id < len(todolist_items):
|
|
|
+ todolist_items[item_id]['crossed'] = 'no'
|
|
|
+ if save_todolist(todolist_items): # Save todo list
|
|
|
+ current_app.logger.info('Saved to-do list.')
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+
|
|
|
+
|
|
|
+@ocb.route('/mgmt/clearlist')
|
|
|
+def clear_list():
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
+ todolist_items = [] # Clear the list
|
|
|
+ if save_todolist(todolist_items): # Save todo list
|
|
|
+ current_app.logger.info('Saved to-do list.')
|
|
|
+ return redirect(url_for('web_panels.mgmt', activeTab='todolist'))
|
|
|
+
|
|
|
+
|
|
|
@ocb.route('/goals', methods=['GET']) # Route for goals overlay
|
|
|
def goals():
|
|
|
db = get_db()
|
|
|
@@ -557,3 +621,10 @@ def votes():
|
|
|
db = get_db()
|
|
|
return render_template('votes.html',
|
|
|
votes=all_active_votes(db))
|
|
|
+
|
|
|
+
|
|
|
+@ocb.route('/todo')
|
|
|
+def todo():
|
|
|
+ todolist_items = current_app.config['LIST']
|
|
|
+ todolist_css = current_app.config['CSS']
|
|
|
+ return render_template('list.html', items=todolist_items, css=todolist_css)
|