lnbits-legend/lnbits/extensions/streamalerts/views.py

29 lines
846 B
Python
Raw Normal View History

2021-06-28 19:02:47 +02:00
from quart import g, abort, render_template
2021-06-20 06:34:01 +02:00
from lnbits.decorators import check_user_exists, validate_uuids
2021-06-28 19:02:47 +02:00
from http import HTTPStatus
2021-06-20 06:34:01 +02:00
2021-08-01 04:54:43 +02:00
from . import streamalerts_ext
2021-06-28 19:02:47 +02:00
from .crud import get_service
2021-06-20 06:34:01 +02:00
2021-08-01 04:54:43 +02:00
@streamalerts_ext.route("/")
2021-06-20 06:34:01 +02:00
@validate_uuids(["usr"], required=True)
@check_user_exists()
async def index():
2021-07-03 18:01:04 +02:00
"""Return the extension's settings page"""
2021-08-01 04:54:43 +02:00
return await render_template("streamalerts/index.html", user=g.user)
2021-06-28 19:02:47 +02:00
2021-08-01 04:54:43 +02:00
@streamalerts_ext.route("/<state>")
2021-06-28 19:02:47 +02:00
async def donation(state):
2021-07-03 18:01:04 +02:00
"""Return the donation form for the Service corresponding to state"""
2021-06-28 19:02:47 +02:00
service = await get_service(0, by_state=state)
if not service:
abort(HTTPStatus.NOT_FOUND, "Service does not exist.")
2021-07-07 10:19:16 +01:00
return await render_template(
2021-08-01 05:22:28 +02:00
"streamalerts/display.html",
twitchuser=service.twitchuser,
service=service.id
2021-07-07 10:19:16 +01:00
)