2022-11-07 17:31:01 +01:00
|
|
|
from flask import render_template, Blueprint, request, current_app
|
2022-09-07 16:44:59 +02:00
|
|
|
from tlapbot.db import get_db
|
2023-03-20 17:28:54 +01:00
|
|
|
from tlapbot.redeems import all_counters, all_milestones, pretty_redeem_queue
|
|
|
|
from tlapbot.owncast_helpers import read_all_users_with_username
|
2022-09-26 16:51:44 +02:00
|
|
|
from datetime import datetime, timezone
|
2022-09-07 16:44:59 +02:00
|
|
|
|
|
|
|
bp = Blueprint('redeem_dashboard', __name__)
|
|
|
|
|
2022-10-17 18:47:30 +02:00
|
|
|
|
|
|
|
@bp.route('/dashboard', methods=['GET'])
|
2022-09-07 16:44:59 +02:00
|
|
|
def dashboard():
|
2022-10-12 15:48:57 +02:00
|
|
|
db = get_db()
|
2022-10-18 14:04:15 +02:00
|
|
|
username = request.args.get("username")
|
|
|
|
if username is not None:
|
2022-10-20 16:10:28 +02:00
|
|
|
users = read_all_users_with_username(db, username)
|
2022-11-22 11:33:05 +01:00
|
|
|
else:
|
2022-10-20 16:10:28 +02:00
|
|
|
users = []
|
2022-09-26 16:51:44 +02:00
|
|
|
utc_timezone = timezone.utc
|
|
|
|
return render_template('dashboard.html',
|
2023-01-04 12:30:38 +01:00
|
|
|
queue=pretty_redeem_queue(db),
|
|
|
|
counters=all_counters(db),
|
2023-03-14 15:42:14 +01:00
|
|
|
milestones=all_milestones(db),
|
2023-01-04 12:30:38 +01:00
|
|
|
redeems=current_app.config['REDEEMS'],
|
2023-01-04 12:37:56 +01:00
|
|
|
prefix=current_app.config['PREFIX'],
|
2023-03-13 15:22:40 +01:00
|
|
|
passive=current_app.config['PASSIVE'],
|
2022-10-18 14:04:15 +02:00
|
|
|
username=username,
|
2022-10-20 16:10:28 +02:00
|
|
|
users=users,
|
2022-10-17 18:47:30 +02:00
|
|
|
utc_timezone=utc_timezone)
|