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
No known key found for this signature in database
GPG key ID: 645FA807E935D9D5
3 changed files with 8 additions and 8 deletions

View file

@ -4,10 +4,10 @@
<q-card class="q-pa-lg">
<q-card-section class="q-pa-none">
<div class="text-center">
<a href="lightning:{{ link.lnurl }}">
<a href="lightning:{{ lnurl }}">
<q-responsive :ratio="1" class="q-mx-md">
<qrcode
value="{{ link.lnurl }}"
value="{{ lnurl }}"
:options="{width: 800}"
class="rounded-borders"
></qrcode>
@ -15,7 +15,7 @@
</a>
</div>
<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
>
</div>

View file

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

View file

@ -30,8 +30,8 @@ async def display(request: Request,link_id):
detail="Pay link does not exist."
)
# abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
return lnurlp_renderer().TemplateResponse("lnurlp/display.html", {"request": request, "link":link})
ctx = {"request": request, "lnurl":link.lnurl(req=request)}
return lnurlp_renderer().TemplateResponse("lnurlp/display.html", ctx)
@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."
)
# abort(HTTPStatus.NOT_FOUND, "Pay link does not exist.")
return lnurlp_renderer().TemplateResponse("lnurlp/print_qr.html", {"request": request, "link":link})
ctx = {"request": request, "lnurl":link.lnurl(req=request)}
return lnurlp_renderer().TemplateResponse("lnurlp/print_qr.html", ctx)