fix: lnurlp templates and path functions

While rendering the tempaltes the link.lnurl() function was not found
as no request object was passed.

Compute the lnurl before rendering the template. This way we can avoid
computing it multiple times and do not to have to pass the request object
in the template.
This commit is contained in:
Stefan Stammberger
2021-10-10 11:05:43 +02:00
parent d319aca6cf
commit c1a82dad9d
3 changed files with 8 additions and 8 deletions

View File

@@ -4,10 +4,10 @@
<q-card class="q-pa-lg"> <q-card class="q-pa-lg">
<q-card-section class="q-pa-none"> <q-card-section class="q-pa-none">
<div class="text-center"> <div class="text-center">
<a href="lightning:{{ link.lnurl }}"> <a href="lightning:{{ lnurl }}">
<q-responsive :ratio="1" class="q-mx-md"> <q-responsive :ratio="1" class="q-mx-md">
<qrcode <qrcode
value="{{ link.lnurl }}" value="{{ lnurl }}"
:options="{width: 800}" :options="{width: 800}"
class="rounded-borders" class="rounded-borders"
></qrcode> ></qrcode>
@@ -15,7 +15,7 @@
</a> </a>
</div> </div>
<div class="row q-mt-lg"> <div class="row q-mt-lg">
<q-btn outline color="grey" @click="copyText('{{ link.lnurl }}')" <q-btn outline color="grey" @click="copyText('{{ lnurl }}')"
>Copy LNURL</q-btn >Copy LNURL</q-btn
> >
</div> </div>

View File

@@ -1,7 +1,7 @@
{% extends "print.html" %} {% block page %} {% extends "print.html" %} {% block page %}
<div class="row justify-center"> <div class="row justify-center">
<div class="qr"> <div class="qr">
<qrcode value="{{ link.lnurl }}" :options="{width}"></qrcode> <qrcode value="{{ lnurl }}" :options="{width}"></qrcode>
</div> </div>
</div> </div>
{% endblock %} {% block styles %} {% endblock %} {% block styles %}

View File

@@ -30,8 +30,8 @@ async def display(request: Request,link_id):
detail="Pay link does not exist." detail="Pay link does not exist."
) )
# abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.") # abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
ctx = {"request": request, "lnurl":link.lnurl(req=request)}
return lnurlp_renderer().TemplateResponse("lnurlp/display.html", {"request": request, "link":link}) return lnurlp_renderer().TemplateResponse("lnurlp/display.html", ctx)
@lnurlp_ext.get("/print/{link_id}", response_class=HTMLResponse) @lnurlp_ext.get("/print/{link_id}", response_class=HTMLResponse)
@@ -43,5 +43,5 @@ async def print_qr(request: Request,link_id):
detail="Pay link does not exist." detail="Pay link does not exist."
) )
# abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.") # abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
ctx = {"request": request, "lnurl":link.lnurl(req=request)}
return lnurlp_renderer().TemplateResponse("lnurlp/print_qr.html", {"request": request, "link":link}) return lnurlp_renderer().TemplateResponse("lnurlp/print_qr.html", ctx)