diff --git a/lnbits/extensions/usermanager/views.py b/lnbits/extensions/usermanager/views.py index a0c51954..a01e8361 100644 --- a/lnbits/extensions/usermanager/views.py +++ b/lnbits/extensions/usermanager/views.py @@ -12,4 +12,4 @@ templates = Jinja2Templates(directory="templates") @validate_uuids(["usr"], required=True) @check_user_exists() async def index(request: Request): - return await render_template("usermanager/index.html", {"request":request,"user":g.user}) + return await templates.TemplateResponse("usermanager/index.html", {"request":request,"user":g.user}) diff --git a/lnbits/extensions/watchonly/views.py b/lnbits/extensions/watchonly/views.py index b448a9e7..59fad6ae 100644 --- a/lnbits/extensions/watchonly/views.py +++ b/lnbits/extensions/watchonly/views.py @@ -13,5 +13,5 @@ templates = Jinja2Templates(directory="templates") @validate_uuids(["usr"], required=True) @check_user_exists() async def index(request: Request): - return await render_template("watchonly/index.html", {"request":request,"user":g.user}) + return await templates.TemplateResponse("watchonly/index.html", {"request":request,"user":g.user}) diff --git a/lnbits/extensions/withdraw/views.py b/lnbits/extensions/withdraw/views.py index 1f1f6e6b..0f23d733 100644 --- a/lnbits/extensions/withdraw/views.py +++ b/lnbits/extensions/withdraw/views.py @@ -6,25 +6,28 @@ from lnbits.decorators import check_user_exists, validate_uuids from . import withdraw_ext from .crud import get_withdraw_link, chunks +from fastapi import FastAPI, Request +from fastapi.templating import Jinja2Templates +templates = Jinja2Templates(directory="templates") @withdraw_ext.get("/") @validate_uuids(["usr"], required=True) @check_user_exists() -async def index(): - return await render_template("withdraw/index.html", user=g.user) +async def index(request: Request): + return await templates.TemplateResponse("withdraw/index.html", {"request":request,"user":g.user}) @withdraw_ext.get("/") -async def display(link_id): +async def display(request: Request, link_id): link = await get_withdraw_link(link_id, 0) or abort( HTTPStatus.NOT_FOUND, "Withdraw link does not exist." ) - return await render_template("withdraw/display.html", link=link, unique=True) + return await templates.TemplateResponse("withdraw/display.html", {"request":request,"link":link, "unique":True}) @withdraw_ext.get("/img/") -async def img(link_id): +async def img(request: Request, link_id): link = await get_withdraw_link(link_id, 0) or abort( HTTPStatus.NOT_FOUND, "Withdraw link does not exist." ) @@ -44,12 +47,12 @@ async def img(link_id): @withdraw_ext.get("/print/") -async def print_qr(link_id): +async def print_qr(request: Request, link_id): link = await get_withdraw_link(link_id) or abort( HTTPStatus.NOT_FOUND, "Withdraw link does not exist." ) if link.uses == 0: - return await render_template("withdraw/print_qr.html", link=link, unique=False) + return await templates.TemplateResponse("withdraw/print_qr.html", {"request":request,link:link, unique:False}) links = [] count = 0 for x in link.usescsv.split(","): @@ -60,4 +63,4 @@ async def print_qr(link_id): count = count + 1 page_link = list(chunks(links, 2)) linked = list(chunks(page_link, 5)) - return await render_template("withdraw/print_qr.html", link=linked, unique=True) + return await templates.TemplateResponse("withdraw/print_qr.html", {"request":request,"link":linked, "unique":True})