feat: update to lnbits 1.0.0 (#41)
--------- Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
This commit is contained in:
parent
239bfb65ab
commit
7f8b269ecd
12 changed files with 1513 additions and 1457 deletions
23
views.py
23
views.py
|
|
@ -1,16 +1,13 @@
|
|||
from http import HTTPStatus
|
||||
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from lnbits.core.models import User
|
||||
from lnbits.decorators import check_user_exists
|
||||
from lnbits.helpers import template_renderer
|
||||
from starlette.exceptions import HTTPException
|
||||
from starlette.responses import HTMLResponse
|
||||
|
||||
from .crud import get_card_by_external_id, get_hits, get_refunds
|
||||
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
boltcards_generic_router = APIRouter()
|
||||
|
||||
|
||||
|
|
@ -21,7 +18,7 @@ def boltcards_renderer():
|
|||
@boltcards_generic_router.get("/", response_class=HTMLResponse)
|
||||
async def index(request: Request, user: User = Depends(check_user_exists)):
|
||||
return boltcards_renderer().TemplateResponse(
|
||||
"boltcards/index.html", {"request": request, "user": user.dict()}
|
||||
"boltcards/index.html", {"request": request, "user": user.json()}
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -32,15 +29,11 @@ async def display(request: Request, card_id: str):
|
|||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Card does not exist."
|
||||
)
|
||||
hits = [hit.dict() for hit in await get_hits([card.id])]
|
||||
refunds = [
|
||||
refund.hit_id for refund in await get_refunds([hit["id"] for hit in hits])
|
||||
]
|
||||
card_dict = card.dict()
|
||||
# Remove wallet id from card dict
|
||||
del card_dict["wallet"]
|
||||
|
||||
hits = await get_hits([card.id])
|
||||
hits_json = [hit.json() for hit in hits]
|
||||
refunds = [refund.hit_id for refund in await get_refunds([hit.id for hit in hits])]
|
||||
card_json = card.json(exclude={"wallet"})
|
||||
return boltcards_renderer().TemplateResponse(
|
||||
"boltcards/display.html",
|
||||
{"request": request, "card": card_dict, "hits": hits, "refunds": refunds},
|
||||
{"request": request, "card": card_json, "hits": hits_json, "refunds": refunds},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue