Tlapbot/tlapbot/tlapbot_dashboard.py

29 lines
1.1 KiB
Python
Raw Normal View History

from flask import render_template, Blueprint, request, current_app
from tlapbot.db import get_db
from tlapbot.redeems import all_active_counters, all_active_milestones, all_active_redeems, pretty_redeem_queue
2024-02-10 13:38:26 +01:00
from tlapbot.owncast_helpers import read_all_users_with_username
2024-02-10 13:33:09 +01:00
from datetime import timezone
bp = Blueprint('redeem_dashboard', __name__)
2022-10-17 18:47:30 +02:00
@bp.route('/dashboard', methods=['GET'])
def dashboard():
db = get_db()
2022-10-18 14:04:15 +02:00
username = request.args.get("username")
if username is not None:
users = read_all_users_with_username(db, username)
2022-11-22 11:33:05 +01:00
else:
users = []
utc_timezone = timezone.utc
return render_template('dashboard.html',
queue=pretty_redeem_queue(db),
counters=all_active_counters(db),
milestones=all_active_milestones(db),
2024-02-10 13:33:09 +01:00
redeems=all_active_redeems(),
2023-01-04 12:37:56 +01:00
prefix=current_app.config['PREFIX'],
passive=current_app.config['PASSIVE'],
2022-10-18 14:04:15 +02:00
username=username,
users=users,
2022-10-17 18:47:30 +02:00
utc_timezone=utc_timezone)