2021-08-20 12:44:03 +01:00
|
|
|
from quart import g, abort, render_template
|
|
|
|
|
|
|
|
from lnbits.decorators import check_user_exists, validate_uuids
|
|
|
|
from http import HTTPStatus
|
|
|
|
|
|
|
|
from . import streamalerts_ext
|
|
|
|
from .crud import get_service
|
|
|
|
|
|
|
|
|
2021-08-21 00:34:48 +01:00
|
|
|
@streamalerts_ext.get("/")
|
2021-08-20 12:44:03 +01:00
|
|
|
@validate_uuids(["usr"], required=True)
|
|
|
|
@check_user_exists()
|
|
|
|
async def index():
|
|
|
|
"""Return the extension's settings page"""
|
|
|
|
return await render_template("streamalerts/index.html", user=g.user)
|
|
|
|
|
|
|
|
|
2021-08-21 00:34:48 +01:00
|
|
|
@streamalerts_ext.get("/<state>")
|
2021-08-20 12:44:03 +01:00
|
|
|
async def donation(state):
|
|
|
|
"""Return the donation form for the Service corresponding to state"""
|
|
|
|
service = await get_service(0, by_state=state)
|
|
|
|
if not service:
|
|
|
|
abort(HTTPStatus.NOT_FOUND, "Service does not exist.")
|
|
|
|
return await render_template(
|
|
|
|
"streamalerts/display.html",
|
|
|
|
twitchuser=service.twitchuser,
|
|
|
|
service=service.id
|
|
|
|
)
|