Converted views

This commit is contained in:
Ben Arc
2021-08-21 01:55:07 +01:00
parent d3d24abb17
commit bbdb96f4ac
21 changed files with 177 additions and 112 deletions
+10 -6
View File
@@ -5,24 +5,28 @@ from http import HTTPStatus
from . import streamalerts_ext
from .crud import get_service
from fastapi import FastAPI, Request
from fastapi.templating import Jinja2Templates
templates = Jinja2Templates(directory="templates")
@streamalerts_ext.get("/")
@validate_uuids(["usr"], required=True)
@check_user_exists()
async def index():
async def index(request: Request):
"""Return the extension's settings page"""
return await render_template("streamalerts/index.html", user=g.user)
return await templates.TemplateResponse("streamalerts/index.html", {"request":request, "user":g.user})
@streamalerts_ext.get("/<state>")
async def donation(state):
async def donation(request: Request, 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(
return await templates.TemplateResponse(
"streamalerts/display.html",
twitchuser=service.twitchuser,
service=service.id
{"request":request,
"twitchuser":service.twitchuser,
"service":service.id}
)