2022-10-18 14:04:15 +02:00
|
|
|
from flask import render_template, Blueprint, request
|
2022-09-07 16:44:59 +02:00
|
|
|
from tlapbot.db import get_db
|
2022-10-18 14:04:15 +02:00
|
|
|
from tlapbot.owncast_helpers import (pretty_redeem_queue, all_counters,
|
|
|
|
read_users_points_from_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()
|
|
|
|
queue = pretty_redeem_queue(db)
|
|
|
|
counters = all_counters(db)
|
2022-10-18 14:04:15 +02:00
|
|
|
username = request.args.get("username")
|
|
|
|
if username is not None:
|
|
|
|
user_points = read_users_points_from_username(db, username)
|
|
|
|
else:
|
|
|
|
user_points = None
|
2022-09-26 16:51:44 +02:00
|
|
|
utc_timezone = timezone.utc
|
|
|
|
return render_template('dashboard.html',
|
|
|
|
queue=queue,
|
2022-10-12 15:48:57 +02:00
|
|
|
counters=counters,
|
2022-10-18 14:04:15 +02:00
|
|
|
username=username,
|
|
|
|
user_points=user_points,
|
2022-10-17 18:47:30 +02:00
|
|
|
utc_timezone=utc_timezone)
|