commit
266e220f94
3 changed files with 13 additions and 10 deletions
|
|
@ -12,4 +12,4 @@ templates = Jinja2Templates(directory="templates")
|
||||||
@validate_uuids(["usr"], required=True)
|
@validate_uuids(["usr"], required=True)
|
||||||
@check_user_exists()
|
@check_user_exists()
|
||||||
async def index(request: Request):
|
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})
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,5 @@ templates = Jinja2Templates(directory="templates")
|
||||||
@validate_uuids(["usr"], required=True)
|
@validate_uuids(["usr"], required=True)
|
||||||
@check_user_exists()
|
@check_user_exists()
|
||||||
async def index(request: Request):
|
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})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,28 @@ from lnbits.decorators import check_user_exists, validate_uuids
|
||||||
|
|
||||||
from . import withdraw_ext
|
from . import withdraw_ext
|
||||||
from .crud import get_withdraw_link, chunks
|
from .crud import get_withdraw_link, chunks
|
||||||
|
from fastapi import FastAPI, Request
|
||||||
|
from fastapi.templating import Jinja2Templates
|
||||||
|
|
||||||
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
@withdraw_ext.get("/")
|
@withdraw_ext.get("/")
|
||||||
@validate_uuids(["usr"], required=True)
|
@validate_uuids(["usr"], required=True)
|
||||||
@check_user_exists()
|
@check_user_exists()
|
||||||
async def index():
|
async def index(request: Request):
|
||||||
return await render_template("withdraw/index.html", user=g.user)
|
return await templates.TemplateResponse("withdraw/index.html", {"request":request,"user":g.user})
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext.get("/<link_id>")
|
@withdraw_ext.get("/<link_id>")
|
||||||
async def display(link_id):
|
async def display(request: Request, link_id):
|
||||||
link = await get_withdraw_link(link_id, 0) or abort(
|
link = await get_withdraw_link(link_id, 0) or abort(
|
||||||
HTTPStatus.NOT_FOUND, "Withdraw link does not exist."
|
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/<link_id>")
|
@withdraw_ext.get("/img/<link_id>")
|
||||||
async def img(link_id):
|
async def img(request: Request, link_id):
|
||||||
link = await get_withdraw_link(link_id, 0) or abort(
|
link = await get_withdraw_link(link_id, 0) or abort(
|
||||||
HTTPStatus.NOT_FOUND, "Withdraw link does not exist."
|
HTTPStatus.NOT_FOUND, "Withdraw link does not exist."
|
||||||
)
|
)
|
||||||
|
|
@ -44,12 +47,12 @@ async def img(link_id):
|
||||||
|
|
||||||
|
|
||||||
@withdraw_ext.get("/print/<link_id>")
|
@withdraw_ext.get("/print/<link_id>")
|
||||||
async def print_qr(link_id):
|
async def print_qr(request: Request, link_id):
|
||||||
link = await get_withdraw_link(link_id) or abort(
|
link = await get_withdraw_link(link_id) or abort(
|
||||||
HTTPStatus.NOT_FOUND, "Withdraw link does not exist."
|
HTTPStatus.NOT_FOUND, "Withdraw link does not exist."
|
||||||
)
|
)
|
||||||
if link.uses == 0:
|
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 = []
|
links = []
|
||||||
count = 0
|
count = 0
|
||||||
for x in link.usescsv.split(","):
|
for x in link.usescsv.split(","):
|
||||||
|
|
@ -60,4 +63,4 @@ async def print_qr(link_id):
|
||||||
count = count + 1
|
count = count + 1
|
||||||
page_link = list(chunks(links, 2))
|
page_link = list(chunks(links, 2))
|
||||||
linked = list(chunks(page_link, 5))
|
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})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue